[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] Un-export vg_read_internal.



Hi,

this was waiting a fairly long time for a round tuit, but here it is. This
should properly banish vg_read_internal into confinement in metadata.c. Should
be fairly obvious, I am just being paranoid here. (I made sure clvmd still
compiles this time, too.)

Yours,
   Petr.

Index: daemons/clvmd/lvm-functions.c
===================================================================
RCS file: /cvs/lvm2/LVM2/daemons/clvmd/lvm-functions.c,v
retrieving revision 1.70
diff -u -p -r1.70 lvm-functions.c
--- daemons/clvmd/lvm-functions.c	22 Oct 2009 17:45:24 -0000	1.70
+++ daemons/clvmd/lvm-functions.c	2 Nov 2009 15:38:10 -0000
@@ -780,9 +780,9 @@ void lvm_do_backup(const char *vgname)
 
 	pthread_mutex_lock(&lvm_lock);
 
-	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent);
+	vg = vg_read(cmd, vgname, NULL /*vgid*/, 0 /*flags*/);
 
-	if (vg && consistent)
+	if (!vg_read_error(vg))
 		check_current_backup(vg);
 	else
 		log_error("Error backing up metadata, can't find VG for group %s", vgname);
Index: lib/metadata/metadata-exported.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata-exported.h,v
retrieving revision 1.121
diff -u -p -r1.121 metadata-exported.h
--- lib/metadata/metadata-exported.h	1 Nov 2009 20:05:17 -0000	1.121
+++ lib/metadata/metadata-exported.h	2 Nov 2009 15:38:10 -0000
@@ -380,8 +380,6 @@ void pvcreate_params_set_defaults(struct
 int vg_write(struct volume_group *vg);
 int vg_commit(struct volume_group *vg);
 int vg_revert(struct volume_group *vg);
-struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
-			     const char *vgid, int *consistent);
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct dm_list *mdas, uint64_t *label_sector,
 				int warnings, int scan_label_only);
@@ -472,7 +470,7 @@ int remove_lvs_in_vg(struct cmd_context 
 		     force_t force);
 /*
  * vg_release() must be called on every struct volume_group allocated
- * by vg_create() or vg_read_internal() to free it when no longer required.
+ * by vg_create() or vg_read() to free it when no longer required.
  */
 void vg_release(struct volume_group *vg);
 
Index: lib/metadata/metadata.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata.c,v
retrieving revision 1.295
diff -u -p -r1.295 metadata.c
--- lib/metadata/metadata.c	1 Nov 2009 20:05:17 -0000	1.295
+++ lib/metadata/metadata.c	2 Nov 2009 15:38:11 -0000
@@ -58,6 +58,10 @@ static struct physical_volume *_find_pv_
 static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
 				    uint32_t status);
 
+static struct volume_group *_vg_read_internal(struct cmd_context *cmd,
+					      const char *vgname,
+					      const char *vgid, int *consistent);
+
 const char _really_init[] =
     "Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
 
@@ -284,7 +288,7 @@ int get_pv_from_vg_by_id(const struct fo
 	struct pv_list *pvl;
 	int r = 0, consistent = 0;
 
-	if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = _vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
 		log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s",
 			  vg_name);
 		return 0;
@@ -786,10 +790,10 @@ struct volume_group *vg_create(struct cm
 		/* NOTE: let caller decide - this may be check for existence */
 		return _vg_make_handle(cmd, NULL, rc);
 
-	/* FIXME: Is this vg_read_internal necessary? Move it inside
+	/* FIXME: Is this _vg_read_internal necessary? Move it inside
 	   vg_lock_newname? */
 	/* is this vg name already in use ? */
-	if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
+	if ((vg = _vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 		log_error("A volume group called '%s' already exists.", vg_name);
 		unlock_and_release_vg(cmd, vg, vg_name);
 		return _vg_make_handle(cmd, NULL, FAILED_EXIST);
@@ -2490,7 +2494,7 @@ static struct volume_group *_vg_read(str
 
 	if (is_orphan_vg(vgname)) {
 		if (use_precommitted) {
-			log_error("Internal error: vg_read_internal requires vgname "
+			log_error("Internal error: _vg_read requires vgname "
 				  "with pre-commit.");
 			return NULL;
 		}
@@ -2779,8 +2783,9 @@ static struct volume_group *_vg_read(str
 	return correct_vg;
 }
 
-struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname,
-			     const char *vgid, int *consistent)
+static struct volume_group *_vg_read_internal(struct cmd_context *cmd,
+					      const char *vgname,
+					      const char *vgid, int *consistent)
 {
 	struct volume_group *vg;
 	struct lv_list *lvl;
@@ -3045,7 +3050,7 @@ static int _get_pvs(struct cmd_context *
 			stack;
 			continue;
 		}
-		if (!(vg = vg_read_internal(cmd, vgname, vgid, &consistent))) {
+		if (!(vg = _vg_read_internal(cmd, vgname, vgid, &consistent))) {
 			stack;
 			continue;
 		}
@@ -3279,7 +3284,7 @@ static struct volume_group *_recover_vg(
 	if (!lock_vol(cmd, lock_name, lock_flags))
 		return_NULL;
 
-	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
+	if (!(vg = _vg_read_internal(cmd, vg_name, vgid, &consistent)))
 		return_NULL;
 
 	if (!consistent) {
@@ -3336,7 +3341,7 @@ static struct volume_group *_vg_lock_and
 	consistent_in = consistent;
 
 	/* If consistent == 1, we get NULL here if correction fails. */
-	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = _vg_read_internal(cmd, vg_name, vgid, &consistent))) {
 		if (consistent_in && !consistent) {
 			log_error("Volume group \"%s\" inconsistent.", vg_name);
 			failure |= FAILED_INCONSISTENT;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]