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

Re: [lvm-devel] [PATCH] (1/2) new library interface for vg_read



Hi,

Dave Wysochanski <dwysocha redhat com> writes:
> Well, doesn't this cause a bug in this path though for the !consistent
> case?  First patch drops the consistent variable in this vgremove path,
> but things like _process_one_vg() do not use the new APIs (which sets
> the proper error codes) until the second patch.  You mention in your
> patch intro this first patch should apply and make a completely workable
> LVM so I'm assuming you mean no bugs.
Oh, hm, you are apparently right. Interestingly enough, the presumably buggy
code does pass the testsuite, so something's wrong with the testsuite, I
suppose. It might be good to have a test triggering that problem. I will
re-split the patch and resubmit later today.

To jstava@:

Could you please apply the attached patch? Now lvm with this patch should break
down on certain error conditions. I won't be able to exactly tell you how to
reproduce the problem, or whether it's even possible from the commandline at
this time, but if there is a testcase, it'll likely include inconsistent
metadata. If it turns out to be too hard, feel free to leave it alone. You
might be able to find extra info in this thread on lvm-devel  

Mon Dec 15 14:33:48 CET 2008  Petr Rockai <me mornfall net>
  * Library portions of vg_read patches.
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata.c new-lvmlib-b/lib/metadata/metadata.c
--- old-lvmlib-b/lib/metadata/metadata.c	2008-12-15 16:54:40.726808148 +0100
+++ new-lvmlib-b/lib/metadata/metadata.c	2008-12-15 16:54:40.814809905 +0100
@@ -224,8 +224,8 @@ int get_pv_from_vg_by_id(const struct fo
 	struct pv_list *pvl;
 	int consistent = 0;
 
-	if (!(vg = vg_read(fmt->cmd, vg_name, vgid, &consistent))) {
-		log_error("get_pv_from_vg_by_id: vg_read failed to read VG %s",
+	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;
 	}
@@ -332,7 +332,7 @@ static int remove_lvs_in_vg(struct cmd_c
 
 /* FIXME: remove redundant vg_name */
 int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
-		     struct volume_group *vg, int consistent,
+		     struct volume_group *vg,
 		     force_t force __attribute((unused)))
 {
 	struct physical_volume *pv;
@@ -340,7 +340,7 @@ int vg_remove_single(struct cmd_context 
 	unsigned lv_count;
 	int ret = 1;
 
-	if (!vg || !consistent || vg_missing_pv_count(vg)) {
+	if (vg_read_error(vg) || vg_missing_pv_count(vg)) {
 		log_error("Volume group \"%s\" not found, is inconsistent "
 			  "or has PVs missing.", vg_name);
 		log_error("Consider vgreduce --removemissing if metadata "
@@ -503,7 +503,7 @@ struct volume_group *vg_create(struct cm
 		return_NULL;
 
 	/* is this vg name already in use ? */
-	if (vg_read(cmd, vg_name, NULL, &consistent)) {
+	if (vg_read_internal(cmd, vg_name, NULL, &consistent)) {
 		log_err("A volume group called '%s' already exists.", vg_name);
 		goto bad;
 	}
@@ -1684,12 +1684,12 @@ int vg_missing_pv_count(const vg_t *vg)
 	return ret;
 }
 
-/* Caller sets consistent to 1 if it's safe for vg_read to correct
+/* Caller sets consistent to 1 if it's safe for vg_read_internal to correct
  * inconsistent metadata on disk (i.e. the VG write lock is held).
  * This guarantees only consistent metadata is returned.
  * If consistent is 0, caller must check whether consistent == 1 on return
  * and take appropriate action if it isn't (e.g. abort; get write lock
- * and call vg_read again).
+ * and call vg_read_internal again).
  *
  * If precommitted is set, use precommitted metadata if present.
  *
@@ -1716,7 +1716,7 @@ static struct volume_group *_vg_read(str
 
 	if (is_orphan_vg(vgname)) {
 		if (use_precommitted) {
-			log_error("Internal error: vg_read requires vgname "
+			log_error("Internal error: vg_read_internal requires vgname "
 				  "with pre-commit.");
 			return NULL;
 		}
@@ -1974,7 +1974,7 @@ static struct volume_group *_vg_read(str
 	return correct_vg;
 }
 
-struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
+struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname,
 			     const char *vgid, int *consistent)
 {
 	struct volume_group *vg;
@@ -2002,7 +2002,7 @@ struct volume_group *vg_read(struct cmd_
 
 /* This is only called by lv_from_lvid, which is only called from
  * activate.c so we know the appropriate VG lock is already held and
- * the vg_read is therefore safe.
+ * the vg_read_internal is therefore safe.
  */
 static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
 					    const char *vgid,
@@ -2034,7 +2034,7 @@ static struct volume_group *_vg_read_by_
 	if (memlock())
 		return NULL;
 
-	/* FIXME Need a genuine read by ID here - don't vg_read by name! */
+	/* FIXME Need a genuine read by ID here - don't vg_read_internal by name! */
 	/* FIXME Disabled vgrenames while active for now because we aren't
 	 *       allowed to do a full scan here any more. */
 
@@ -2218,7 +2218,7 @@ static int _get_pvs(struct cmd_context *
 			stack;
 			continue;
 		}
-		if (!(vg = vg_read(cmd, vgname, vgid, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vgname, vgid, &consistent))) {
 			stack;
 			continue;
 		}
@@ -2388,77 +2388,242 @@ int pv_analyze(struct cmd_context *cmd, 
  * 0 - fail
  * 1 - success
  */
-int vg_check_status(const struct volume_group *vg, uint32_t status)
+static uint32_t _vg_check_status(const struct volume_group *vg, uint32_t status)
 {
+	uint32_t ret = 0;
 	if ((status & CLUSTERED) &&
 	    (vg_is_clustered(vg)) && !locking_is_clustered() &&
 	    !lockingfailed()) {
 		log_error("Skipping clustered volume group %s", vg->name);
-		return 0;
+		ret |= FAILED_CLUSTERED;
 	}
 
 	if ((status & EXPORTED_VG) &&
 	    (vg->status & EXPORTED_VG)) {
 		log_error("Volume group %s is exported", vg->name);
-		return 0;
+		ret |= FAILED_EXPORTED;
 	}
 
 	if ((status & LVM_WRITE) &&
 	    !(vg->status & LVM_WRITE)) {
 		log_error("Volume group %s is read-only", vg->name);
-		return 0;
+		ret |= FAILED_READ_ONLY;
 	}
+
 	if ((status & RESIZEABLE_VG) &&
 	    !(vg->status & RESIZEABLE_VG)) {
 		log_error("Volume group %s is not resizeable.", vg->name);
-		return 0;
+		ret |= FAILED_RESIZEABLE;
 	}
 
+	return ret;
+}
+
+uint32_t vg_check_status(const struct volume_group *vg, uint32_t status)
+{
+	return !_vg_check_status(vg, status);
+}
+
+uint32_t vg_read_error(vg_t *vg) {
+	if (!vg)
+		return FAILED_ALLOCATION;
+	if (vg->read_failed & EXISTENCE_CHECK)
+		return vg->read_failed & ~(EXISTENCE_CHECK | FAILED_NOTFOUND);
+	return vg->read_failed;
+}
+
+/* Returns true if the volume group already exists. If unsure, it will return
+   true (it might exist, but we are not sure, as the read failed for some
+   other reason). */
+
+uint32_t vg_exists(vg_t *vg) {
+	if (!vg)
+		return 1;
+	log_error("vg_exists: %d != %d?", vg->read_failed, FAILED_NOTFOUND | EXISTENCE_CHECK);
+	if (vg->read_failed == (FAILED_NOTFOUND | EXISTENCE_CHECK))
+		return 0;
 	return 1;
 }
 
+static vg_t *_vg_make_handle(struct cmd_context *cmd,
+			     struct volume_group *vg,
+			     uint32_t failure)
+{
+	if (!vg)
+		if (!(vg = dm_pool_zalloc(cmd->mem, sizeof(*vg))))
+			return_NULL;
+	vg->read_failed = failure;
+	return vg;
+}
+
+/*
+ * High-level read-for-update function.
+ * On failure:
+ *  - out of memory: NULL is returned
+ *  - other: a volume group with "failed" field set to nonzero is returned
+ *
+ * Failures:
+ *  - metadata inconsistent and automatic correction failed: FAILED_INCONSISTENT
+ *  - VG is read-only: FAILED_READ_ONLY
+ *  - VG is EXPORTED, unless flags has ALLOW_EXPORTED: FAILED_EXPORTED
+ *  - VG is not RESIZEABLE, unless flags has ALLOW_NONRESIZEABLE:
+ *    FAILED_RESIZEABLE
+ *  - locking failed: FAILED_LOCKING
+ *
+ * On failures, all locks are released, unless KEEP_LOCK has been supplied.
+ *
+ * If EXISTENCE_CHECK is set in flags, if the VG exists, a non-NULL struct
+ * volume_group will be returned every time, but if it has INCONSISTENT_VG set,
+ * the other fields will be uninitialized. You *have to* check for
+ * INCONSISTENT_VG if passing EXISTENCE_CHECK. You also *must not* use it if it
+ * has INCONSISTENT_VG set.
+ */
+vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
+			 const char *vgid, uint32_t flags)
+{
+	return vg_read(cmd, vg_name, vgid, flags | READ_FOR_UPDATE);
+}
+
+/*
+ * FIXME we want vg_read to attempt automatic recovery after acquiring a
+ * temporary write lock -- if that fails, we bail out as usual, with failed &
+ * FAILED_INCONSISTENT. If it works, we are good to go. Code that's been in
+ * toollib just set lock type to LCK_WRITE and called vg_read_internal with
+ * *consistent = 1.
+ */
+vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
+	      const char *vgid, uint32_t flags)
+{
+	uint32_t status = CLUSTERED;
+	uint32_t lock = LCK_VG_READ;
+
+	if (flags & READ_FOR_UPDATE) {
+		status |= EXPORTED_VG | LVM_WRITE;
+		lock = LCK_VG_WRITE;
+	}
+
+	if (flags & ALLOW_EXPORTED)
+		status &= ~EXPORTED_VG;
+
+	if (flags & REQUIRE_RESIZEABLE)
+		status |= RESIZEABLE_VG;
+
+	if (flags & NONBLOCKING_LOCK)
+		lock |= LCK_NONBLOCK;
+
+	return vg_lock_and_read(cmd, vg_name, vgid, lock, status, flags);
+}
+
+static vg_t *_recover_vg(struct cmd_context *cmd, const char *lock, const char *vg_name,
+			 const char *vgid, uint32_t lock_flags )
+{
+	int consistent = 1;
+	struct volume_group *vg;
+
+	lock_flags &= ~LCK_TYPE_MASK;
+	lock_flags |= LCK_WRITE;
+
+	unlock_vg(cmd, lock);
+
+	dev_close_all();
+
+	if (!lock_vol(cmd, lock, lock_flags))
+		return_NULL;
+
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
+		return_NULL;
+	if (!consistent)
+		return_NULL;
+	return vg;
+}
+
 /*
  * vg_lock_and_read - consolidate vg locking, reading, and status flag checking
  *
+ * misc_flags:
+ *  ALLOW_INCONSISTENT: disable autocorrection
+ *  
+ * Setting ALLOW_INCONSISTENT might give you inconsistent metadata. You will
+ * *still* get FAILED_INCONSISTENT in case the metadata has *really* been
+ * inconsistent. However, you still get the latest version of metadata in VG.
+ *
+ *
+ *
  * Returns:
- * NULL - failure
- * non-NULL - success; volume group handle
+ * Use vg_read_error(vg) to determine the result. Nonzero vg_read_error(vg)
+ * means there were problems reading the volume group.
+ * Zero value means that the VG is open and appropriate locks are held.
  */
 vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
 		       const char *vgid,
 		       uint32_t lock_flags, uint32_t status_flags,
 		       uint32_t misc_flags)
 {
-	struct volume_group *vg;
+	struct volume_group *vg = 0;
+	const char *lock;
 	int consistent = 1;
+	int consistent_in;
+	uint32_t failure = 0;
 
-	if (!(misc_flags & CORRECT_INCONSISTENT))
-		consistent = 0;
+	if (misc_flags & ALLOW_INCONSISTENT || !(lock_flags & LCK_WRITE))
+	consistent = 0;
 
-	if (!validate_name(vg_name)) {
+	if (!validate_name(vg_name) && !is_orphan_vg(vg_name)) {
 		log_error("Volume group name %s has invalid characters",
 			  vg_name);
 		return NULL;
 	}
 
-	if (!lock_vol(cmd, vg_name, lock_flags)) {
-		log_error("Can't get lock for %s", vg_name);
-		return NULL;
+	lock = (misc_flags & ORPHAN_LOCK ? VG_ORPHANS : vg_name);
+	if (!(misc_flags & DISABLE_LOCK)) {
+		if (!lock_vol(cmd, lock, lock_flags)) {
+			log_error("Can't get lock for %s", vg_name);
+			return _vg_make_handle(cmd, vg, FAILED_LOCKING);
+		}
 	}
 
-	if (!(vg = vg_read(cmd, vg_name, vgid, &consistent)) ||
-	    ((misc_flags & FAIL_INCONSISTENT) && !consistent)) {
-		log_error("Volume group \"%s\" not found", vg_name);
-		unlock_vg(cmd, vg_name);
-		return NULL;
+	if (misc_flags & ORPHAN_LOCK)
+		status_flags &= ~LVM_WRITE;
+
+	if (misc_flags & EXISTENCE_CHECK)
+		consistent = 0;
+
+	consistent_in = consistent;
+
+	/* If consistent == 1, we get NULL here if correction fails. */
+	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;
+			goto_bad;
+		}
+		if (!(misc_flags & EXISTENCE_CHECK))
+			log_error("Volume group \"%s\" not found", vg_name);
+		failure |= FAILED_NOTFOUND | (misc_flags & EXISTENCE_CHECK);
+		goto_bad;
 	}
 
-	if (!vg_check_status(vg, status_flags)) {
-		unlock_vg(cmd, vg_name);
-		return NULL;
+	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
+	if (!consistent && !failure) {
+		vg = _recover_vg(cmd, lock, vg_name, vgid, lock_flags);
+		if (!vg) {
+			log_error("Recovery of volume group \"%s\" failed.",
+			  vg_name);
+			failure |= FAILED_INCONSISTENT;
+			goto_bad;
+		}
 	}
 
-	return vg;
+	failure |= _vg_check_status(vg, status_flags);
+	if (failure)
+		goto_bad;
+
+	return _vg_make_handle(cmd, vg, failure);
+ bad:
+	if (failure != (FAILED_NOTFOUND | EXISTENCE_CHECK))
+		if (!(misc_flags & KEEP_LOCK) && !(misc_flags & DISABLE_LOCK))
+			unlock_vg(cmd, lock);
+	return _vg_make_handle(cmd, vg, failure);
 }
 
 /*
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata-exported.h new-lvmlib-b/lib/metadata/metadata-exported.h
--- old-lvmlib-b/lib/metadata/metadata-exported.h	2008-12-15 16:54:40.726808148 +0100
+++ new-lvmlib-b/lib/metadata/metadata-exported.h	2008-12-15 16:54:40.810812749 +0100
@@ -76,7 +76,7 @@ struct pv_segment;
 						   written out in metadata*/
 
 //#define POSTORDER_FLAG	0x02000000U /* Not real flags, reserved for
-//#define POSTORDER_OPEN_FLAG	0x04000000U    temporary use inside vg_read. */
+//#define POSTORDER_OPEN_FLAG	0x04000000U    temporary use inside vg_read_internal. */
 
 #define LVM_READ              	0x00000100U	/* LV VG */
 #define LVM_WRITE             	0x00000200U	/* LV VG */
@@ -99,6 +99,32 @@ struct pv_segment;
 #define CORRECT_INCONSISTENT    0x00000001U /* Correct inconsistent metadata */
 #define FAIL_INCONSISTENT       0x00000002U /* Fail if metadata inconsistent */
 
+/* vg_read and vg_read_for_update flags */
+#define ALLOW_INCONSISTENT 0x1
+#define ALLOW_EXPORTED 0x2
+#define REQUIRE_RESIZEABLE 0x4
+#define EXISTENCE_CHECK 0x8
+
+#define NONBLOCKING_LOCK 0x100
+#define KEEP_LOCK 0x200
+#define DISABLE_LOCK 0x400
+#define ORPHAN_LOCK 0x800
+
+#define READ_FOR_UPDATE 0x1000
+
+/* vg's "read_failed" field */
+#define FAILED_INCONSISTENT 0x1
+#define FAILED_LOCKING 0x2
+#define FAILED_NOTFOUND 0x4
+// 0x8 is left out for EXISTENCE_CHECK
+
+#define FAILED_READ_ONLY 0x10
+#define FAILED_EXPORTED 0x20
+#define FAILED_RESIZEABLE 0x40
+#define FAILED_CLUSTERED 0x80
+
+#define FAILED_ALLOCATION 0x100
+
 /* Mirror conversion type flags */
 #define MIRROR_BY_SEG		0x00000001U	/* segment-by-segment mirror */
 #define MIRROR_BY_LV		0x00000002U	/* mirror using whole mimage LVs */
@@ -197,6 +223,8 @@ struct volume_group {
 	char *system_id;
 
 	uint32_t status;
+	uint32_t read_failed;
+
 	alloc_policy_t alloc;
 
 	uint32_t extent_size;
@@ -328,7 +356,7 @@ struct lv_list {
 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(struct cmd_context *cmd, const char *vg_name,
+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,
@@ -348,11 +376,20 @@ int is_orphan(const pv_t *pv);
 int vgs_are_compatible(struct cmd_context *cmd,
 		       struct volume_group *vg_from,
 		       struct volume_group *vg_to);
+
 vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
 		       const char *vgid,
 		       uint32_t lock_flags, uint32_t status_flags,
 		       uint32_t misc_flags);
 
+uint32_t vg_read_error(vg_t *vg);
+uint32_t vg_exists(vg_t *vg);
+vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
+	      const char *vgid, uint32_t flags);
+
+vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
+			 const char *vgid, uint32_t flags);
+
 /* pe_start and pe_end relate to any existing data so that new metadata
 * areas can avoid overlap */
 pv_t *pv_create(const struct cmd_context *cmd,
@@ -378,7 +415,7 @@ struct volume_group *vg_create(struct cm
 			       int pv_count, char **pv_names);
 int vg_remove(struct volume_group *vg);
 int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
-		     struct volume_group *vg, int consistent,
+		     struct volume_group *vg,
 		     force_t force);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
@@ -501,7 +538,7 @@ int vg_add_snapshot(const char *name,
 
 int vg_remove_snapshot(struct logical_volume *cow);
 
-int vg_check_status(const struct volume_group *vg, uint32_t status);
+uint32_t vg_check_status(const struct volume_group *vg, uint32_t status);
 
 /*
 * Mirroring functions
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata.h new-lvmlib-b/lib/metadata/metadata.h
--- old-lvmlib-b/lib/metadata/metadata.h	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/lib/metadata/metadata.h	2008-12-15 16:54:40.814809905 +0100
@@ -68,12 +68,13 @@
 //						   written out in metadata*/
 
 #define POSTORDER_FLAG		0x02000000U /* Not real flags, reserved for  */
-#define POSTORDER_OPEN_FLAG	0x04000000U /* temporary use inside vg_read. */
+#define POSTORDER_OPEN_FLAG	0x04000000U /* temporary use inside vg_read_internal. */
 
 //#define LVM_READ              	0x00000100U	/* LV VG */
 //#define LVM_WRITE             	0x00000200U	/* LV VG */
 //#define CLUSTERED         	0x00000400U	/* VG */
 #define SHARED            	0x00000800U	/* VG */
+//#define INCONSISTENT_VG         0x00001000U	/* VG */
 
 /* Format features flags */
 //#define FMT_SEGMENTS		0x00000001U	/* Arbitrary segment params? */
diff -rN -p -u old-lvmlib-b/tools/pvresize.c new-lvmlib-b/tools/pvresize.c
--- old-lvmlib-b/tools/pvresize.c	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/tools/pvresize.c	2008-12-15 16:54:40.778813291 +0100
@@ -62,7 +62,7 @@ static int _pv_resize_single(struct cmd_
 			return 0;
 		}
 
-		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 			unlock_vg(cmd, vg_name);
 			log_error("Unable to find volume group of \"%s\"",
 				  pv_name);
diff -rN -p -u old-lvmlib-b/tools/toollib.c new-lvmlib-b/tools/toollib.c
--- old-lvmlib-b/tools/toollib.c	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/tools/toollib.c	2008-12-15 16:54:40.782812263 +0100
@@ -347,7 +347,7 @@ int process_each_lv(struct cmd_context *
 			consistent = 1;
 		else
 			consistent = 0;
-		if (!(vg = vg_read(cmd, vgname, NULL, &consistent)) || !consistent) {
+		if (!(vg = vg_read_internal(cmd, vgname, NULL, &consistent)) || !consistent) {
 			unlock_vg(cmd, vgname);
 			if (!vg)
 				log_error("Volume group \"%s\" "
@@ -489,7 +489,7 @@ static int _process_one_vg(struct cmd_co
 	}
 
 	log_verbose("Finding volume group \"%s\"", vg_name);
-	if (!(vg = vg_read(cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) {
 		log_error("Volume group \"%s\" not found", vg_name);
 		unlock_vg(cmd, vg_name);
 		return ECMD_FAILED;
@@ -776,7 +776,7 @@ int process_each_pv(struct cmd_context *
 					log_error("Can't lock %s: skipping", sll->str);
 					continue;
 				}
-				if (!(vg = vg_read(cmd, sll->str, NULL, &consistent))) {
+				if (!(vg = vg_read_internal(cmd, sll->str, NULL, &consistent))) {
 					log_error("Volume group \"%s\" not found", sll->str);
 					unlock_vg(cmd, sll->str);
 					ret_max = ECMD_FAILED;
@@ -1199,7 +1199,7 @@ struct volume_group *recover_vg(struct c
 		return NULL;
 	}
 
-	return vg_read(cmd, vgname, NULL, &consistent);
+	return vg_read_internal(cmd, vgname, NULL, &consistent);
 }
 
 int apply_lvname_restrictions(const char *name)
diff -rN -p -u old-lvmlib-b/tools/vgreduce.c new-lvmlib-b/tools/vgreduce.c
--- old-lvmlib-b/tools/vgreduce.c	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/tools/vgreduce.c	2008-12-15 16:54:40.782812263 +0100
@@ -426,7 +426,7 @@ static int _vgreduce_single(struct cmd_c
 	vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
 	vg->extent_count -= pv_pe_count(pv);
 
-	if(!(orphan_vg = vg_read(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
+	if(!(orphan_vg = vg_read_internal(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
 	   !consistent) {
 		log_error("Unable to read existing orphan PVs");
 		unlock_vg(cmd, VG_ORPHANS);
@@ -520,7 +520,7 @@ int vgreduce(struct cmd_context *cmd, in
 		return ECMD_FAILED;
 	}
 
-	if ((!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent)
+	if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
 	    && !repairing) {
 		log_error("Volume group \"%s\" doesn't exist", vg_name);
 		unlock_vg(cmd, vg_name);
@@ -541,7 +541,7 @@ int vgreduce(struct cmd_context *cmd, in
 		}
 
 		consistent = !arg_count(cmd, force_ARG);
-		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 			log_error("Volume group \"%s\" not found", vg_name);
 			unlock_vg(cmd, vg_name);
 			return ECMD_FAILED;
diff -rN -p -u old-lvmlib-b/tools/vgremove.c new-lvmlib-b/tools/vgremove.c
--- old-lvmlib-b/tools/vgremove.c	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/tools/vgremove.c	2008-12-15 16:54:40.782812263 +0100
@@ -19,7 +19,7 @@ static int vgremove_single(struct cmd_co
 			   struct volume_group *vg, int consistent,
 			   void *handle __attribute((unused)))
 {
-	if (!vg_remove_single(cmd, vg_name, vg, consistent,
+	if (!vg_remove_single(cmd, vg_name, vg,
 			      arg_count(cmd, force_ARG)))
 		return ECMD_FAILED;
 
diff -rN -p -u old-lvmlib-b/tools/vgrename.c new-lvmlib-b/tools/vgrename.c
--- old-lvmlib-b/tools/vgrename.c	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/tools/vgrename.c	2008-12-15 16:54:40.782812263 +0100
@@ -75,7 +75,7 @@ static int vg_rename_path(struct cmd_con
 		return 0;
 	}
 
-	if (!(vg = vg_read(cmd, vg_name_old, vgid, &consistent)) || !consistent) {
+	if (!(vg = vg_read_internal(cmd, vg_name_old, vgid, &consistent)) || !consistent) {
 		log_error("Volume group %s %s%s%snot found.", vg_name_old,
 		vgid ? "(" : "", vgid ? vgid : "", vgid ? ") " : "");
 		unlock_vg(cmd, vg_name_old);
@@ -107,7 +107,7 @@ static int vg_rename_path(struct cmd_con
 	}
 
 	consistent = 0;
-	if ((vg_new = vg_read(cmd, vg_name_new, NULL, &consistent))) {
+	if ((vg_new = vg_read_internal(cmd, vg_name_new, NULL, &consistent))) {
 		log_error("New volume group \"%s\" already exists",
 			  vg_name_new);
 		goto error;
diff -rN -p -u old-lvmlib-b/tools/vgsplit.c new-lvmlib-b/tools/vgsplit.c
--- old-lvmlib-b/tools/vgsplit.c	2008-12-15 16:54:40.710813517 +0100
+++ new-lvmlib-b/tools/vgsplit.c	2008-12-15 16:54:40.778813291 +0100
@@ -334,7 +334,7 @@ int vgsplit(struct cmd_context *cmd, int
 	}
 
 	consistent = 0;
-	if ((vg_to = vg_read(cmd, vg_name_to, NULL, &consistent))) {
+	if ((vg_to = vg_read_internal(cmd, vg_name_to, NULL, &consistent))) {
 		existing_vg = 1;
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "
@@ -451,7 +451,7 @@ int vgsplit(struct cmd_context *cmd, int
 	 */
 	consistent = 1;
 	if (!test_mode() &&
-	    (!(vg_to = vg_read(cmd, vg_name_to, NULL, &consistent)) ||
+	    (!(vg_to = vg_read_internal(cmd, vg_name_to, NULL, &consistent)) ||
 	     !consistent)) {
 		log_error("Volume group \"%s\" became inconsistent: please "
 			  "fix manually", vg_name_to);

Yours,
   Petr.

PS: This version of the patch actually compiles, but has the abovementioned
bug. The previous failed to compile due to forgotten int vs uint32_t in
vg_check_status definition.

-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

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