public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-10-12 16:41 mornfall
  0 siblings, 0 replies; 41+ messages in thread
From: mornfall @ 2010-10-12 16:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-10-12 16:41:18

Modified files:
	lib/metadata   : metadata-exported.h mirror.c 
	tools          : lvconvert.c 

Log message:
	Make lvconvert respect --yes/--force in the inactive log conversion
	prompt. Fixes BZs 642055, 621281. Patch by Taka.
	
	Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
	Reviewed-by: Petr Rockai <prockai@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.168&r2=1.169
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147

--- LVM2/lib/metadata/metadata-exported.h	2010/09/30 13:05:45	1.168
+++ LVM2/lib/metadata/metadata-exported.h	2010/10/12 16:41:17	1.169
@@ -652,7 +652,7 @@
 struct logical_volume *detach_mirror_log(struct lv_segment *seg);
 int attach_mirror_log(struct lv_segment *seg, struct logical_volume *lv);
 int remove_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
-		      struct dm_list *removable_pvs);
+		      struct dm_list *removable_pvs, int force);
 int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
 		   uint32_t log_count, uint32_t region_size,
 		   struct dm_list *allocatable_pvs, alloc_policy_t alloc);
--- LVM2/lib/metadata/mirror.c	2010/08/17 19:25:05	1.134
+++ LVM2/lib/metadata/mirror.c	2010/10/12 16:41:17	1.135
@@ -1573,7 +1573,8 @@
  */
 int remove_mirror_log(struct cmd_context *cmd,
 		      struct logical_volume *lv,
-		      struct dm_list *removable_pvs)
+		      struct dm_list *removable_pvs,
+		      int force)
 {
 	float sync_percent;
 	percent_range_t percent_range = PERCENT_0;
@@ -1597,7 +1598,7 @@
 		log_error("Unable to convert the log of an inactive "
 			  "cluster mirror, %s", lv->name);
 		return 0;
-	} else if (yes_no_prompt("Full resync required to convert "
+	} else if (force || yes_no_prompt("Full resync required to convert "
 				 "inactive mirror %s to core log. "
 				 "Proceed? [y/n]: ", lv->name) == 'y')
 		sync_percent = 0;
--- LVM2/tools/lvconvert.c	2010/08/17 16:25:35	1.146
+++ LVM2/tools/lvconvert.c	2010/10/12 16:41:18	1.147
@@ -747,7 +747,9 @@
 
 	/* Remove an existing log completely */
 	if (!log_count) {
-		if (!remove_mirror_log(cmd, original_lv, operable_pvs))
+		if (!remove_mirror_log(cmd, original_lv, operable_pvs,
+				       arg_count(cmd, yes_ARG) ||
+				       arg_count(cmd, force_ARG)))
 			return_0;
 		return 1;
 	}


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2011-02-21 12:29 prajnoha
  0 siblings, 0 replies; 41+ messages in thread
From: prajnoha @ 2011-02-21 12:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-02-21 12:29:21

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgconvert.c 

Log message:
	Fix vgconvert code to work with changes in metadata area handling and changes
	in format_instance. Add new 'vg_convert' function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.181&r2=1.182
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.432&r2=1.433
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48

--- LVM2/lib/metadata/metadata-exported.h	2011/02/21 12:27:26	1.181
+++ LVM2/lib/metadata/metadata-exported.h	2011/02/21 12:29:21	1.182
@@ -442,6 +442,9 @@
 int vg_remove(struct volume_group *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
+int vg_convert(struct cmd_context *cmd, struct volume_group *vg,
+	       const struct format_type *target_fmt, int64_t label_sector,
+	       int pvmetadatacopies, uint64_t pvmetadatasize);
 int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
 	      struct pvcreate_params *pp);
 int vg_reduce(struct volume_group *vg, const char *pv_name);
--- LVM2/lib/metadata/metadata.c	2011/02/21 12:26:27	1.432
+++ LVM2/lib/metadata/metadata.c	2011/02/21 12:29:21	1.433
@@ -496,6 +496,109 @@
 	return 1;
 }
 
+int vg_convert(struct cmd_context *cmd, struct volume_group *vg,
+	       const struct format_type *target_fmt, int64_t label_sector,
+	       int pvmetadatacopies, uint64_t pvmetadatasize)
+{
+	struct physical_volume *pv, *existing_pv;
+	struct format_instance_ctx fic;
+	uint64_t pe_start = 0;
+	struct pv_list *pvl;
+	int change_made = 0;
+	const char *vg_name = vg->name;
+
+	/* Replace an old format instance with a new empty one. */
+	vg->fid->fmt->ops->destroy_instance(vg->fid);
+	fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
+	fic.context.vg_ref.vg_name = vg_name;
+	fic.context.vg_ref.vg_id = NULL;
+	if (!(vg->fid = target_fmt->ops->create_instance(target_fmt, &fic))) {
+		log_error("Couldn't create target format instance "
+			  "for VG %s.", vg_name);
+		return 0;
+	}
+
+	/*
+	 * Create new PVs in target format taking original PVs as coimage.
+	 * Write the new PVs out and replace the old PVs in VG structure
+	 * with the new PVs.
+	 */
+	dm_list_iterate_items(pvl, &vg->pvs) {
+		existing_pv = pvl->pv;
+		pe_start = pv_pe_start(existing_pv);
+
+		if (!(pv = pv_create(cmd, pv_dev(existing_pv),
+				     &existing_pv->id,
+				     0, 0, 0, pe_start,
+				     pv_pe_count(existing_pv),
+				     pv_pe_size(existing_pv),
+				     label_sector, pvmetadatacopies,
+				     pvmetadatasize, 0))) {
+			log_error("Failed to setup physical volume \"%s\"",
+				  pv_dev_name(existing_pv));
+			if (change_made)
+				goto revert;
+			return 0;
+		}
+
+		/* Need to revert manually if it fails after this point */
+		change_made = 1;
+
+		log_verbose("Set up physical volume for \"%s\" with %" PRIu64
+			    " available sectors", pv_dev_name(pv), pv_size(pv));
+
+		/* Wipe existing label first */
+		if (!label_remove(pv_dev(pv))) {
+			log_error("Failed to wipe existing label on %s",
+				  pv_dev_name(pv));
+		}
+
+		log_very_verbose("Writing physical volume data to disk \"%s\"",
+				 pv_dev_name(pv));
+		/* FIXME: This pv_write will change the VG assignment for the
+		 *	  PV info in the cache to orphan VG! We should just change
+		 *	  the existing VG format information in the cache or throw
+		 *	  the cache away after this pv_write. */
+		if (!(pv_write(cmd, pv))) {
+			log_error("Failed to write physical volume \"%s\"",
+				  pv_dev_name(pv));
+			goto revert;
+		}
+		log_verbose("Physical volume \"%s\" successfully created",
+			    pv_dev_name(pv));
+
+		if (!vg->fid->fmt->ops->pv_setup(vg->fid->fmt, pv, vg)) {
+			log_error("Failed to setup PV %s in new format for VG %s.",
+				  pv_dev_name(pv), vg_name);
+			goto revert;
+		}
+
+		/* FIXME: Free the mem used by the old PV structure? */
+
+		/* Copy relevant fields from old PV and further initialise new PV. */
+		pv->vg = vg;
+		if (!(pv->vg_name = dm_pool_strdup(vg->vgmem, vg_name))) {
+			log_error("vg->name allocation failed for %s",pv_dev_name(pv));
+			goto revert;
+		}
+		memcpy(&pv->vgid, &vg->id, sizeof(vg->id));
+		if (!alloc_pv_segment_whole_pv(vg->vgmem, pv)) {
+			log_error("pv->segments allocation failed for %s", pv_dev_name(pv));
+			goto revert;
+		}
+
+		pvl->pv = pv;
+	}
+
+
+	return 1;
+
+revert:
+	log_error("Use pvcreate and vgcfgrestore to repair "
+		  "from archived metadata.");
+	return 0;
+}
+
 int remove_lvs_in_vg(struct cmd_context *cmd,
 		     struct volume_group *vg,
 		     force_t force)
--- LVM2/tools/vgconvert.c	2011/02/21 12:26:28	1.47
+++ LVM2/tools/vgconvert.c	2011/02/21 12:29:21	1.48
@@ -19,16 +19,11 @@
 			    struct volume_group *vg,
 			    void *handle __attribute__((unused)))
 {
-	struct physical_volume *pv, *existing_pv;
+	const struct format_type *target_fmt = cmd->fmt;
 	struct logical_volume *lv;
 	struct lv_list *lvl;
-	uint64_t size = 0;
-	struct dm_list mdas;
 	int pvmetadatacopies = 0;
 	uint64_t pvmetadatasize = 0;
-	uint64_t pe_start = 0;
-	struct pv_list *pvl;
-	int change_made = 0;
 	struct lvinfo info;
 	int active = 0;
 
@@ -37,13 +32,13 @@
 		return ECMD_FAILED;
 	}
 
-	if (vg->fid->fmt == cmd->fmt) {
+	if (vg->fid->fmt == target_fmt) {
 		log_error("Volume group \"%s\" already uses format %s",
 			  vg_name, cmd->fmt->name);
 		return ECMD_FAILED;
 	}
 
-	if (cmd->fmt->features & FMT_MDAS) {
+	if (target_fmt->features & FMT_MDAS) {
 		if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
 			log_error("Metadata size may not be negative");
 			return EINVALID_CMD_LINE;
@@ -72,7 +67,7 @@
 
 	/* Set PV/LV limit if converting from unlimited metadata format */
 	if (vg->fid->fmt->features & FMT_UNLIMITED_VOLS &&
-	    !(cmd->fmt->features & FMT_UNLIMITED_VOLS)) {
+	    !(target_fmt->features & FMT_UNLIMITED_VOLS)) {
 		if (!vg->max_lv)
 			vg->max_lv = 255;
 		if (!vg->max_pv)
@@ -81,7 +76,7 @@
 
 	/* If converting to restricted lvid, check if lvid is compatible */
 	if (!(vg->fid->fmt->features & FMT_RESTRICTED_LVIDS) &&
-	    cmd->fmt->features & FMT_RESTRICTED_LVIDS)
+	    target_fmt->features & FMT_RESTRICTED_LVIDS)
 		dm_list_iterate_items(lvl, &vg->lvs)
 			if (!lvid_in_restricted_range(&lvl->lv->lvid)) {
 				log_error("Logical volume %s lvid format is"
@@ -91,7 +86,7 @@
 			}
 
 	/* Attempt to change any LVIDs that are too big */
-	if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) {
+	if (target_fmt->features & FMT_RESTRICTED_LVIDS) {
 		dm_list_iterate_items(lvl, &vg->lvs) {
 			lv = lvl->lv;
 			if (lv->status & SNAPSHOT)
@@ -115,66 +110,18 @@
 		return ECMD_FAILED;
 	}
 
-	dm_list_iterate_items(pvl, &vg->pvs) {
-		existing_pv = pvl->pv;
-
-		pe_start = pv_pe_start(existing_pv);
-		/* pe_end = pv_pe_count(existing_pv) * pv_pe_size(existing_pv) + pe_start - 1; */
-
-		dm_list_init(&mdas);
-		if (!(pv = pv_create(cmd, pv_dev(existing_pv),
-				     &existing_pv->id, size, 0, 0,
-				     pe_start, pv_pe_count(existing_pv),
-				     pv_pe_size(existing_pv),
-				     arg_int64_value(cmd, labelsector_ARG,
-						     DEFAULT_LABELSECTOR),
-				     pvmetadatacopies, pvmetadatasize, 0))) {
-			log_error("Failed to setup physical volume \"%s\"",
-				  pv_dev_name(existing_pv));
-			if (change_made)
-				log_error("Use pvcreate and vgcfgrestore to "
-					  "repair from archived metadata.");
-			return ECMD_FAILED;
-		}
-
-		/* Need to revert manually if it fails after this point */
-		change_made = 1;
-
-		log_verbose("Set up physical volume for \"%s\" with %" PRIu64
-			    " available sectors", pv_dev_name(pv), pv_size(pv));
-
-		/* Wipe existing label first */
-		if (!label_remove(pv_dev(pv))) {
-			log_error("Failed to wipe existing label on %s",
-				  pv_dev_name(pv));
-			log_error("Use pvcreate and vgcfgrestore to repair "
-				  "from archived metadata.");
-			return ECMD_FAILED;
-		}
-
-		log_very_verbose("Writing physical volume data to disk \"%s\"",
-				 pv_dev_name(pv));
-		if (!(pv_write(cmd, pv))) {
-			log_error("Failed to write physical volume \"%s\"",
-				  pv_dev_name(pv));
-			log_error("Use pvcreate and vgcfgrestore to repair "
-				  "from archived metadata.");
-			return ECMD_FAILED;
-		}
-		log_verbose("Physical volume \"%s\" successfully created",
-			    pv_dev_name(pv));
-
-	}
-
 	log_verbose("Deleting existing metadata for VG %s", vg_name);
 	if (!vg_remove_mdas(vg)) {
 		log_error("Removal of existing metadata for %s failed.",
 			  vg_name);
-		log_error("Use pvcreate and vgcfgrestore to repair "
-			  "from archived metadata.");
-		return ECMD_FAILED;
+		goto revert;
 	}
 
+	if (!vg_convert(cmd, vg, target_fmt, arg_int64_value(cmd,
+				labelsector_ARG, DEFAULT_LABELSECTOR),
+			pvmetadatacopies, pvmetadatasize))
+		goto revert;
+
 	/* FIXME Cache the label format change so we don't have to skip this */
 	if (test_mode()) {
 		log_verbose("Test mode: Skipping metadata writing for VG %s in"
@@ -183,18 +130,21 @@
 	}
 
 	log_verbose("Writing metadata for VG %s using format %s", vg_name,
-		    cmd->fmt->name);
-	if (!backup_restore_vg(cmd, vg)) {
+		    target_fmt->name);
+	if (!vg_write(vg) || !vg_commit(vg)) {
 		log_error("Conversion failed for volume group %s.", vg_name);
-		log_error("Use pvcreate and vgcfgrestore to repair from "
-			  "archived metadata.");
-		return ECMD_FAILED;
+		goto revert;
 	}
 	log_print("Volume group %s successfully converted", vg_name);
 
 	backup(vg);
 
 	return ECMD_PROCESSED;
+
+revert:
+	log_error("Use pvcreate and vgcfgrestore to repair "
+		  "from archived metadata.");
+	return ECMD_FAILED;
 }
 
 int vgconvert(struct cmd_context *cmd, int argc, char **argv)


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-06-30 20:03 agk
  0 siblings, 0 replies; 41+ messages in thread
From: agk @ 2010-06-30 20:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-06-30 20:03:53

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : toollib.c vgchange.c vgcreate.c vgsplit.c 

Log message:
	improve vgmetadatacopies unmanaged message

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.163&r2=1.164
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.377&r2=1.378
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.206&r2=1.207
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101

--- LVM2/lib/metadata/metadata-exported.h	2010/06/30 19:28:35	1.163
+++ LVM2/lib/metadata/metadata-exported.h	2010/06/30 20:03:52	1.164
@@ -456,7 +456,7 @@
 	const char *restorefile; /* 0 if no --restorefile option */
 	force_t force;
 	unsigned yes;
-	unsigned mda_ignore;
+	unsigned metadataignore;
 };
 
 struct physical_volume *pvcreate_single(struct cmd_context *cmd,
@@ -889,7 +889,7 @@
 uint32_t vg_mda_count(const struct volume_group *vg);
 uint32_t vg_mda_used_count(const struct volume_group *vg);
 uint32_t vg_mda_copies(const struct volume_group *vg);
-int vg_set_mda_copies(struct volume_group *vg, uint32_t copies);
+int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies);
 int vg_check_write_mode(struct volume_group *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
 #define vg_is_exported(vg) (vg_status((vg)) & EXPORTED_VG)
@@ -905,7 +905,7 @@
 	size_t max_lv;
 	alloc_policy_t alloc;
 	int clustered; /* FIXME: put this into a 'status' variable instead? */
-	uint32_t metadata_copies;
+	uint32_t vgmetadatacopies;
 };
 
 int vgcreate_params_validate(struct cmd_context *cmd,
--- LVM2/lib/metadata/metadata.c	2010/06/30 19:55:43	1.377
+++ LVM2/lib/metadata/metadata.c	2010/06/30 20:03:52	1.378
@@ -1583,7 +1583,7 @@
 	pp->restorefile = 0;
 	pp->force = PROMPT;
 	pp->yes = 0;
-	pp->mda_ignore = DEFAULT_PVMETADATAIGNORE;
+	pp->metadataignore = DEFAULT_PVMETADATAIGNORE;
 }
 
 /*
@@ -1673,7 +1673,7 @@
 	log_very_verbose("Writing physical volume data to disk \"%s\"",
 			 pv_name);
 
-	if (pp->mda_ignore) {
+	if (pp->metadataignore) {
 		dm_list_iterate_items(mda, &mdas) {
 			mda_set_ignored(mda, 1);
 		}
@@ -4247,17 +4247,17 @@
 	return 0;
 }
 
-int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore)
+int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignored)
 {
 	const char *pv_name = pv_dev_name(pv);
 
-	if (mda_ignore && !pv_mda_used_count(pv)) {
+	if (mda_ignored && !pv_mda_used_count(pv)) {
 		log_error("Metadata areas on physical volume \"%s\" already "
 			  "ignored.", pv_name);
 		return 0;
 	}
 
-	if (!mda_ignore && (pv_mda_used_count(pv) == pv_mda_count(pv))) {
+	if (!mda_ignored && (pv_mda_used_count(pv) == pv_mda_count(pv))) {
 		log_error("Metadata areas on physical volume \"%s\" already "
 			  "marked as in-use.", pv_name);
 		return 0;
@@ -4270,9 +4270,9 @@
 	}
 
 	log_verbose("Marking metadata areas on physical volume \"%s\" "
-		    "as %s.", pv_name, mda_ignore ? "ignored" : "in-use");
+		    "as %s.", pv_name, mda_ignored ? "ignored" : "in-use");
 
-	if (!pv_mda_set_ignored(pv, mda_ignore))
+	if (!pv_mda_set_ignored(pv, mda_ignored))
 		return_0;
 
 	/*
--- LVM2/tools/toollib.c	2010/06/30 12:49:29	1.206
+++ LVM2/tools/toollib.c	2010/06/30 20:03:53	1.207
@@ -1187,7 +1187,7 @@
 		vp_def->max_lv = vg->max_lv;
 		vp_def->alloc = vg->alloc;
 		vp_def->clustered = vg_is_clustered(vg);
-		vp_def->metadata_copies = vg->mda_copies;
+		vp_def->vgmetadatacopies = vg->mda_copies;
 	} else {
 		vp_def->vg_name = NULL;
 		vp_def->extent_size = DEFAULT_EXTENT_SIZE * 2;
@@ -1195,7 +1195,7 @@
 		vp_def->max_lv = DEFAULT_MAX_LV;
 		vp_def->alloc = DEFAULT_ALLOC_POLICY;
 		vp_def->clustered = DEFAULT_CLUSTERED;
-		vp_def->metadata_copies = DEFAULT_VGMETADATACOPIES;
+		vp_def->vgmetadatacopies = DEFAULT_VGMETADATACOPIES;
 	}
 }
 
@@ -1244,13 +1244,13 @@
 	}
 
 	if (arg_count(cmd, metadatacopies_ARG)) {
-		vp_new->metadata_copies = arg_int_value(cmd, metadatacopies_ARG,
+		vp_new->vgmetadatacopies = arg_int_value(cmd, metadatacopies_ARG,
 							DEFAULT_VGMETADATACOPIES);
 	} else if (arg_count(cmd, vgmetadatacopies_ARG)) {
-		vp_new->metadata_copies = arg_int_value(cmd, vgmetadatacopies_ARG,
+		vp_new->vgmetadatacopies = arg_int_value(cmd, vgmetadatacopies_ARG,
 							DEFAULT_VGMETADATACOPIES);
 	} else {
-		vp_new->metadata_copies = find_config_tree_int(cmd,
+		vp_new->vgmetadatacopies = find_config_tree_int(cmd,
 						   "metadata/vgmetadatacopies",
 						   DEFAULT_VGMETADATACOPIES);
 	}
@@ -1378,19 +1378,19 @@
 	}
 
 	if (arg_count(cmd, metadataignore_ARG)) {
-		pp->mda_ignore = !strcmp(arg_str_value(cmd,
+		pp->metadataignore = !strcmp(arg_str_value(cmd,
 						metadataignore_ARG,
 						DEFAULT_PVMETADATAIGNORE_STR),
 					 "y");
 	} else {
-		pp->mda_ignore = !strcmp(find_config_tree_str(cmd,
+		pp->metadataignore = !strcmp(find_config_tree_str(cmd,
 					"metadata/pvmetadataignore",
 					DEFAULT_PVMETADATAIGNORE_STR),
 					"y");
 	}
 	if (arg_count(cmd, pvmetadatacopies_ARG) &&
 	    !arg_int_value(cmd, pvmetadatacopies_ARG, -1) &&
-	    pp->mda_ignore) {
+	    pp->metadataignore) {
 		log_error("metadataignore only applies to metadatacopies > 0");
 		return 0;
 	}
--- LVM2/tools/vgchange.c	2010/06/28 21:35:00	1.107
+++ LVM2/tools/vgchange.c	2010/06/30 20:03:53	1.108
@@ -528,17 +528,15 @@
 static int _vgchange_metadata_copies(struct cmd_context *cmd,
 				     struct volume_group *vg)
 {
-	uint32_t mda_copies = DEFAULT_VGMETADATACOPIES;
+	uint32_t mda_copies = arg_uint_value(cmd, vgmetadatacopies_ARG, DEFAULT_VGMETADATACOPIES);
 
-	if (arg_count(cmd, vgmetadatacopies_ARG))
-		mda_copies = arg_uint_value(cmd, vgmetadatacopies_ARG,
-			DEFAULT_VGMETADATACOPIES);
-	else if (arg_count(cmd, metadatacopies_ARG))
-		mda_copies = arg_uint_value(cmd, metadatacopies_ARG,
-			DEFAULT_VGMETADATACOPIES);
 	if (mda_copies == vg_mda_copies(vg)) {
-		log_error("Metadata copies of VG %s is already %u",
-			  vg->name, mda_copies);
+		if (vg_mda_copies(vg) == VGMETADATACOPIES_UNMANAGED)
+			log_error("Number of metadata copies for VG %s is already unmanaged.",
+				  vg->name);
+		else
+			log_error("Number of metadata copies for VG %s is already %" PRIu32,
+				  vg->name, mda_copies);
 		return ECMD_PROCESSED;
 	}
 
--- LVM2/tools/vgcreate.c	2010/06/28 20:38:23	1.79
+++ LVM2/tools/vgcreate.c	2010/06/30 20:03:53	1.80
@@ -64,7 +64,7 @@
 	    !vg_set_max_pv(vg, vp_new.max_pv) ||
 	    !vg_set_alloc_policy(vg, vp_new.alloc) ||
 	    !vg_set_clustered(vg, vp_new.clustered) ||
-	    !vg_set_mda_copies(vg, vp_new.metadata_copies))
+	    !vg_set_mda_copies(vg, vp_new.vgmetadatacopies))
 		goto bad_orphan;
 
 	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
--- LVM2/tools/vgsplit.c	2010/06/28 20:39:24	1.100
+++ LVM2/tools/vgsplit.c	2010/06/30 20:03:53	1.101
@@ -384,7 +384,7 @@
 		    !vg_set_max_pv(vg_to, vp_new.max_pv) ||
 		    !vg_set_alloc_policy(vg_to, vp_new.alloc) ||
 		    !vg_set_clustered(vg_to, vp_new.clustered) ||
-		    !vg_set_mda_copies(vg_to, vp_new.metadata_copies))
+		    !vg_set_mda_copies(vg_to, vp_new.vgmetadatacopies))
 			goto_bad;
 	}
 


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-06-30 18:03 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-06-30 18:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-30 18:03:53

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 
	tools          : vgremove.c 

Log message:
	Refactor vg_remove_check to place pv removal into separate function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.161&r2=1.162
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.374&r2=1.375
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61

--- LVM2/lib/metadata/metadata-exported.h	2010/06/30 12:17:24	1.161
+++ LVM2/lib/metadata/metadata-exported.h	2010/06/30 18:03:52	1.162
@@ -540,6 +540,7 @@
 struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name);
 int vg_remove_mdas(struct volume_group *vg);
 int vg_remove_check(struct volume_group *vg);
+void vg_remove_pvs(struct volume_group *vg);
 int vg_remove(struct volume_group *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
--- LVM2/lib/metadata/metadata.c	2010/06/30 17:13:06	1.374
+++ LVM2/lib/metadata/metadata.c	2010/06/30 18:03:52	1.375
@@ -510,7 +510,6 @@
 int vg_remove_check(struct volume_group *vg)
 {
 	unsigned lv_count;
-	struct pv_list *pvl, *tpvl;
 
 	if (vg_read_error(vg) || vg_missing_pv_count(vg)) {
 		log_error("Volume group \"%s\" not found, is inconsistent "
@@ -534,11 +533,17 @@
 	if (!archive(vg))
 		return 0;
 
+	return 1;
+}
+
+void vg_remove_pvs(struct volume_group *vg)
+{
+	struct pv_list *pvl, *tpvl;
+
 	dm_list_iterate_items_safe(pvl, tpvl, &vg->pvs) {
 		del_pvl_from_vgs(vg, pvl);
 		dm_list_add(&vg->removed_pvs, &pvl->list);
 	}
-	return 1;
 }
 
 int vg_remove(struct volume_group *vg)
--- LVM2/liblvm/lvm_vg.c	2010/04/19 15:22:24	1.40
+++ LVM2/liblvm/lvm_vg.c	2010/06/30 18:03:53	1.41
@@ -180,6 +180,8 @@
 	if (!vg_remove_check(vg))
 		return -1;
 
+	vg_remove_pvs(vg);
+
 	return 0;
 }
 
--- LVM2/tools/vgremove.c	2010/06/30 14:01:40	1.60
+++ LVM2/tools/vgremove.c	2010/06/30 18:03:53	1.61
@@ -54,6 +54,8 @@
 		return ECMD_FAILED;
 	}
 
+	vg_remove_pvs(vg);
+
 	if (!vg_remove(vg)) {
 		stack;
 		return ECMD_FAILED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-06-29 21:32 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-06-29 21:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-29 21:32:44

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : pvchange.c 

Log message:
	Move code into pv_change_metadataignore library function.
	
	In preparation to call this from both pvcreate as well as pvchange,
	move the guts of metadataignore into a library function.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.158&r2=1.159
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.363&r2=1.364
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79

--- LVM2/lib/metadata/metadata-exported.h	2010/06/28 20:40:01	1.158
+++ LVM2/lib/metadata/metadata-exported.h	2010/06/29 21:32:44	1.159
@@ -866,6 +866,7 @@
 uint32_t pv_mda_count(const struct physical_volume *pv);
 uint32_t pv_mda_used_count(const struct physical_volume *pv);
 unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned ignored);
+int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore);
 
 uint64_t lv_size(const struct logical_volume *lv);
 
--- LVM2/lib/metadata/metadata.c	2010/06/28 20:40:01	1.363
+++ LVM2/lib/metadata/metadata.c	2010/06/29 21:32:44	1.364
@@ -4223,6 +4223,50 @@
 	return 0;
 }
 
+int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore)
+{
+	const char *pv_name = pv_dev_name(pv);
+
+	if (mda_ignore && (pv_mda_used_count(pv) == 0)) {
+		log_error("Physical volume \"%s\" metadata already "
+			  "ignored", pv_name);
+		return 0;
+	}
+	if (!mda_ignore && (pv_mda_used_count(pv) == pv_mda_count(pv))) {
+		log_error("Physical volume \"%s\" metadata already "
+			  "not ignored", pv_name);
+		return 0;
+	}
+	if (!pv_mda_count(pv)) {
+		log_error("Physical volume \"%s\" has no metadata "
+			  "areas ", pv_name);
+		return 0;
+	}
+	if (mda_ignore) {
+		log_verbose("Setting physical volume \"%s\" "
+			    "metadata ignored", pv_name);
+	} else {
+		log_verbose("Setting physical volume \"%s\" "
+			    "metadata not ignored", pv_name);
+	}
+	if (!pv_mda_set_ignored(pv, mda_ignore)) {
+		return 0;
+	}
+	/*
+	 * Update vg_mda_copies based on the mdas in this PV.
+	 * This is most likely what the user would expect - if they
+	 * specify a specific PV to be ignored/un-ignored, they will
+	 * most likely not want LVM to turn around and change the
+	 * ignore / un-ignore value when it writes the VG to disk.
+	 * This does not guarantee this PV's ignore bits will be
+	 * preserved in future operations.
+	 */
+	if (!is_orphan(pv) && vg_mda_copies(pv->vg)) {
+		vg_set_mda_copies(pv->vg, vg_mda_used_count(pv->vg));
+	}
+	return 1;
+}
+
 uint32_t vg_seqno(const struct volume_group *vg)
 {
 	return vg->seqno;
--- LVM2/tools/pvchange.c	2010/06/28 20:38:06	1.78
+++ LVM2/tools/pvchange.c	2010/06/29 21:32:44	1.79
@@ -122,42 +122,8 @@
 			}
 		}
 	} else if (arg_count(cmd, metadataignore_ARG)) {
-		if (mda_ignore && (pv_mda_used_count(pv) == 0)) {
-			log_error("Physical volume \"%s\" metadata already "
-				  "ignored", pv_name);
+		if (!pv_change_metadataignore(pv, mda_ignore))
 			goto out;
-		}
-		if (!mda_ignore && (pv_mda_used_count(pv) == pv_mda_count(pv))) {
-			log_error("Physical volume \"%s\" metadata already "
-				  "not ignored", pv_name);
-			goto out;
-		}
-		if (!pv_mda_count(pv)) {
-			log_error("Physical volume \"%s\" has no metadata "
-				  "areas ", pv_name);
-			goto out;
-		}
-		if (mda_ignore) {
-			log_verbose("Setting physical volume \"%s\" "
-				    "metadata ignored", pv_name);
-		} else {
-			log_verbose("Setting physical volume \"%s\" "
-				    "metadata not ignored", pv_name);
-		}
-		if (!pv_mda_set_ignored(pv, mda_ignore)) {
-			goto out;
-		}
-		/*
-		 * Update vg_mda_copies based on the mdas in this PV.
-		 * This is most likely what the user would expect - if they
-		 * specify a specific PV to be ignored/un-ignored, they will
-		 * most likely not want LVM to turn around and change the
-		 * ignore / un-ignore value when it writes the VG to disk.
-		 * This does not guarantee this PV's ignore bits will be
-		 * preserved in future operations.
-		 */
-		if (!is_orphan(pv) && vg_mda_copies(vg))
-			vg_set_mda_copies(vg, vg_mda_used_count(vg));
 	} else {
 		/* --uuid: Change PV ID randomly */
 		if (!id_create(&pv->id)) {


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-06-28 20:40 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-06-28 20:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:40:01

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	lib/report     : report.c 
	tools          : args.h lvmcmdline.c tools.h 

Log message:
	Allow 'all' and 'unmanaged' values for --vgmetadatacopies.
	
	Allowing an 'all' and 'unmanaged' value is more intuitive, and
	provides a simple way for users to get back to original LVM behavior
	of metadata written to all PVs in the volume group.
	
	If the user requests "--vgmetadatacopies unmanaged", this instructs
	LVM not to manage the ignore bits to achieve a specific number of
	metadata copies in the volume group.  The user is free to use
	"pvchange --metadataignore" to control the mdas on a per-PV basis.
	If the user requests "--vgmetadatacopies all", this instructs LVM
	to do 2 things: 1) clear all ignore bits, and 2) set the "unmanaged"
	policy going forward.
	
	Internally, we use the special MAX_UINT32 value to indicate 'all'.
	This 'just' works since it's the largest value possible for the
	field and so all 'ignore' bits on all mdas in the VG will get
	cleared inside _vg_metadata_balance().  However, after we've
	called the _vg_metadata_balance function, we check for the special
	'all' value, and if set, we write the "unmanaged" value into the
	metadata.  As such, the 'all' value is never written to disk.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.157&r2=1.158
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.362&r2=1.363
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.68&r2=1.69

--- LVM2/lib/metadata/metadata-exported.h	2010/06/28 20:36:56	1.157
+++ LVM2/lib/metadata/metadata-exported.h	2010/06/28 20:40:01	1.158
@@ -882,6 +882,8 @@
 uint64_t vg_max_lv(const struct volume_group *vg);
 uint32_t vg_mda_count(const struct volume_group *vg);
 uint32_t vg_mda_used_count(const struct volume_group *vg);
+#define VGMETADATACOPIES_ALL UINT32_MAX
+#define VGMETADATACOPIES_UNMANAGED 0
 uint32_t vg_mda_copies(const struct volume_group *vg);
 int vg_set_mda_copies(struct volume_group *vg, uint32_t value);
 int vg_check_write_mode(struct volume_group *vg);
--- LVM2/lib/metadata/metadata.c	2010/06/28 20:38:56	1.362
+++ LVM2/lib/metadata/metadata.c	2010/06/28 20:40:01	1.363
@@ -1063,7 +1063,7 @@
 	int ret = 1;
 
 	mda_copies = vg_mda_used_count(vg);
-	if (!vg->mda_copies)
+	if (vg->mda_copies == VGMETADATACOPIES_UNMANAGED)
 		goto skip_adjust;
 
 	if (mda_copies > vg->mda_copies) {
@@ -1076,6 +1076,15 @@
 			count = vg->mda_copies - mda_copies;
 		ret = _vg_unignore_mdas(vg, count);
 	}
+	/*
+	 * The VGMETADATACOPIES_ALL value will never be written disk.
+	 * It is a special cmdline value that means 2 things:
+	 * 1. clear all ignore bits in all mdas in this vg
+	 * 2. set the "unmanaged" policy going forward for metadata balancing
+	 */
+	if (vg->mda_copies == VGMETADATACOPIES_ALL)
+		vg->mda_copies = VGMETADATACOPIES_UNMANAGED;
+
 	if (!ret)
 		return ret;
 
--- LVM2/lib/report/report.c	2010/06/28 20:37:23	1.121
+++ LVM2/lib/report/report.c	2010/06/28 20:40:01	1.122
@@ -926,6 +926,11 @@
 
 	count = vg_mda_copies(vg);
 
+	if (count == VGMETADATACOPIES_UNMANAGED) {
+		dm_report_field_set_value(field, "unmanaged", &_minusone64);
+		return 1;
+	}
+
 	return _uint32_disp(rh, mem, field, &count, private);
 }
 
--- LVM2/tools/args.h	2010/06/28 20:37:37	1.76
+++ LVM2/tools/args.h	2010/06/28 20:40:01	1.77
@@ -23,7 +23,7 @@
 arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
 arg(nolocking_ARG, '\0', "nolocking", NULL, 0)
 arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0)
-arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", int_arg, 0)
+arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", vgmetadatacopies_arg, 0)
 arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg, 0)
 arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
 arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0)
--- LVM2/tools/lvmcmdline.c	2010/06/28 20:39:39	1.123
+++ LVM2/tools/lvmcmdline.c	2010/06/28 20:40:01	1.124
@@ -473,6 +473,34 @@
 	return 1;
 }
 
+/*
+ * Non-zero, positive integer, "all", or "unmanaged"
+ */
+int vgmetadatacopies_arg(struct cmd_context *cmd __attribute((unused)),
+			 struct arg *a)
+{
+	if (!strcasecmp(a->value, "all")) {
+		a->ui_value = VGMETADATACOPIES_ALL;
+		return 1;
+	}
+
+	if (!strcasecmp(a->value, "unmanaged")) {
+		a->ui_value = VGMETADATACOPIES_UNMANAGED;
+		return 1;
+	}
+
+	if (!_size_arg(cmd, a, 1))
+		return 0;
+
+	if (a->sign == SIGN_MINUS)
+		return 0;
+
+	if (!a->ui_value)
+		return 0;
+
+	return 1;
+}
+
 static void __alloc(int size)
 {
 	if (!(_cmdline.commands = dm_realloc(_cmdline.commands, sizeof(*_cmdline.commands) * size))) {
--- LVM2/tools/tools.h	2010/06/15 11:00:46	1.68
+++ LVM2/tools/tools.h	2010/06/28 20:40:01	1.69
@@ -152,6 +152,8 @@
 int segtype_arg(struct cmd_context *cmd, struct arg *a);
 int alloc_arg(struct cmd_context *cmd, struct arg *a);
 int readahead_arg(struct cmd_context *cmd, struct arg *a);
+int vgmetadatacopies_arg(struct cmd_context *cmd __attribute((unused)),
+			 struct arg *a);
 
 /* we use the enums to access the switches */
 unsigned arg_count(const struct cmd_context *cmd, int a);


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-02-24 18:15 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-02-24 18:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-02-24 18:15:49

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : lvchange.c 

Log message:
	Refactor lvchange_tag() to call lv_change_tag() library function.
	
	Similar refactoring to vgchange - pull out common parts and put into
	library function for reuse.  Should be no functional change.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.315&r2=1.316
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117

--- LVM2/lib/metadata/metadata-exported.h	2010/02/24 18:15:05	1.132
+++ LVM2/lib/metadata/metadata-exported.h	2010/02/24 18:15:49	1.133
@@ -493,6 +493,8 @@
 int set_lv(struct cmd_context *cmd, struct logical_volume *lv,
            uint64_t sectors, int value);
 
+int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag);
+
 /* Reduce the size of an LV by extents */
 int lv_reduce(struct logical_volume *lv, uint32_t extents);
 
--- LVM2/lib/metadata/metadata.c	2010/02/24 18:15:05	1.315
+++ LVM2/lib/metadata/metadata.c	2010/02/24 18:15:49	1.316
@@ -665,6 +665,30 @@
 	return 0;
 }
 
+int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
+{
+	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
+		log_error("Logical volume %s/%s does not support tags",
+			  lv->vg->name, lv->name);
+		return 0;
+	}
+
+	if (add_tag) {
+		if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
+			log_error("Failed to add tag %s to %s/%s",
+				  tag, lv->vg->name, lv->name);
+			return 0;
+		}
+	} else {
+		if (!str_list_del(&lv->tags, tag)) {
+			log_error("Failed to remove tag %s from %s/%s",
+				  tag, lv->vg->name, lv->name);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
 {
 	if (!(vg->fid->fmt->features & FMT_TAGS)) {
--- LVM2/tools/lvchange.c	2010/01/06 19:08:58	1.116
+++ LVM2/tools/lvchange.c	2010/02/24 18:15:49	1.117
@@ -500,25 +500,8 @@
 		return 0;
 	}
 
-	if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
-		log_error("Logical volume %s/%s does not support tags",
-			  lv->vg->name, lv->name);
-		return 0;
-	}
-
-	if ((arg == addtag_ARG)) {
-		if (!str_list_add(cmd->mem, &lv->tags, tag)) {
-			log_error("Failed to add tag %s to %s/%s",
-				  tag, lv->vg->name, lv->name);
-			return 0;
-		}
-	} else {
-		if (!str_list_del(&lv->tags, tag)) {
-			log_error("Failed to remove tag %s from %s/%s",
-				  tag, lv->vg->name, lv->name);
-			return 0;
-		}
-	}
+	if (!lv_change_tag(lv, tag, arg == addtag_ARG))
+		return_0;
 
 	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
 


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-02-24 18:15 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-02-24 18:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-02-24 18:15:06

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Refactor _vgchange_tag() to vg_change_tag() library function.
	
	Pull out common code to be called from tools as well as lvm2app.
	Leave archive() at tool level so we can use from vgcreate
	as well as vgchange.  Should be no functional change.
	- add stack macro in vgchange
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.131&r2=1.132
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.314&r2=1.315
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/lib/metadata/metadata-exported.h	2010/02/14 03:21:37	1.131
+++ LVM2/lib/metadata/metadata-exported.h	2010/02/24 18:15:05	1.132
@@ -463,6 +463,7 @@
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
 	      struct pvcreate_params *pp);
 int vg_reduce(struct volume_group *vg, char *pv_name);
+int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag);
 int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
 int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
 int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv);
--- LVM2/lib/metadata/metadata.c	2010/02/14 03:21:37	1.314
+++ LVM2/lib/metadata/metadata.c	2010/02/24 18:15:05	1.315
@@ -665,6 +665,29 @@
 	return 0;
 }
 
+int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
+{
+	if (!(vg->fid->fmt->features & FMT_TAGS)) {
+		log_error("Volume group %s does not support tags", vg->name);
+		return 0;
+	}
+
+	if (add_tag) {
+		if (!str_list_add(vg->vgmem, &vg->tags, tag)) {
+			log_error("Failed to add tag %s to volume group %s",
+				  tag, vg->name);
+			return 0;
+		}
+	} else {
+		if (!str_list_del(&vg->tags, tag)) {
+			log_error("Failed to remove tag %s from volume group "
+				  "%s", tag, vg->name);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 const char *strip_dir(const char *vg_name, const char *dev_dir)
 {
 	size_t len = strlen(dev_dir);
--- LVM2/tools/vgchange.c	2010/01/13 01:56:18	1.98
+++ LVM2/tools/vgchange.c	2010/02/24 18:15:06	1.99
@@ -447,28 +447,14 @@
 		return ECMD_FAILED;
 	}
 
-	if (!(vg->fid->fmt->features & FMT_TAGS)) {
-		log_error("Volume group %s does not support tags", vg->name);
-		return ECMD_FAILED;
-	}
-
 	if (!archive(vg)) {
 		stack;
 		return ECMD_FAILED;
 	}
 
-	if ((arg == addtag_ARG)) {
-		if (!str_list_add(cmd->mem, &vg->tags, tag)) {
-			log_error("Failed to add tag %s to volume group %s",
-				  tag, vg->name);
-			return ECMD_FAILED;
-		}
-	} else {
-		if (!str_list_del(&vg->tags, tag)) {
-			log_error("Failed to remove tag %s from volume group "
-				  "%s", tag, vg->name);
-			return ECMD_FAILED;
-		}
+	if (!vg_change_tag(vg, tag, arg == addtag_ARG)) {
+		stack;
+		return ECMD_FAILED;
 	}
 
 	if (!vg_write(vg) || !vg_commit(vg)) {


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-02-14  3:21 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-02-14  3:21 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-02-14 03:21:38

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	lib/report     : columns.h report.c 
	liblvm         : .exported_symbols lvm2app.h lvm_pv.c 

Log message:
	Export lvm_pv_get_size(), lvm_pv_get_free(), lvm_pv_get_dev_size in lvm2app.
	
	We add these exports to show the pv_size and pv_free and dev_size
	fields.
	Fixes rhbz561423.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.130&r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.313&r2=1.314
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/lib/metadata/metadata-exported.h	2010/02/14 03:21:06	1.130
+++ LVM2/lib/metadata/metadata-exported.h	2010/02/14 03:21:37	1.131
@@ -726,6 +726,9 @@
 const char *pv_vg_name(const struct physical_volume *pv);
 const char *pv_dev_name(const struct physical_volume *pv);
 uint64_t pv_size(const struct physical_volume *pv);
+uint64_t pv_size_field(const struct physical_volume *pv);
+uint64_t pv_dev_size(const struct physical_volume *pv);
+uint64_t pv_free(const struct physical_volume *pv);
 uint64_t pv_status(const struct physical_volume *pv);
 uint32_t pv_pe_size(const struct physical_volume *pv);
 uint64_t pv_pe_start(const struct physical_volume *pv);
--- LVM2/lib/metadata/metadata.c	2010/02/03 14:08:40	1.313
+++ LVM2/lib/metadata/metadata.c	2010/02/14 03:21:37	1.314
@@ -3603,6 +3603,38 @@
 	return pv_field(pv, size);
 }
 
+uint64_t pv_dev_size(const struct physical_volume *pv)
+{
+	uint64_t size;
+
+	if (!dev_get_size(pv->dev, &size))
+		size = 0;
+	return size;
+}
+
+uint64_t pv_size_field(const struct physical_volume *pv)
+{
+	uint64_t size;
+
+	if (!pv->pe_count)
+		size = pv->size;
+	else
+		size = (uint64_t) pv->pe_count * pv->pe_size;
+	return size;
+}
+
+uint64_t pv_free(const struct physical_volume *pv)
+{
+	uint64_t freespace;
+
+	if (!pv->pe_count)
+		freespace = pv->size;
+	else
+		freespace = (uint64_t)
+			(pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
+	return freespace;
+}
+
 uint64_t pv_status(const struct physical_volume *pv)
 {
 	return pv_field(pv, status);
--- LVM2/lib/report/columns.h	2009/05/21 03:04:53	1.37
+++ LVM2/lib/report/columns.h	2010/02/14 03:21:38	1.38
@@ -78,7 +78,7 @@
 
 FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.")
 FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.")
-FIELD(LABEL, pv, NUM, "DevSize", dev, 7, devsize, "dev_size", "Size of underlying device in current units.")
+FIELD(LABEL, pv, NUM, "DevSize", id, 7, devsize, "dev_size", "Size of underlying device in current units.")
 FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.")
 FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.")
 FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.")
--- LVM2/lib/report/report.c	2010/01/13 01:55:44	1.111
+++ LVM2/lib/report/report.c	2010/02/14 03:21:38	1.112
@@ -767,10 +767,7 @@
 	    (const struct physical_volume *) data;
 	uint64_t freespace;
 
-	if (!pv->pe_count)
-		freespace = pv->size;
-	else
-		freespace = (uint64_t) (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
+	freespace = pv_free(pv);
 
 	return _size64_disp(rh, mem, field, &freespace, private);
 }
@@ -783,10 +780,7 @@
 	    (const struct physical_volume *) data;
 	uint64_t size;
 
-	if (!pv->pe_count)
-		size = pv->size;
-	else
-		size = (uint64_t) pv->pe_count * pv->pe_size;
+	size = pv_size_field(pv);
 
 	return _size64_disp(rh, mem, field, &size, private);
 }
@@ -795,11 +789,11 @@
 			 struct dm_report_field *field,
 			 const void *data, void *private)
 {
-	const struct device *dev = *(const struct device **) data;
+	const struct physical_volume *pv =
+	    (const struct physical_volume *) data;
 	uint64_t size;
 
-	if (!dev_get_size(dev, &size))
-		size = 0;
+	size = pv_dev_size(pv);
 
 	return _size64_disp(rh, mem, field, &size, private);
 }
--- LVM2/liblvm/.exported_symbols	2009/07/28 13:17:04	1.22
+++ LVM2/liblvm/.exported_symbols	2010/02/14 03:21:38	1.23
@@ -3,6 +3,9 @@
 lvm_quit
 lvm_config_reload
 lvm_config_override
+lvm_pv_get_dev_size
+lvm_pv_get_size
+lvm_pv_get_free
 lvm_pv_get_name
 lvm_pv_get_uuid
 lvm_pv_get_mda_count
--- LVM2/liblvm/lvm2app.h	2009/09/14 19:43:12	1.9
+++ LVM2/liblvm/lvm2app.h	2010/02/14 03:21:38	1.10
@@ -868,6 +868,40 @@
 uint64_t lvm_pv_get_mda_count(const pv_t pv);
 
 /**
+ * Get the current size in bytes of a device underlying a
+ * physical volume.
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * Size in bytes.
+ */
+uint64_t lvm_pv_get_dev_size(const pv_t pv);
+
+/**
+ * Get the current size in bytes of a physical volume.
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * Size in bytes.
+ */
+uint64_t lvm_pv_get_size(const pv_t pv);
+
+/**
+ * Get the current unallocated space in bytes of a physical volume.
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * Free size in bytes.
+ */
+uint64_t lvm_pv_get_free(const pv_t pv);
+
+/**
  * Resize physical volume to new_size bytes.
  *
  * NOTE: This function is currently not implemented.
--- LVM2/liblvm/lvm_pv.c	2009/08/13 12:18:15	1.7
+++ LVM2/liblvm/lvm_pv.c	2010/02/14 03:21:38	1.8
@@ -43,6 +43,21 @@
 	return (uint64_t) pv_mda_count(pv);
 }
 
+uint64_t lvm_pv_get_dev_size(const pv_t pv)
+{
+	return (uint64_t) SECTOR_SIZE*pv_dev_size(pv);
+}
+
+uint64_t lvm_pv_get_size(const pv_t pv)
+{
+	return (uint64_t) SECTOR_SIZE*pv_size_field(pv);
+}
+
+uint64_t lvm_pv_get_free(const pv_t pv)
+{
+	return (uint64_t) SECTOR_SIZE*pv_free(pv);
+}
+
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
 	/* FIXME: add pv resize code here */


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2010-02-14  3:21 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2010-02-14  3:21 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-02-14 03:21:07

Modified files:
	lib/metadata   : metadata-exported.h metadata.h 
	liblvm         : lvm_lv.c lvm_vg.c 

Log message:
	Fix off by 512 sizes for lvm2app.
	
	Internally we store sizes in sectors, but lvm2app exports sizes
	in bytes.  We could get fancier and allow units configuration but
	this fix should do for now.
	
	Fixes rhbz561422.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.129&r2=1.130
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.199&r2=1.200
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35

--- LVM2/lib/metadata/metadata-exported.h	2010/02/03 14:08:40	1.129
+++ LVM2/lib/metadata/metadata-exported.h	2010/02/14 03:21:06	1.130
@@ -25,6 +25,7 @@
 
 #define MAX_STRIPES 128U
 #define SECTOR_SHIFT 9L
+#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
 #define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT)	/* PAGESIZE in sectors */
 #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
--- LVM2/lib/metadata/metadata.h	2009/09/28 17:46:16	1.199
+++ LVM2/lib/metadata/metadata.h	2010/02/14 03:21:06	1.200
@@ -28,7 +28,7 @@
 
 //#define MAX_STRIPES 128U
 //#define SECTOR_SHIFT 9L
-#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
+//#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
 //#define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT)	/* PAGESIZE in sectors */
 //#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 //#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
--- LVM2/liblvm/lvm_lv.c	2009/08/13 12:17:32	1.16
+++ LVM2/liblvm/lvm_lv.c	2010/02/14 03:21:06	1.17
@@ -26,7 +26,7 @@
 /* FIXME: have lib/report/report.c _disp function call lv_size()? */
 uint64_t lvm_lv_get_size(const lv_t lv)
 {
-	return lv_size(lv);
+	return SECTOR_SIZE*lv_size(lv);
 }
 
 char *lvm_lv_get_uuid(const lv_t lv)
@@ -112,7 +112,7 @@
 	if (!vg_check_write_mode(vg))
 		return NULL;
 	memset(&lp, 0, sizeof(lp));
-	extents = extents_from_size(vg->cmd, size, vg->extent_size);
+	extents = extents_from_size(vg->cmd, size/SECTOR_SIZE, vg->extent_size);
 	_lv_set_default_params(&lp, vg, name, extents);
 	_lv_set_default_linear_params(vg->cmd, &lp);
 	if (!lv_create_single(vg, &lp))
--- LVM2/liblvm/lvm_vg.c	2010/02/03 14:08:40	1.34
+++ LVM2/liblvm/lvm_vg.c	2010/02/14 03:21:06	1.35
@@ -86,7 +86,7 @@
 	if (!vg_check_write_mode(vg))
 		return -1;
 
-	if (!vg_set_extent_size(vg, new_size))
+	if (!vg_set_extent_size(vg, new_size/SECTOR_SIZE))
 		return -1;
 	return 0;
 }
@@ -256,17 +256,17 @@
 /* FIXME: invalid handle? return INTMAX? */
 uint64_t lvm_vg_get_size(const vg_t vg)
 {
-	return vg_size(vg);
+	return SECTOR_SIZE*vg_size(vg);
 }
 
 uint64_t lvm_vg_get_free_size(const vg_t vg)
 {
-	return vg_free(vg);
+	return SECTOR_SIZE*vg_free(vg);
 }
 
 uint64_t lvm_vg_get_extent_size(const vg_t vg)
 {
-	return vg_extent_size(vg);
+	return SECTOR_SIZE*vg_extent_size(vg);
 }
 
 uint64_t lvm_vg_get_extent_count(const vg_t vg)


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-11-01 20:05 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-11-01 20:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-11-01 20:05:17

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgcreate.c vgsplit.c 

Log message:
	Rename validate_vg_create_params to vgcreate_params_validate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.120&r2=1.121
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.294&r2=1.295
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/lib/metadata/metadata-exported.h	2009/11/01 19:51:54	1.120
+++ LVM2/lib/metadata/metadata-exported.h	2009/11/01 20:05:17	1.121
@@ -749,8 +749,8 @@
 	int clustered; /* FIXME: put this into a 'status' variable instead? */
 };
 
-int validate_vg_create_params(struct cmd_context *cmd,
-			      struct vgcreate_params *vp);
+int vgcreate_params_validate(struct cmd_context *cmd,
+			     struct vgcreate_params *vp);
 
 int validate_vg_rename_params(struct cmd_context *cmd,
 			      const char *vg_name_old,
--- LVM2/lib/metadata/metadata.c	2009/11/01 19:51:54	1.294
+++ LVM2/lib/metadata/metadata.c	2009/11/01 20:05:17	1.295
@@ -679,8 +679,8 @@
  * FIXME: Move inside vg_create library function.
  * FIXME: Change vgcreate_params struct to individual gets/sets
  */
-int validate_vg_create_params(struct cmd_context *cmd,
-			      struct vgcreate_params *vp)
+int vgcreate_params_validate(struct cmd_context *cmd,
+			     struct vgcreate_params *vp)
 {
 	if (!validate_new_vg_name(cmd, vp->vg_name)) {
 		log_error("New volume group name \"%s\" is invalid",
--- LVM2/tools/vgcreate.c	2009/11/01 20:03:24	1.74
+++ LVM2/tools/vgcreate.c	2009/11/01 20:05:17	1.75
@@ -50,7 +50,7 @@
 	if (vgcreate_params_set_from_args(cmd, &vp_new, &vp_def))
 		return EINVALID_CMD_LINE;
 
-	if (validate_vg_create_params(cmd, &vp_new))
+	if (vgcreate_params_validate(cmd, &vp_new))
 	    return EINVALID_CMD_LINE;
 
 	/* Create the new VG */
--- LVM2/tools/vgsplit.c	2009/11/01 20:03:24	1.98
+++ LVM2/tools/vgsplit.c	2009/11/01 20:05:17	1.99
@@ -373,7 +373,7 @@
 			goto_bad;
 		}
 
-		if (validate_vg_create_params(cmd, &vp_new)) {
+		if (vgcreate_params_validate(cmd, &vp_new)) {
 			r = EINVALID_CMD_LINE;
 			goto_bad;
 		}


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-11-01 19:51 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-11-01 19:51 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-11-01 19:51:55

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 
	tools          : pvcreate.c toollib.c toollib.h vgcreate.c 
	                 vgextend.c 

Log message:
	Rename pvcreate_params processing functions to better match <object><action>.
	
	Rename fill_default_pvcreate_params to pvcreate_params_set_defaults.
	Rename pvcreate_validate_restore_params to pvcreate_restore_params_validate.
	Rename pvcreate_validate_params to pvcreate_params_validate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.119&r2=1.120
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.293&r2=1.294
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.175&r2=1.176
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55

--- LVM2/lib/metadata/metadata-exported.h	2009/10/31 17:30:52	1.119
+++ LVM2/lib/metadata/metadata-exported.h	2009/11/01 19:51:54	1.120
@@ -372,7 +372,7 @@
 struct physical_volume *pvcreate_single(struct cmd_context *cmd,
 					const char *pv_name,
 					struct pvcreate_params *pp);
-void fill_default_pvcreate_params(struct pvcreate_params *pp);
+void pvcreate_params_set_defaults(struct pvcreate_params *pp);
 
 /*
 * Utility functions
--- LVM2/lib/metadata/metadata.c	2009/10/31 17:30:52	1.293
+++ LVM2/lib/metadata/metadata.c	2009/11/01 19:51:54	1.294
@@ -1314,7 +1314,7 @@
 	return 1;
 }
 
-void fill_default_pvcreate_params(struct pvcreate_params *pp)
+void pvcreate_params_set_defaults(struct pvcreate_params *pp)
 {
 	memset(pp, 0, sizeof(*pp));
 	pp->zero = 1;
@@ -1354,7 +1354,7 @@
 	struct pvcreate_params default_pp;
 	char buffer[64] __attribute((aligned(8)));
 
-	fill_default_pvcreate_params(&default_pp);
+	pvcreate_params_set_defaults(&default_pp);
 	if (!pp)
 		pp = &default_pp;
 
--- LVM2/liblvm/lvm_vg.c	2009/10/05 20:03:08	1.32
+++ LVM2/liblvm/lvm_vg.c	2009/11/01 19:51:55	1.33
@@ -54,7 +54,7 @@
 		return -1;
 	}
 
-	fill_default_pvcreate_params(&pp);
+	pvcreate_params_set_defaults(&pp);
 	if (!vg_extend(vg, 1, (char **) &device, &pp)) {
 		unlock_vg(vg->cmd, VG_ORPHANS);
 		return -1;
--- LVM2/tools/pvcreate.c	2009/10/05 20:03:54	1.87
+++ LVM2/tools/pvcreate.c	2009/11/01 19:51:55	1.88
@@ -23,7 +23,7 @@
  * Output arguments:
  * pp: structure allocated by caller, fields written / validated here
  */
-static int pvcreate_validate_restore_params(struct cmd_context *cmd,
+static int pvcreate_restore_params_validate(struct cmd_context *cmd,
 					    int argc, char **argv,
 					    struct pvcreate_params *pp)
 {
@@ -84,12 +84,12 @@
 	int ret = ECMD_PROCESSED;
 	struct pvcreate_params pp;
 
-	fill_default_pvcreate_params(&pp);
+	pvcreate_params_set_defaults(&pp);
 
-	if (!pvcreate_validate_restore_params(cmd, argc, argv, &pp)) {
+	if (!pvcreate_restore_params_validate(cmd, argc, argv, &pp)) {
 		return EINVALID_CMD_LINE;
 	}
-	if (!pvcreate_validate_params(cmd, argc, argv, &pp)) {
+	if (!pvcreate_params_validate(cmd, argc, argv, &pp)) {
 		return EINVALID_CMD_LINE;
 	}
 
--- LVM2/tools/toollib.c	2009/10/06 16:00:38	1.175
+++ LVM2/tools/toollib.c	2009/11/01 19:51:55	1.176
@@ -1278,7 +1278,7 @@
  * Output arguments:
  * pp: structure allocated by caller, fields written / validated here
  */
-int pvcreate_validate_params(struct cmd_context *cmd,
+int pvcreate_params_validate(struct cmd_context *cmd,
 			     int argc, char **argv,
 			     struct pvcreate_params *pp)
 {
--- LVM2/tools/toollib.h	2009/10/05 20:03:55	1.65
+++ LVM2/tools/toollib.h	2009/11/01 19:51:55	1.66
@@ -107,7 +107,7 @@
 int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
 void lv_spawn_background_polling(struct cmd_context *cmd,
 				 struct logical_volume *lv);
-int pvcreate_validate_params(struct cmd_context *cmd,
+int pvcreate_params_validate(struct cmd_context *cmd,
 			     int argc, char **argv,
 			     struct pvcreate_params *pp);
 
--- LVM2/tools/vgcreate.c	2009/10/31 17:39:22	1.71
+++ LVM2/tools/vgcreate.c	2009/11/01 19:51:55	1.72
@@ -40,8 +40,8 @@
 			  "use --pvmetadatacopies instead.");
 		return EINVALID_CMD_LINE;
 	}
-	fill_default_pvcreate_params(&pp);
-	if (!pvcreate_validate_params(cmd, argc, argv, &pp)) {
+	pvcreate_params_set_defaults(&pp);
+	if (!pvcreate_params_validate(cmd, argc, argv, &pp)) {
 		return EINVALID_CMD_LINE;
 	}
 
--- LVM2/tools/vgextend.c	2009/10/05 20:55:57	1.54
+++ LVM2/tools/vgextend.c	2009/11/01 19:51:55	1.55
@@ -37,8 +37,8 @@
 			  "use --pvmetadatacopies instead.");
 		return EINVALID_CMD_LINE;
 	}
-	fill_default_pvcreate_params(&pp);
-	if (!pvcreate_validate_params(cmd, argc, argv, &pp)) {
+	pvcreate_params_set_defaults(&pp);
+	if (!pvcreate_params_validate(cmd, argc, argv, &pp)) {
 		return EINVALID_CMD_LINE;
 	}
 


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-10-31 17:30 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-10-31 17:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-31 17:30:52

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Add vg_set_clustered() - move logic from vgchange.
	
	Similar to other vg_set_* functions, we create a vg_set_clustered() function
	which does a few checks and sets a flag.  This is where we check for
	any limitations of clusters.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.118&r2=1.119
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.292&r2=1.293
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89

--- LVM2/lib/metadata/metadata-exported.h	2009/10/31 17:26:13	1.118
+++ LVM2/lib/metadata/metadata-exported.h	2009/10/31 17:30:52	1.119
@@ -462,6 +462,7 @@
 int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
 int vg_set_max_pv(struct volume_group *vg, uint32_t max_pv);
 int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc);
+int vg_set_clustered(struct volume_group *vg, int clustered);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
--- LVM2/lib/metadata/metadata.c	2009/10/31 17:26:13	1.292
+++ LVM2/lib/metadata/metadata.c	2009/10/31 17:30:52	1.293
@@ -1127,6 +1127,26 @@
 	return 1;
 }
 
+int vg_set_clustered(struct volume_group *vg, int clustered)
+{
+	struct lv_list *lvl;
+	if (clustered) {
+		dm_list_iterate_items(lvl, &vg->lvs) {
+			if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
+				log_error("Volume group %s contains snapshots "
+					  "that are not yet supported.",
+					  vg->name);
+				return 0;
+			}
+		}
+	}
+
+	if (clustered)
+		vg->status |= CLUSTERED;
+	else
+		vg->status &= ~CLUSTERED;
+	return 1;
+}
 
 /*
  * Separate metadata areas after splitting a VG.
--- LVM2/tools/vgchange.c	2009/09/30 12:05:25	1.88
+++ LVM2/tools/vgchange.c	2009/10/31 17:30:52	1.89
@@ -245,7 +245,6 @@
 			       struct volume_group *vg)
 {
 	int clustered = !strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y");
-	struct lv_list *lvl;
 
 	if (clustered && (vg_is_clustered(vg))) {
 		log_error("Volume group \"%s\" is already clustered",
@@ -259,26 +258,13 @@
 		return ECMD_FAILED;
 	}
 
-	if (clustered) {
-		dm_list_iterate_items(lvl, &vg->lvs) {
-			if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
-				log_error("Volume group %s contains snapshots "
-					  "that are not yet supported.",
-					  vg->name);
-				return ECMD_FAILED;
-			}
-		}
-	}
-
 	if (!archive(vg)) {
 		stack;
 		return ECMD_FAILED;
 	}
 
-	if (clustered)
-		vg->status |= CLUSTERED;
-	else
-		vg->status &= ~CLUSTERED;
+	if (!vg_set_clustered(vg, clustered))
+		return ECMD_FAILED;
 
 	if (!vg_write(vg) || !vg_commit(vg)) {
 		stack;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-10-05 20:03 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-10-05 20:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-05 20:03:08

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 

Log message:
	Allow calling fill_default_pvcreate_params from tools.
	
	We need defaults for pvcreate_params at a higher level - this will
	allow us to use a common function from the tools to take defaults,
	then fill in any non-defaults from the commandline.
	
	Future patches will refactor vgcreate/vgextend to call this function
	if one or more pvcreate parameters are given on the commandline.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.115&r2=1.116
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.287&r2=1.288
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32

--- LVM2/lib/metadata/metadata-exported.h	2009/10/05 20:02:48	1.115
+++ LVM2/lib/metadata/metadata-exported.h	2009/10/05 20:03:08	1.116
@@ -371,6 +371,7 @@
 struct physical_volume *pvcreate_single(struct cmd_context *cmd,
 					const char *pv_name,
 					struct pvcreate_params *pp);
+void fill_default_pvcreate_params(struct pvcreate_params *pp);
 
 /*
 * Utility functions
--- LVM2/lib/metadata/metadata.c	2009/10/05 20:02:48	1.287
+++ LVM2/lib/metadata/metadata.c	2009/10/05 20:03:08	1.288
@@ -1272,7 +1272,7 @@
 	return 1;
 }
 
-static void fill_default_pvcreate_params(struct pvcreate_params *pp)
+void fill_default_pvcreate_params(struct pvcreate_params *pp)
 {
 	memset(pp, 0, sizeof(*pp));
 	pp->zero = 0;
--- LVM2/liblvm/lvm_vg.c	2009/10/05 20:02:48	1.31
+++ LVM2/liblvm/lvm_vg.c	2009/10/05 20:03:08	1.32
@@ -41,6 +41,8 @@
 
 int lvm_vg_extend(vg_t vg, const char *device)
 {
+	struct pvcreate_params pp;
+
 	if (vg_read_error(vg))
 		return -1;
 
@@ -52,15 +54,8 @@
 		return -1;
 	}
 
-	/* If device not initialized, pvcreate it */
-	if (!pv_by_path(vg->cmd, device) &&
-	   (!pvcreate_single(vg->cmd, device, NULL))) {
-		log_error("Unable to initialize device for LVM use");
-		unlock_vg(vg->cmd, VG_ORPHANS);
-		return -1;
-	}
-
-	if (!vg_extend(vg, 1, (char **) &device, NULL)) {
+	fill_default_pvcreate_params(&pp);
+	if (!vg_extend(vg, 1, (char **) &device, &pp)) {
 		unlock_vg(vg->cmd, VG_ORPHANS);
 		return -1;
 	}


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-10-05 20:02 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-10-05 20:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-10-05 20:02:49

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 
	tools          : vgcreate.c vgextend.c 

Log message:
	Add pvcreate_params to vg_extend.
	
	Another refactoring for implicit pvcreate support.  We need to get
	the pvcreate parameters somehow to the vg_extend routine.  Options
	seemed to be:
	1. Attach the parameters to struct volume_group.  I personally
	did not like this idea in most cases, though one could make an
	agrument why it might be ok at least for some of the parameters
	(e.g. metadatacopies).
	2. Pass them in to the extend routine.  This second route seemed
	to be the best approach given the constraints.
	
	Future patches will parse the command line and fill in the actual
	values for the pvcreate_single call.
	Should be no functional change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.286&r2=1.287
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51

--- LVM2/lib/metadata/metadata-exported.h	2009/10/01 01:04:27	1.114
+++ LVM2/lib/metadata/metadata-exported.h	2009/10/05 20:02:48	1.115
@@ -453,7 +453,8 @@
 int vg_remove(struct volume_group *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
-int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
+int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
+	      struct pvcreate_params *pp);
 int vg_reduce(struct volume_group *vg, char *pv_name);
 int vg_set_extent_size(struct volume_group *vg, uint32_t new_extent_size);
 int vg_set_max_lv(struct volume_group *vg, uint32_t max_lv);
--- LVM2/lib/metadata/metadata.c	2009/10/05 20:02:30	1.286
+++ LVM2/lib/metadata/metadata.c	2009/10/05 20:02:48	1.287
@@ -582,7 +582,18 @@
 	return 1;
 }
 
-int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
+/*
+ * Extend a VG by a single PV / device path
+ *
+ * Parameters:
+ * - vg: handle of volume group to extend by 'pv_name'
+ * - pv_count: count of device paths of PVs
+ * - pv_names: device paths of PVs to add to VG
+ * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
+ *
+ */
+int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
+	      struct pvcreate_params *pp)
 {
 	int i;
 
@@ -591,7 +602,7 @@
 
 	/* attach each pv */
 	for (i = 0; i < pv_count; i++) {
-		if (!vg_extend_single_pv(vg, pv_names[i], NULL))
+		if (!vg_extend_single_pv(vg, pv_names[i], pp))
 			goto bad;
 	}
 
--- LVM2/liblvm/lvm_vg.c	2009/09/14 19:43:12	1.30
+++ LVM2/liblvm/lvm_vg.c	2009/10/05 20:02:48	1.31
@@ -60,7 +60,7 @@
 		return -1;
 	}
 
-	if (!vg_extend(vg, 1, (char **) &device)) {
+	if (!vg_extend(vg, 1, (char **) &device, NULL)) {
 		unlock_vg(vg->cmd, VG_ORPHANS);
 		return -1;
 	}
--- LVM2/tools/vgcreate.c	2009/09/14 22:47:50	1.66
+++ LVM2/tools/vgcreate.c	2009/10/05 20:02:48	1.67
@@ -63,7 +63,7 @@
 	}
 
 	/* attach the pv's */
-	if (!vg_extend(vg, argc - 1, argv + 1))
+	if (!vg_extend(vg, argc - 1, argv + 1, NULL))
 		goto_bad;
 
 	if (vp_new.max_lv != vg->max_lv)
--- LVM2/tools/vgextend.c	2009/09/14 22:47:50	1.50
+++ LVM2/tools/vgextend.c	2009/10/05 20:02:49	1.51
@@ -54,7 +54,7 @@
 		goto_bad;
 
 	/* extend vg */
-	if (!vg_extend(vg, argc, argv))
+	if (!vg_extend(vg, argc, argv, NULL))
 		goto_bad;
 
 	/* ret > 0 */


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-10-01  1:04 agk
  0 siblings, 0 replies; 41+ messages in thread
From: agk @ 2009-10-01  1:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-10-01 01:04:27

Modified files:
	lib/metadata   : metadata-exported.h mirror.c 
	lib/report     : report.c 
	tools          : polldaemon.c 

Log message:
	Add percent_range to copy_percent too.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.113&r2=1.114
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28

--- LVM2/lib/metadata/metadata-exported.h	2009/10/01 00:35:29	1.113
+++ LVM2/lib/metadata/metadata-exported.h	2009/10/01 01:04:27	1.114
@@ -691,7 +691,8 @@
 						  uint32_t lv_type);
 const char *get_pvmove_pvname_from_lv(struct logical_volume *lv);
 const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr);
-float copy_percent(struct logical_volume *lv_mirr);
+float copy_percent(struct logical_volume *lv_mirr,
+		   percent_range_t *percent_range);
 struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
 			  struct logical_volume *lv);
 
--- LVM2/lib/metadata/mirror.c	2009/10/01 00:35:29	1.90
+++ LVM2/lib/metadata/mirror.c	2009/10/01 01:04:27	1.91
@@ -1114,7 +1114,8 @@
 	return lvs;
 }
 
-float copy_percent(struct logical_volume *lv_mirr)
+float copy_percent(struct logical_volume *lv_mirr,
+		   percent_range_t *percent_range)
 {
 	uint32_t numerator = 0u, denominator = 0u;
 	struct lv_segment *seg;
@@ -1128,6 +1129,13 @@
 			numerator += seg->area_len;
 	}
 
+	if (!denominator || (numerator == denominator))
+		*percent_range = PERCENT_100;
+	else if (numerator == 0)
+		*percent_range = PERCENT_0;
+	else
+		*percent_range = PERCENT_0_TO_100;
+		
 	return denominator ? (float) numerator *100 / denominator : 100.0;
 }
 
--- LVM2/lib/report/report.c	2009/10/01 00:35:30	1.103
+++ LVM2/lib/report/report.c	2009/10/01 01:04:27	1.104
@@ -1054,7 +1054,8 @@
 	return 1;
 }
 
-static int _copypercent_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
+static int _copypercent_disp(struct dm_report *rh __attribute((unused)),
+			     struct dm_pool *mem,
 			     struct dm_report_field *field,
 			     const void *data, void *private __attribute((unused)))
 {
@@ -1077,7 +1078,7 @@
 		return 1;
 	}
 
-	percent = copy_percent(lv);
+	percent = copy_percent(lv, &percent_range);
 
 	if (!(repstr = dm_pool_zalloc(mem, 8))) {
 		log_error("dm_pool_alloc failed");
--- LVM2/tools/polldaemon.c	2009/10/01 00:35:30	1.27
+++ LVM2/tools/polldaemon.c	2009/10/01 01:04:27	1.28
@@ -68,7 +68,7 @@
 				struct daemon_parms *parms)
 {
 	float segment_percent = 0.0, overall_percent = 0.0;
-	percent_range_t percent_range;
+	percent_range_t percent_range, overall_percent_range;
 	uint32_t event_nr = 0;
 
 	if (!lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
@@ -78,7 +78,7 @@
 		return PROGRESS_CHECK_FAILED;
 	}
 
-	overall_percent = copy_percent(lv);
+	overall_percent = copy_percent(lv, &overall_percent_range);
 	if (parms->progress_display)
 		log_print("%s: %s: %.1f%%", name, parms->progress_title,
 			  overall_percent);
@@ -89,7 +89,7 @@
 	if (percent_range != PERCENT_100)
 		return PROGRESS_UNFINISHED;
 
-	if (overall_percent >= 100.0)
+	if (overall_percent_range == PERCENT_100)
 		return PROGRESS_FINISHED_ALL;
 
 	return PROGRESS_FINISHED_SEGMENT;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-09-14 15:45 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-09-14 15:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-14 15:45:24

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm2app.h lvm_vg.c 

Log message:
	Add max_pv and max_lv vg 'get' lvm2app exports.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.109&r2=1.110
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.282&r2=1.283
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29

--- LVM2/lib/metadata/metadata-exported.h	2009/09/02 21:39:29	1.109
+++ LVM2/lib/metadata/metadata-exported.h	2009/09/14 15:45:23	1.110
@@ -717,6 +717,8 @@
 uint64_t vg_extent_count(const struct volume_group *vg);
 uint64_t vg_free_count(const struct volume_group *vg);
 uint64_t vg_pv_count(const struct volume_group *vg);
+uint64_t vg_max_pv(const struct volume_group *vg);
+uint64_t vg_max_lv(const struct volume_group *vg);
 int vg_check_write_mode(struct volume_group *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
 
--- LVM2/lib/metadata/metadata.c	2009/09/02 21:39:49	1.282
+++ LVM2/lib/metadata/metadata.c	2009/09/14 15:45:23	1.283
@@ -3525,6 +3525,16 @@
 	return (uint64_t) vg->pv_count;
 }
 
+uint64_t vg_max_pv(const struct volume_group *vg)
+{
+	return (uint64_t) vg->max_pv;
+}
+
+uint64_t vg_max_lv(const struct volume_group *vg)
+{
+	return (uint64_t) vg->max_lv;
+}
+
 uint64_t lv_size(const struct logical_volume *lv)
 {
 	return lv->size;
--- LVM2/liblvm/lvm2app.h	2009/09/02 21:40:10	1.7
+++ LVM2/liblvm/lvm2app.h	2009/09/14 15:45:23	1.8
@@ -589,6 +589,28 @@
  */
 uint64_t lvm_vg_get_pv_count(const vg_t vg);
 
+/**
+ * Get the maximum number of physical volumes allowed in a volume group.
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Maximum number of physical volumes allowed in a volume group.
+ */
+uint64_t lvm_vg_get_max_pv(const vg_t vg);
+
+/**
+ * Get the maximum number of logical volumes allowed in a volume group.
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Maximum number of logical volumes allowed in a volume group.
+ */
+uint64_t lvm_vg_get_max_lv(const vg_t vg);
+
 /************************** logical volume handling *************************/
 
 /**
--- LVM2/liblvm/lvm_vg.c	2009/09/02 21:40:10	1.28
+++ LVM2/liblvm/lvm_vg.c	2009/09/14 15:45:23	1.29
@@ -274,6 +274,16 @@
 	return vg_pv_count(vg);
 }
 
+uint64_t lvm_vg_get_max_pv(const vg_t vg)
+{
+	return vg_max_pv(vg);
+}
+
+uint64_t lvm_vg_get_max_lv(const vg_t vg)
+{
+	return vg_max_lv(vg);
+}
+
 char *lvm_vg_get_uuid(const vg_t vg)
 {
 	char uuid[64] __attribute((aligned(8)));


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-09-02 21:39 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-09-02 21:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:39:07

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgconvert.c 

Log message:
	Rename internal library function vg_remove to vg_remove_mdas.
	
	Later patches should consolidate the vgremove / vgreduce functions but for
	now let's clarify what vg_remove actually does by changing the name.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.279&r2=1.280
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38

--- LVM2/lib/metadata/metadata-exported.h	2009/07/30 17:45:29	1.107
+++ LVM2/lib/metadata/metadata-exported.h	2009/09/02 21:39:07	1.108
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -441,7 +441,7 @@
 uint32_t pv_list_extents_free(const struct dm_list *pvh);
 
 struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name);
-int vg_remove(struct volume_group *vg);
+int vg_remove_mdas(struct volume_group *vg);
 int vg_remove_single(struct volume_group *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
--- LVM2/lib/metadata/metadata.c	2009/08/20 07:03:02	1.279
+++ LVM2/lib/metadata/metadata.c	2009/09/02 21:39:07	1.280
@@ -502,8 +502,8 @@
 		return 0;
 	}
 
-	if (!vg_remove(vg)) {
-		log_error("vg_remove %s failed", vg->name);
+	if (!vg_remove_mdas(vg)) {
+		log_error("vg_remove_mdas %s failed", vg->name);
 		unlock_vg(vg->cmd, VG_ORPHANS);
 		return 0;
 	}
@@ -1676,7 +1676,7 @@
 	return NULL;
 }
 
-int vg_remove(struct volume_group *vg)
+int vg_remove_mdas(struct volume_group *vg)
 {
 	struct metadata_area *mda;
 
--- LVM2/tools/vgconvert.c	2009/07/30 17:45:30	1.37
+++ LVM2/tools/vgconvert.c	2009/09/02 21:39:07	1.38
@@ -167,7 +167,7 @@
 	}
 
 	log_verbose("Deleting existing metadata for VG %s", vg_name);
-	if (!vg_remove(vg)) {
+	if (!vg_remove_mdas(vg)) {
 		log_error("Removal of existing metadata for %s failed.",
 			  vg_name);
 		log_error("Use pvcreate and vgcfgrestore to repair "


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-09-02 21:39 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-09-02 21:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:39:29

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_vg.c 
	tools          : vgremove.c 

Log message:
	Split vg_remove_single into 2 functions - the second part commits to disk.
	
	Split vg_remove_single into vg_remove_check (mandatory checks before
	vgremove) and vg_remove (do actual remove by committing to disk).
	
	In liblvm, we'd like to provide an consistent API that allows multiple
	changes in memory, then let lvm_vg_write() control the commit to disk.  In
	some cases (for example, lvresize calls fsadm) this may not be possible.
	However, since we are using an object model and dividing things into small
	operations, the most logical model seems to be the lvm_vg_write model, and
	handling the special cases as they arrive.  So as best as possible
	we move towards this end.
	
	A possible optimization would be to consolidate vg_remove (committing)
	code with vgreduce code.  A second possible optimization is making vgreduce
	of the last device equivalent to vgremove.  Today, lvm_vg_reduce fails if
	vgreduce is called with the last device, but from an object model perspective
	we could view this as equivalent to vgremove and allow it.  My gut feel is
	we do not want to do this though.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.108&r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.280&r2=1.281
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55

--- LVM2/lib/metadata/metadata-exported.h	2009/09/02 21:39:07	1.108
+++ LVM2/lib/metadata/metadata-exported.h	2009/09/02 21:39:29	1.109
@@ -442,7 +442,8 @@
 
 struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name);
 int vg_remove_mdas(struct volume_group *vg);
-int vg_remove_single(struct volume_group *vg);
+int vg_remove_check(struct volume_group *vg);
+int vg_remove(struct volume_group *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
--- LVM2/lib/metadata/metadata.c	2009/09/02 21:39:07	1.280
+++ LVM2/lib/metadata/metadata.c	2009/09/02 21:39:29	1.281
@@ -468,12 +468,9 @@
 	return 1;
 }
 
-int vg_remove_single(struct volume_group *vg)
+int vg_remove_check(struct volume_group *vg)
 {
-	struct physical_volume *pv;
-	struct pv_list *pvl;
 	unsigned lv_count;
-	int ret = 1;
 
 	if (vg_read_error(vg) || vg_missing_pv_count(vg)) {
 		log_error("Volume group \"%s\" not found, is inconsistent "
@@ -497,6 +494,15 @@
 	if (!archive(vg))
 		return 0;
 
+	return 1;
+}
+
+int vg_remove(struct volume_group *vg)
+{
+	struct physical_volume *pv;
+	struct pv_list *pvl;
+	int ret = 1;
+
 	if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
 		log_error("Can't get lock for orphan PVs");
 		return 0;
--- LVM2/liblvm/lvm_vg.c	2009/08/13 12:16:45	1.26
+++ LVM2/liblvm/lvm_vg.c	2009/09/02 21:39:29	1.27
@@ -153,7 +153,10 @@
 	if (!vg_check_write_mode(vg))
 		return -1;
 
-	if (!vg_remove_single(vg))
+	if (!vg_remove_check(vg))
+		return -1;
+
+	if (!vg_remove(vg))
 		return -1;
 	return 0;
 }
--- LVM2/tools/vgremove.c	2009/07/14 19:37:18	1.54
+++ LVM2/tools/vgremove.c	2009/09/02 21:39:29	1.55
@@ -44,7 +44,10 @@
 			return ECMD_FAILED;
 	}
 
-	if (!vg_remove_single(vg))
+	if (!vg_remove_check(vg))
+		return ECMD_FAILED;
+
+	if (!vg_remove(vg))
 		return ECMD_FAILED;
 
 	return ECMD_PROCESSED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-28 15:14 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-28 15:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-28 15:14:57

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : lvm_lv.c lvm_vg.c 

Log message:
	Add an open_mode to the vg struct for liblvm - enforce read / write semantics.
	
	For now, a simple way to enforce the read/write semantics is to just save the
	open mode of the VG.  If the caller uses lvm_vg_create, the mode is write.
	The caller using lvm_vg_open can use either read or write to open the VG.
	Once we have this, we enforce the permissions on each API call and don't allow
	a caller to modify a VG that has not been opened properly.
	
	This may be better combined with the locking mode, but I view that as future
	cleanup, past this initial release.  The intial release should enforce the
	basic object semantics though, as described in the lvm.h file.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.104&r2=1.105
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.271&r2=1.272
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23

--- LVM2/lib/metadata/metadata-exported.h	2009/07/28 13:17:04	1.104
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/28 15:14:56	1.105
@@ -247,6 +247,7 @@
 	 * They have to get cleared on vg_commit.
 	 */
 	struct dm_list removed_pvs;
+	uint32_t open_mode; /* FIXME: read or write - check lock type? */
 
 	/*
 	 * Store result of the last vg_read().
@@ -713,6 +714,7 @@
 uint64_t vg_extent_count(const vg_t *vg);
 uint64_t vg_free_count(const vg_t *vg);
 uint64_t vg_pv_count(const vg_t *vg);
+int vg_check_write_mode(vg_t *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
 
 struct vgcreate_params {
--- LVM2/lib/metadata/metadata.c	2009/07/28 13:17:04	1.271
+++ LVM2/lib/metadata/metadata.c	2009/07/28 15:14:56	1.272
@@ -3042,6 +3042,16 @@
 	return 1;
 }
 
+/* FIXME: remove / combine this with locking? */
+int vg_check_write_mode(vg_t *vg)
+{
+	if (vg->open_mode != 'w') {
+		log_errno(EPERM, "Attempt to modify a read-only VG\n");
+		return 0;
+	}
+	return 1;
+}
+
 /*
  * Performs a set of checks against a VG according to bits set in status
  * and returns FAILED_* bits for those that aren't acceptable.
--- LVM2/liblvm/lvm_lv.c	2009/07/28 13:16:40	1.11
+++ LVM2/liblvm/lvm_lv.c	2009/07/28 15:14:56	1.12
@@ -107,9 +107,10 @@
 	uint64_t extents;
 	struct lv_list *lvl;
 
-	/* FIXME: check for proper VG access */
 	if (vg_read_error(vg))
 		return NULL;
+	if (!vg_check_write_mode(vg))
+		return NULL;
 	memset(&lp, 0, sizeof(lp));
 	extents = extents_from_size(vg->cmd, size, vg->extent_size);
 	_lv_set_default_params(&lp, vg, name, extents);
@@ -130,6 +131,8 @@
 {
 	if (!lv || !lv->vg || vg_read_error(lv->vg))
 		return -1;
+	if (!vg_check_write_mode(lv->vg))
+		return -1;
 	if (!lv_remove_single(lv->vg->cmd, lv, DONT_PROMPT))
 		return -1;
 	return 0;
--- LVM2/liblvm/lvm_vg.c	2009/07/28 13:17:04	1.22
+++ LVM2/liblvm/lvm_vg.c	2009/07/28 15:14:56	1.23
@@ -35,6 +35,7 @@
 		vg_release(vg);
 		return NULL;
 	}
+	vg->open_mode = 'w';
 	return vg;
 }
 
@@ -43,6 +44,9 @@
 	if (vg_read_error(vg))
 		return -1;
 
+	if (!vg_check_write_mode(vg))
+		return -1;
+
 	if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
 		log_error("Can't get lock for orphan PVs");
 		return -1;
@@ -72,6 +76,8 @@
 {
 	if (vg_read_error(vg))
 		return -1;
+	if (!vg_check_write_mode(vg))
+		return -1;
 
 	if (!vg_reduce(vg, (char *)device))
 		return -1;
@@ -82,6 +88,8 @@
 {
 	if (vg_read_error(vg))
 		return -1;
+	if (!vg_check_write_mode(vg))
+		return -1;
 
 	if (!vg_set_extent_size(vg, new_size))
 		return -1;
@@ -94,6 +102,8 @@
 
 	if (vg_read_error(vg))
 		return -1;
+	if (!vg_check_write_mode(vg))
+		return -1;
 
 	if (dm_list_empty(&vg->pvs)) {
 		log_error("Volume group %s does not contain any "
@@ -140,6 +150,8 @@
 {
 	if (vg_read_error(vg))
 		return -1;
+	if (!vg_check_write_mode(vg))
+		return -1;
 
 	if (!vg_remove_single(vg))
 		return -1;
@@ -165,6 +177,8 @@
 		vg_release(vg);
 		return NULL;
 	}
+	/* FIXME: combine this with locking ? */
+	vg->open_mode = mode[0];
 
 	return vg;
 }


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-28 13:17 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-28 13:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-28 13:17:04

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	liblvm         : .exported_symbols lvm.h lvm_vg.c 
	test/api       : test.c 

Log message:
	Add lvm_vg_get_seqno, updating lvm.h and unit test.
	
	Adding the ability to get the seqno is important for an application to
	determine if something has changed in a VG.  Otherwise, the only way to
	know is to open the VG with write permission and hold the handle.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.270&r2=1.271
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/test.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21

--- LVM2/lib/metadata/metadata-exported.h	2009/07/27 17:43:40	1.103
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/28 13:17:04	1.104
@@ -705,6 +705,7 @@
 uint64_t lv_size(const lv_t *lv);
 
 int vg_missing_pv_count(const vg_t *vg);
+uint32_t vg_seqno(const vg_t *vg);
 uint32_t vg_status(const vg_t *vg);
 uint64_t vg_size(const vg_t *vg);
 uint64_t vg_free(const vg_t *vg);
--- LVM2/lib/metadata/metadata.c	2009/07/27 17:43:40	1.270
+++ LVM2/lib/metadata/metadata.c	2009/07/28 13:17:04	1.271
@@ -3424,6 +3424,11 @@
 	return info ? dm_list_size(&info->mdas) : UINT64_C(0);
 }
 
+uint32_t vg_seqno(const vg_t *vg)
+{
+	return vg->seqno;
+}
+
 uint32_t vg_status(const vg_t *vg)
 {
 	return vg->status;
--- LVM2/liblvm/.exported_symbols	2009/07/28 11:03:28	1.21
+++ LVM2/liblvm/.exported_symbols	2009/07/28 13:17:04	1.22
@@ -6,6 +6,7 @@
 lvm_pv_get_name
 lvm_pv_get_uuid
 lvm_pv_get_mda_count
+lvm_vg_get_seqno
 lvm_vg_get_name
 lvm_vg_get_uuid
 lvm_vg_get_size
--- LVM2/liblvm/lvm.h	2009/07/28 13:16:40	1.39
+++ LVM2/liblvm/lvm.h	2009/07/28 13:17:04	1.40
@@ -49,6 +49,17 @@
  * A volume group handle may be obtained with read or write permission.
  * Any attempt to change a property of a pv_t, vg_t, or lv_t without
  * obtaining write permission on the vg_t will fail with EPERM.
+ *
+ * An application first opening a VG read-only, then later wanting to change
+ * a property of an object must first close the VG and re-open with write
+ * permission. Currently liblvm provides no mechanism to determine whether
+ * the VG has changed on-disk in between these operations - this is the
+ * application's responsiblity. One way the application can ensure the VG
+ * has not changed is to save the "vg_seqno" field after opening the VG with
+ * READ permission. If the application later needs to modify the VG, it can
+ * close the VG and re-open with WRITE permission. It should then check
+ * whether the original "vg_seqno" obtained with READ permission matches
+ * the new one obtained with WRITE permission.
  */
 
 /**
@@ -470,6 +481,21 @@
 int lvm_vg_set_extent_size(vg_t *vg, uint32_t new_size);
 
 /**
+ * Get the current metadata sequence number of a volume group.
+ *
+ * The metadata sequence number is incrented for each metadata change.
+ * Applications may use the sequence number to determine if any LVM objects
+ * have changed from a prior query.
+ *
+ * \param   vg
+ * VG handle obtained from lvm_vg_create or lvm_vg_open.
+ *
+ * \return
+ * Metadata sequence number.
+ */
+uint64_t lvm_vg_get_seqno(const vg_t *vg);
+
+/**
  * Get the current name of a volume group.
  *
  * Memory is allocated using dm_malloc() and caller must free the memory
--- LVM2/liblvm/lvm_vg.c	2009/07/28 09:56:48	1.21
+++ LVM2/liblvm/lvm_vg.c	2009/07/28 13:17:04	1.22
@@ -223,6 +223,11 @@
 	return list;
 }
 
+uint64_t lvm_vg_get_seqno(const vg_t *vg)
+{
+	return vg_seqno(vg);
+}
+
 /* FIXME: invalid handle? return INTMAX? */
 uint64_t lvm_vg_get_size(const vg_t *vg)
 {
--- LVM2/test/api/test.c	2009/07/28 11:03:29	1.20
+++ LVM2/test/api/test.c	2009/07/28 13:17:04	1.21
@@ -345,10 +345,11 @@
 
 static void _show_one_vg(vg_t *vg)
 {
-	printf("%s (%s): size=%"PRIu64", free=%"PRIu64", #pv=%"PRIu64"\n",
+	printf("%s (%s): sz=%"PRIu64", free=%"PRIu64", #pv=%"PRIu64
+		", seq#=%"PRIu64"\n",
 		lvm_vg_get_name(vg), lvm_vg_get_uuid(vg),
 		lvm_vg_get_size(vg), lvm_vg_get_free_size(vg),
-		lvm_vg_get_pv_count(vg));
+		lvm_vg_get_pv_count(vg), lvm_vg_get_seqno(vg));
 }
 
 static void _list_open_vgs(void)


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-26  2:34 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-26  2:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:34:09

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : lvcreate.c 

Log message:
	Move extents_from_size from lvcreate into internal library so we can reuse.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.266&r2=1.267
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.206&r2=1.207

--- LVM2/lib/metadata/metadata-exported.h	2009/07/26 02:33:35	1.100
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/26 02:34:09	1.101
@@ -495,6 +495,9 @@
 int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
 	      const char *new_name);
 
+uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
+			   uint32_t extent_size);
+
 /* FIXME: refactor and reduce the size of this struct! */
 struct lvcreate_params {
 	/* flags */
--- LVM2/lib/metadata/metadata.c	2009/07/26 02:02:22	1.266
+++ LVM2/lib/metadata/metadata.c	2009/07/26 02:34:09	1.267
@@ -680,6 +680,28 @@
 	return NULL;
 }
 
+uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
+			   uint32_t extent_size)
+{
+	if (size % extent_size) {
+		size += extent_size - size % extent_size;
+		log_print("Rounding up size to full physical extent %s",
+			  display_size(cmd, size));
+	}
+
+	if (size > (uint64_t) UINT32_MAX * extent_size) {
+		log_error("Volume too large (%s) for extent size %s. "
+			  "Upper limit is %s.",
+			  display_size(cmd, size),
+			  display_size(cmd, (uint64_t) extent_size),
+			  display_size(cmd, (uint64_t) UINT32_MAX *
+				       extent_size));
+		return 0;
+	}
+
+	return (uint64_t) size / extent_size;
+}
+
 static int _recalc_extents(uint32_t *extents, const char *desc1,
 			   const char *desc2, uint32_t old_size,
 			   uint32_t new_size)
--- LVM2/tools/lvcreate.c	2009/07/26 02:33:35	1.206
+++ LVM2/tools/lvcreate.c	2009/07/26 02:34:09	1.207
@@ -25,9 +25,6 @@
 	int pv_count;
 };
 
-static uint64_t _extents_from_size(struct cmd_context *cmd, uint64_t size,
-				   uint32_t extent_size);
-
 static int _lvcreate_name_params(struct lvcreate_params *lp,
 				 struct cmd_context *cmd,
 				 int *pargc, char ***pargv)
@@ -136,12 +133,12 @@
 	uint32_t pv_extent_count;
 
 	if (lcp->size &&
-	    !(lp->extents = _extents_from_size(vg->cmd, lcp->size,
+	    !(lp->extents = extents_from_size(vg->cmd, lcp->size,
 					       vg->extent_size)))
 		return_0;
 
 	if (lp->voriginsize &&
-	    !(lp->voriginextents = _extents_from_size(vg->cmd, lp->voriginsize,
+	    !(lp->voriginextents = extents_from_size(vg->cmd, lp->voriginsize,
 						      vg->extent_size)))
 		return_0;
 
@@ -573,28 +570,6 @@
 	return 1;
 }
 
-static uint64_t _extents_from_size(struct cmd_context *cmd, uint64_t size,
-				   uint32_t extent_size)
-{
-	if (size % extent_size) {
-		size += extent_size - size % extent_size;
-		log_print("Rounding up size to full physical extent %s",
-			  display_size(cmd, size));
-	}
-
-	if (size > (uint64_t) UINT32_MAX * extent_size) {
-		log_error("Volume too large (%s) for extent size %s. "
-			  "Upper limit is %s.",
-			  display_size(cmd, size),
-			  display_size(cmd, (uint64_t) extent_size),
-			  display_size(cmd, (uint64_t) UINT32_MAX *
-				       extent_size));
-		return 0;
-	}
-
-	return (uint64_t) size / extent_size;
-}
-
 int lvcreate(struct cmd_context *cmd, int argc, char **argv)
 {
 	int r = ECMD_PROCESSED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-26  1:53 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-26  1:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 01:53:09

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : pvcreate.c 

Log message:
	Move bulk of pvcreate logic into library.
	
	In preparation for implicit pvcreate during vgcreate / vgextend,
	move bulk of pvcreate logic inside library.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.96&r2=1.97
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.261&r2=1.262
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82

--- LVM2/lib/metadata/metadata-exported.h	2009/07/15 17:26:26	1.96
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/26 01:53:09	1.97
@@ -337,6 +337,25 @@
 	struct logical_volume *lv;
 };
 
+struct pvcreate_params {
+	int zero;
+	uint64_t size;
+	uint64_t data_alignment;
+	int pvmetadatacopies;
+	uint64_t pvmetadatasize;
+	int64_t labelsector;
+	struct id id; /* FIXME: redundant */
+	struct id *idp; /* 0 if no --uuid option */
+	uint64_t pe_start;
+	uint32_t extent_count;
+	uint32_t extent_size;
+	const char *restorefile; /* 0 if no --restorefile option */
+	force_t force;
+	unsigned yes;
+};
+
+int pvcreate_single(struct cmd_context *cmd, const char *pv_name, void *handle);
+
 /*
 * Utility functions
 */
--- LVM2/lib/metadata/metadata.c	2009/07/26 01:52:19	1.261
+++ LVM2/lib/metadata/metadata.c	2009/07/26 01:53:09	1.262
@@ -28,6 +28,7 @@
 #include "locking.h"
 #include "archiver.h"
 #include "defaults.h"
+#include "filter-persistent.h"
 
 #include <sys/param.h>
 
@@ -63,6 +64,9 @@
 static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
 				    uint32_t status);
 
+const char _really_init[] =
+    "Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
+
 unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignment)
 {
 	if (pv->pe_align)
@@ -954,6 +958,222 @@
 	return 1;
 }
 
+/*
+ * See if we may pvcreate on this device.
+ * 0 indicates we may not.
+ */
+static int pvcreate_check(struct cmd_context *cmd, const char *name,
+			  struct pvcreate_params *pp)
+{
+	struct physical_volume *pv;
+	struct device *dev;
+	uint64_t md_superblock, swap_signature;
+	int wipe_md, wipe_swap;
+
+	/* FIXME Check partition type is LVM unless --force is given */
+
+	/* Is there a pv here already? */
+	pv = pv_read(cmd, name, NULL, NULL, 0, 0);
+
+	/*
+	 * If a PV has no MDAs it may appear to be an orphan until the
+	 * metadata is read off another PV in the same VG.  Detecting
+	 * this means checking every VG by scanning every PV on the
+	 * system.
+	 */
+	if (pv && is_orphan(pv)) {
+		if (!scan_vgs_for_pvs(cmd))
+			return_0;
+		pv = pv_read(cmd, name, NULL, NULL, 0, 0);
+	}
+
+	/* Allow partial & exported VGs to be destroyed. */
+	/* We must have -ff to overwrite a non orphan */
+	if (pv && !is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) {
+		log_error("Can't initialize physical volume \"%s\" of "
+			  "volume group \"%s\" without -ff", name, pv_vg_name(pv));
+		return 0;
+	}
+
+	/* prompt */
+	if (pv && !is_orphan(pv) && !pp->yes &&
+	    yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') {
+		log_print("%s: physical volume not initialized", name);
+		return 0;
+	}
+
+	if (sigint_caught())
+		return 0;
+
+	dev = dev_cache_get(name, cmd->filter);
+
+	/* Is there an md superblock here? */
+	if (!dev && md_filtering()) {
+		unlock_vg(cmd, VG_ORPHANS);
+
+		persistent_filter_wipe(cmd->filter);
+		lvmcache_destroy(cmd, 1);
+
+		init_md_filtering(0);
+		if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+			log_error("Can't get lock for orphan PVs");
+			init_md_filtering(1);
+			return 0;
+		}
+		dev = dev_cache_get(name, cmd->filter);
+		init_md_filtering(1);
+	}
+
+	if (!dev) {
+		log_error("Device %s not found (or ignored by filtering).", name);
+		return 0;
+	}
+
+	/*
+	 * This test will fail if the device belongs to an MD array.
+	 */
+	if (!dev_test_excl(dev)) {
+		/* FIXME Detect whether device-mapper itself is still using it */
+		log_error("Can't open %s exclusively.  Mounted filesystem?",
+			  name);
+		return 0;
+	}
+
+	/* Wipe superblock? */
+	if ((wipe_md = dev_is_md(dev, &md_superblock)) == 1 &&
+	    ((!pp->idp && !pp->restorefile) || pp->yes ||
+	     (yes_no_prompt("Software RAID md superblock "
+			    "detected on %s. Wipe it? [y/n] ", name) == 'y'))) {
+		log_print("Wiping software RAID md superblock on %s", name);
+		if (!dev_set(dev, md_superblock, 4, 0)) {
+			log_error("Failed to wipe RAID md superblock on %s",
+				  name);
+			return 0;
+		}
+	}
+
+	if (wipe_md == -1) {
+		log_error("Fatal error while trying to detect software "
+			  "RAID md superblock on %s", name);
+		return 0;
+	}
+
+	if ((wipe_swap = dev_is_swap(dev, &swap_signature)) == 1 &&
+	    ((!pp->idp && !pp->restorefile) || pp->yes ||
+	     (yes_no_prompt("Swap signature detected on %s. Wipe it? [y/n] ",
+			    name) == 'y'))) {
+		log_print("Wiping swap signature on %s", name);
+		if (!dev_set(dev, swap_signature, 10, 0)) {
+			log_error("Failed to wipe swap signature on %s", name);
+			return 0;
+		}
+	}
+
+	if (wipe_swap == -1) {
+		log_error("Fatal error while trying to detect swap "
+			  "signature on %s", name);
+		return 0;
+	}
+
+	if (sigint_caught())
+		return 0;
+
+	if (pv && !is_orphan(pv) && pp->force) {
+		log_warn("WARNING: Forcing physical volume creation on "
+			  "%s%s%s%s", name,
+			  !is_orphan(pv) ? " of volume group \"" : "",
+			  !is_orphan(pv) ? pv_vg_name(pv) : "",
+			  !is_orphan(pv) ? "\"" : "");
+	}
+
+	return 1;
+}
+
+int pvcreate_single(struct cmd_context *cmd, const char *pv_name, void *handle)
+{
+	struct pvcreate_params *pp = (struct pvcreate_params *) handle;
+	void *pv;
+	struct device *dev;
+	struct dm_list mdas;
+
+	if (pp->idp) {
+		if ((dev = device_from_pvid(cmd, pp->idp)) &&
+		    (dev != dev_cache_get(pv_name, cmd->filter))) {
+			log_error("uuid %s already in use on \"%s\"",
+				  pp->idp->uuid, dev_name(dev));
+			return 0;
+		}
+	}
+
+	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+		log_error("Can't get lock for orphan PVs");
+		return 0;
+	}
+
+	if (!pvcreate_check(cmd, pv_name, pp))
+		goto error;
+
+	if (sigint_caught())
+		goto error;
+
+	if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
+		log_error("%s: Couldn't find device.  Check your filters?",
+			  pv_name);
+		goto error;
+	}
+
+	dm_list_init(&mdas);
+	if (!(pv = pv_create(cmd, dev, pp->idp, pp->size,
+			     pp->data_alignment, pp->pe_start,
+			     pp->extent_count, pp->extent_size,
+			     pp->pvmetadatacopies,
+			     pp->pvmetadatasize,&mdas))) {
+		log_error("Failed to setup physical volume \"%s\"", pv_name);
+		goto error;
+	}
+
+	log_verbose("Set up physical volume for \"%s\" with %" PRIu64
+		    " available sectors", pv_name, pv_size(pv));
+
+	/* Wipe existing label first */
+	if (!label_remove(pv_dev(pv))) {
+		log_error("Failed to wipe existing label on %s", pv_name);
+		goto error;
+	}
+
+	if (pp->zero) {
+		log_verbose("Zeroing start of device %s", pv_name);
+		if (!dev_open_quiet(dev)) {
+			log_error("%s not opened: device not zeroed", pv_name);
+			goto error;
+		}
+
+		if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
+			log_error("%s not wiped: aborting", pv_name);
+			dev_close(dev);
+			goto error;
+		}
+		dev_close(dev);
+	}
+
+	log_very_verbose("Writing physical volume data to disk \"%s\"",
+			 pv_name);
+	if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas,
+		       pp->labelsector))) {
+		log_error("Failed to write physical volume \"%s\"", pv_name);
+		goto error;
+	}
+
+	log_print("Physical volume \"%s\" successfully created", pv_name);
+
+	unlock_vg(cmd, VG_ORPHANS);
+	return 1;
+
+      error:
+	unlock_vg(cmd, VG_ORPHANS);
+	return 0;
+}
+
 static void _free_pv(struct dm_pool *mem, struct physical_volume *pv)
 {
 	dm_pool_free(mem, pv);
--- LVM2/tools/pvcreate.c	2009/04/10 10:01:38	1.81
+++ LVM2/tools/pvcreate.c	2009/07/26 01:53:09	1.82
@@ -14,244 +14,7 @@
  */
 
 #include "tools.h"
-#include "metadata.h"
-
-struct pvcreate_params {
-	int zero;
-	uint64_t size;
-	uint64_t data_alignment;
-	int pvmetadatacopies;
-	uint64_t pvmetadatasize;
-	int64_t labelsector;
-	struct id id; /* FIXME: redundant */
-	struct id *idp; /* 0 if no --uuid option */
-	uint64_t pe_start;
-	uint32_t extent_count;
-	uint32_t extent_size;
-	const char *restorefile; /* 0 if no --restorefile option */
-	force_t force;
-	unsigned yes;
-};
-
-const char _really_init[] =
-    "Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
-
-/*
- * See if we may pvcreate on this device.
- * 0 indicates we may not.
- */
-static int pvcreate_check(struct cmd_context *cmd, const char *name,
-			  struct pvcreate_params *pp)
-{
-	struct physical_volume *pv;
-	struct device *dev;
-	uint64_t md_superblock, swap_signature;
-	int wipe_md, wipe_swap;
-
-	/* FIXME Check partition type is LVM unless --force is given */
-
-	/* Is there a pv here already? */
-	pv = pv_read(cmd, name, NULL, NULL, 0, 0);
-
-	/*
-	 * If a PV has no MDAs it may appear to be an orphan until the
-	 * metadata is read off another PV in the same VG.  Detecting
-	 * this means checking every VG by scanning every PV on the
-	 * system.
-	 */
-	if (pv && is_orphan(pv)) {
-		if (!scan_vgs_for_pvs(cmd))
-			return_0;
-		pv = pv_read(cmd, name, NULL, NULL, 0, 0);
-	}
-
-	/* Allow partial & exported VGs to be destroyed. */
-	/* We must have -ff to overwrite a non orphan */
-	if (pv && !is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) {
-		log_error("Can't initialize physical volume \"%s\" of "
-			  "volume group \"%s\" without -ff", name, pv_vg_name(pv));
-		return 0;
-	}
-
-	/* prompt */
-	if (pv && !is_orphan(pv) && !pp->yes &&
-	    yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') {
-		log_print("%s: physical volume not initialized", name);
-		return 0;
-	}
-
-	if (sigint_caught())
-		return 0;
-
-	dev = dev_cache_get(name, cmd->filter);
-
-	/* Is there an md superblock here? */
-	if (!dev && md_filtering()) {
-		unlock_vg(cmd, VG_ORPHANS);
-
-		persistent_filter_wipe(cmd->filter);
-		lvmcache_destroy(cmd, 1);
-
-		init_md_filtering(0);
-		if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
-			log_error("Can't get lock for orphan PVs");
-			init_md_filtering(1);
-			return 0;
-		}
-		dev = dev_cache_get(name, cmd->filter);
-		init_md_filtering(1);
-	}
-
-	if (!dev) {
-		log_error("Device %s not found (or ignored by filtering).", name);
-		return 0;
-	}
-
-	/*
- 	 * This test will fail if the device belongs to an MD array.
-	 */
-	if (!dev_test_excl(dev)) {
-		/* FIXME Detect whether device-mapper itself is still using it */
-		log_error("Can't open %s exclusively.  Mounted filesystem?",
-			  name);
-		return 0;
-	}
-
-	/* Wipe superblock? */
-	if ((wipe_md = dev_is_md(dev, &md_superblock)) == 1 &&
-	    ((!pp->idp && !pp->restorefile) || pp->yes ||
-	     (yes_no_prompt("Software RAID md superblock "
-			    "detected on %s. Wipe it? [y/n] ", name) == 'y'))) {
-		log_print("Wiping software RAID md superblock on %s", name);
-		if (!dev_set(dev, md_superblock, 4, 0)) {
-			log_error("Failed to wipe RAID md superblock on %s",
-				  name);
-			return 0;
-		}
-	}
-
-	if (wipe_md == -1) {
-		log_error("Fatal error while trying to detect software "
-			  "RAID md superblock on %s", name);
-		return 0;
-	}
-
-	if ((wipe_swap = dev_is_swap(dev, &swap_signature)) == 1 &&
-	    ((!pp->idp && !pp->restorefile) || pp->yes ||
-	     (yes_no_prompt("Swap signature detected on %s. Wipe it? [y/n] ",
-			    name) == 'y'))) {
-		log_print("Wiping swap signature on %s", name);
-		if (!dev_set(dev, swap_signature, 10, 0)) {
-			log_error("Failed to wipe swap signature on %s", name);
-			return 0;
-		}
-	}
-
-	if (wipe_swap == -1) {
-		log_error("Fatal error while trying to detect swap "
-			  "signature on %s", name);
-		return 0;
-	}
-
-	if (sigint_caught())
-		return 0;
-
-	if (pv && !is_orphan(pv) && pp->force) {
-		log_warn("WARNING: Forcing physical volume creation on "
-			  "%s%s%s%s", name,
-			  !is_orphan(pv) ? " of volume group \"" : "",
-			  !is_orphan(pv) ? pv_vg_name(pv) : "",
-			  !is_orphan(pv) ? "\"" : "");
-	}
-
-	return 1;
-}
-
-static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
-			   void *handle)
-{
-	struct pvcreate_params *pp = (struct pvcreate_params *) handle;
-	void *pv;
-	struct device *dev;
-	struct dm_list mdas;
-
-	if (pp->idp) {
-		if ((dev = device_from_pvid(cmd, pp->idp)) &&
-		    (dev != dev_cache_get(pv_name, cmd->filter))) {
-			log_error("uuid %s already in use on \"%s\"",
-				  pp->idp->uuid, dev_name(dev));
-			return 0;
-		}
-	}
-
-	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
-		log_error("Can't get lock for orphan PVs");
-		return 0;
-	}
-
-	if (!pvcreate_check(cmd, pv_name, pp))
-		goto error;
-
-	if (sigint_caught())
-		goto error;
-
-	if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
-		log_error("%s: Couldn't find device.  Check your filters?",
-			  pv_name);
-		goto error;
-	}
-
-	dm_list_init(&mdas);
-	if (!(pv = pv_create(cmd, dev, pp->idp, pp->size,
-			     pp->data_alignment, pp->pe_start,
-			     pp->extent_count, pp->extent_size,
-			     pp->pvmetadatacopies,
-			     pp->pvmetadatasize,&mdas))) {
-		log_error("Failed to setup physical volume \"%s\"", pv_name);
-		goto error;
-	}
-
-	log_verbose("Set up physical volume for \"%s\" with %" PRIu64
-		    " available sectors", pv_name, pv_size(pv));
-
-	/* Wipe existing label first */
-	if (!label_remove(pv_dev(pv))) {
-		log_error("Failed to wipe existing label on %s", pv_name);
-		goto error;
-	}
-
-	if (pp->zero) {
-		log_verbose("Zeroing start of device %s", pv_name);
-		if (!dev_open_quiet(dev)) {
-			log_error("%s not opened: device not zeroed", pv_name);
-			goto error;
-		}
-
-		if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) {
-			log_error("%s not wiped: aborting", pv_name);
-			dev_close(dev);
-			goto error;
-		}
-		dev_close(dev);
-	}
-
-	log_very_verbose("Writing physical volume data to disk \"%s\"",
-			 pv_name);
-	if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas,
-		       pp->labelsector))) {
-		log_error("Failed to write physical volume \"%s\"", pv_name);
-		goto error;
-	}
-
-	log_print("Physical volume \"%s\" successfully created", pv_name);
-
-	unlock_vg(cmd, VG_ORPHANS);
-	return 1;
-
-      error:
-	unlock_vg(cmd, VG_ORPHANS);
-	return 0;
-}
+#include "metadata-exported.h"
 
 /*
  * Intial sanity checking of command-line arguments and fill in 'pp' fields.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-15  5:50 mornfall
  0 siblings, 0 replies; 41+ messages in thread
From: mornfall @ 2009-07-15  5:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-07-15 05:50:22

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : pvdisplay.c pvresize.c reporter.c toollib.c 
	                 vgreduce.c 

Log message:
	Port process_each_pv to new vg_read.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.252&r2=1.253
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96

--- LVM2/lib/metadata/metadata-exported.h	2009/07/14 03:00:30	1.93
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/15 05:50:22	1.94
@@ -95,6 +95,7 @@
 /* vg_read and vg_read_for_update flags */
 #define READ_ALLOW_INCONSISTENT	0x00010000U
 #define READ_ALLOW_EXPORTED	0x00020000U
+#define READ_WITHOUT_LOCK       0x00040000U
 
 /* A meta-flag, useful with toollib for_each_* functions. */
 #define READ_FOR_UPDATE 	0x00100000U
--- LVM2/lib/metadata/metadata.c	2009/07/15 05:49:48	1.252
+++ LVM2/lib/metadata/metadata.c	2009/07/15 05:50:22	1.253
@@ -2897,7 +2897,8 @@
 	lock_name = is_orphan_vg(vg_name) ? VG_ORPHANS : vg_name;
 	already_locked = vgname_is_locked(lock_name);
 
-	if (!already_locked && !lock_vol(cmd, lock_name, lock_flags)) {
+	if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
+	    !lock_vol(cmd, lock_name, lock_flags)) {
 		log_error("Can't get lock for %s", vg_name);
 		return _vg_make_handle(cmd, vg, FAILED_LOCKING);
 	}
@@ -2953,7 +2954,7 @@
 	return _vg_make_handle(cmd, vg, failure);
 
 bad:
-	if (!already_locked)
+	if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK))
 		unlock_vg(cmd, lock_name);
 
 	return _vg_make_handle(cmd, vg, failure);
--- LVM2/tools/pvdisplay.c	2009/07/01 16:59:37	1.52
+++ LVM2/tools/pvdisplay.c	2009/07/15 05:50:22	1.53
@@ -113,6 +113,6 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	return process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ, 0, NULL,
+	return process_each_pv(cmd, argc, argv, NULL, 0, 0, NULL,
 			       _pvdisplay_single);
 }
--- LVM2/tools/pvresize.c	2009/07/07 01:18:35	1.31
+++ LVM2/tools/pvresize.c	2009/07/15 05:50:22	1.32
@@ -205,7 +205,7 @@
 	params.done = 0;
 	params.total = 0;
 
-	ret = process_each_pv(cmd, argc, argv, NULL, LCK_VG_WRITE, 0, &params,
+	ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, 0, &params,
 			      _pvresize_single);
 
 	log_print("%d physical volume(s) resized / %d physical volume(s) "
--- LVM2/tools/reporter.c	2009/07/01 17:00:52	1.53
+++ LVM2/tools/reporter.c	2009/07/15 05:50:22	1.54
@@ -378,12 +378,12 @@
 				    report_handle, &_vgs_single);
 		break;
 	case LABEL:
-		r = process_each_pv(cmd, argc, argv, NULL, LCK_NONE,
+		r = process_each_pv(cmd, argc, argv, NULL, READ_WITHOUT_LOCK,
 				    1, report_handle, &_label_single);
 		break;
 	case PVS:
 		if (args_are_pvs)
-			r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
+			r = process_each_pv(cmd, argc, argv, NULL, 0,
 					    0, report_handle, &_pvs_single);
 		else
 			r = process_each_vg(cmd, argc, argv, 0,
@@ -395,7 +395,7 @@
 		break;
 	case PVSEGS:
 		if (args_are_pvs)
-			r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
+			r = process_each_pv(cmd, argc, argv, NULL, 0,
 					    0, report_handle, &_pvsegs_single);
 		else
 			r = process_each_vg(cmd, argc, argv, 0,
--- LVM2/tools/toollib.c	2009/07/15 05:23:19	1.161
+++ LVM2/tools/toollib.c	2009/07/15 05:50:22	1.162
@@ -615,7 +615,7 @@
  * This can pause alongide pvscan or vgscan process for a while.
  */
 int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
-		    struct volume_group *vg, uint32_t lock_type,
+		    struct volume_group *vg, uint32_t flags,
 		    int scan_label_only, void *handle,
 		    int (*process_single) (struct cmd_context * cmd,
 					   struct volume_group * vg,
@@ -625,7 +625,7 @@
 	int opt = 0;
 	int ret_max = ECMD_PROCESSED;
 	int ret = 0;
-	int lock_global = lock_type == LCK_VG_READ;
+	int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE);
 
 	struct pv_list *pvl;
 	struct physical_volume *pv;
@@ -633,12 +633,11 @@
 	struct dm_list tags;
 	struct str_list *sll;
 	char *tagname;
-	int consistent = 1;
 	int scanned = 0;
 
 	dm_list_init(&tags);
 
-	if (lock_global && !lock_vol(cmd, VG_GLOBAL, lock_type)) {
+	if (lock_global && !lock_vol(cmd, VG_GLOBAL, LCK_READ)) {
 		log_error("Unable to obtain global lock.");
 		return ECMD_FAILED;
 	}
@@ -719,26 +718,11 @@
 		if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 0)) &&
 			   !dm_list_empty(vgnames)) {
 			dm_list_iterate_items(sll, vgnames) {
-				if (!lock_vol(cmd, sll->str, lock_type)) {
-					log_error("Can't lock %s: skipping", sll->str);
+				vg = vg_read(cmd, sll->str, NULL, flags);
+				if (vg_read_error(vg)) {
 					ret_max = ECMD_FAILED;
 					continue;
 				}
-				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;
-					continue;
-				}
-				if (!consistent) {
-					unlock_and_release_vg(cmd, vg, sll->str);
-					continue;
-				}
-
-				if (!vg_check_status(vg, CLUSTERED)) {
-					unlock_and_release_vg(cmd, vg, sll->str);
-					continue;
-				}
 
 				ret = process_each_pv_in_vg(cmd, vg, &tags,
 							    handle,
--- LVM2/tools/vgreduce.c	2009/07/15 05:47:55	1.95
+++ LVM2/tools/vgreduce.c	2009/07/15 05:50:22	1.96
@@ -573,7 +573,7 @@
 
 		/* FIXME: Pass private struct through to all these functions */
 		/* and update in batch here? */
-		ret = process_each_pv(cmd, argc, argv, vg, LCK_NONE, 0, NULL,
+		ret = process_each_pv(cmd, argc, argv, vg, READ_FOR_UPDATE, 0, NULL,
 				      _vgreduce_single);
 
 	}


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-14  2:15 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-14  2:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-14 02:15:21

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit - move move_pvs_used_by_lv and move_pv inside library.
	
	In the future we may export these functions or something like them in liblvm
	For now this helps in cleaning up the checks for RESIZEABLE since we can
	use the internal library function vg_bad_status_bits.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
	Acked-by: Alasdair G Kergon <agk@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.90&r2=1.91
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.247&r2=1.248
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84

--- LVM2/lib/metadata/metadata-exported.h	2009/07/10 21:19:37	1.90
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/14 02:15:21	1.91
@@ -375,6 +375,11 @@
 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
 	     struct dm_list *mdas, int64_t label_sector);
 int is_pv(pv_t *pv);
+int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
+	    const char *pv_name);
+int move_pvs_used_by_lv(struct volume_group *vg_from,
+			struct volume_group *vg_to,
+			const char *lv_name);
 int is_orphan_vg(const char *vg_name);
 int is_orphan(const pv_t *pv);
 int vgs_are_compatible(struct cmd_context *cmd,
--- LVM2/lib/metadata/metadata.c	2009/07/14 02:14:04	1.247
+++ LVM2/lib/metadata/metadata.c	2009/07/14 02:15:21	1.248
@@ -274,6 +274,72 @@
 	return r;
 }
 
+int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
+	    const char *pv_name)
+{
+	struct physical_volume *pv;
+	struct pv_list *pvl;
+
+	/* FIXME: handle tags */
+	if (!(pvl = find_pv_in_vg(vg_from, pv_name))) {
+		log_error("Physical volume %s not in volume group %s",
+			  pv_name, vg_from->name);
+		return 0;
+	}
+
+	dm_list_move(&vg_to->pvs, &pvl->list);
+
+	vg_from->pv_count--;
+	vg_to->pv_count++;
+
+	pv = pvl->pv;
+
+	vg_from->extent_count -= pv_pe_count(pv);
+	vg_to->extent_count += pv_pe_count(pv);
+
+	vg_from->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
+	vg_to->free_count += pv_pe_count(pv) - pv_pe_alloc_count(pv);
+
+	return 1;
+}
+
+int move_pvs_used_by_lv(struct volume_group *vg_from,
+			struct volume_group *vg_to,
+			const char *lv_name)
+{
+	struct lv_segment *lvseg;
+	unsigned s;
+	struct lv_list *lvl;
+	struct logical_volume *lv;
+
+	/* FIXME: handle tags */
+	if (!(lvl = find_lv_in_vg(vg_from, lv_name))) {
+		log_error("Logical volume %s not in volume group %s",
+			  lv_name, vg_from->name);
+		return 0;
+	}
+
+	dm_list_iterate_items(lvseg, &lvl->lv->segments) {
+		if (lvseg->log_lv)
+			if (!move_pvs_used_by_lv(vg_from, vg_to,
+						     lvseg->log_lv->name))
+				return_0;
+		for (s = 0; s < lvseg->area_count; s++) {
+			if (seg_type(lvseg, s) == AREA_PV) {
+				if (!move_pv(vg_from, vg_to,
+					      pv_dev_name(seg_pv(lvseg, s))))
+					return_0;
+			} else if (seg_type(lvseg, s) == AREA_LV) {
+				lv = seg_lv(lvseg, s);
+				if (!move_pvs_used_by_lv(vg_from, vg_to,
+							     lv->name))
+				    return_0;
+			}
+		}
+	}
+	return 1;
+}
+
 static int validate_new_vg_name(struct cmd_context *cmd, const char *vg_name)
 {
 	char vg_path[PATH_MAX];
--- LVM2/tools/vgsplit.c	2009/07/09 10:09:33	1.83
+++ LVM2/tools/vgsplit.c	2009/07/14 02:15:21	1.84
@@ -15,72 +15,6 @@
 
 #include "tools.h"
 
-static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
-		    const char *pv_name)
-{
-	struct physical_volume *pv;
-	struct pv_list *pvl;
-
-	/* FIXME: handle tags */
-	if (!(pvl = find_pv_in_vg(vg_from, pv_name))) {
-		log_error("Physical volume %s not in volume group %s",
-			  pv_name, vg_from->name);
-		return 0;
-	}
-
-	dm_list_move(&vg_to->pvs, &pvl->list);
-
-	vg_from->pv_count--;
-	vg_to->pv_count++;
-
-	pv = pvl->pv;
-
-	vg_from->extent_count -= pv_pe_count(pv);
-	vg_to->extent_count += pv_pe_count(pv);
-
-	vg_from->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
-	vg_to->free_count += pv_pe_count(pv) - pv_pe_alloc_count(pv);
-
-	return 1;
-}
-
-static int _move_pvs_used_by_lv(struct volume_group *vg_from,
-				   struct volume_group *vg_to,
-				   const char *lv_name)
-{
-	struct lv_segment *lvseg;
-	unsigned s;
-	struct lv_list *lvl;
-	struct logical_volume *lv;
-
-	/* FIXME: handle tags */
-	if (!(lvl = find_lv_in_vg(vg_from, lv_name))) {
-		log_error("Logical volume %s not in volume group %s",
-			  lv_name, vg_from->name);
-		return 0;
-	}
-
-	dm_list_iterate_items(lvseg, &lvl->lv->segments) {
-		if (lvseg->log_lv)
-			if (!_move_pvs_used_by_lv(vg_from, vg_to,
-						     lvseg->log_lv->name))
-				return_0;
-		for (s = 0; s < lvseg->area_count; s++) {
-			if (seg_type(lvseg, s) == AREA_PV) {
-				if (!_move_pv(vg_from, vg_to,
-					      pv_dev_name(seg_pv(lvseg, s))))
-					return_0;
-			} else if (seg_type(lvseg, s) == AREA_LV) {
-				lv = seg_lv(lvseg, s);
-				if (!_move_pvs_used_by_lv(vg_from, vg_to,
-							     lv->name))
-				    return_0;
-			}
-		}
-	}
-	return 1;
-}
-
 /* FIXME Why not (lv->vg == vg) ? */
 static int _lv_is_in_vg(struct volume_group *vg, struct logical_volume *lv)
 {
@@ -401,12 +335,12 @@
 
 	/* Move PVs across to new structure */
 	for (opt = 0; opt < argc; opt++) {
-		if (!_move_pv(vg_from, vg_to, argv[opt]))
+		if (!move_pv(vg_from, vg_to, argv[opt]))
 			goto_bad;
 	}
 
 	/* If an LV given on the cmdline, move used_by PVs */
-	if (lv_name && !_move_pvs_used_by_lv(vg_from, vg_to, lv_name))
+	if (lv_name && !move_pvs_used_by_lv(vg_from, vg_to, lv_name))
 		goto_bad;
 
 	/* Move required LVs across, checking consistency */


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-10 20:07 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-10 20:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-10 20:07:03

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgremove.c 

Log message:
	Remove force parameter from vg_remove_single, now the liblvm function.
	
	Move check for active LVs outside of library function.  The vgremove
	liblvm function function will fail if there are active LVs.  It will
	be the application's responsibility to check this condition and remove
	the LVs individually before calling vgremove.  Note also that we've
	duplicated the EXPORTED_VG check in vgremove_single (tools) and
	vg_remove_single (library).  Duplication seemed the only option here
	since we don't want to do the automatic removal of LVs (in the tools)
	if the vg is exported, and we still need to protect the library call
	from removal if the vg is exported.
	
	We still need to deal with the ORPHAN lock but vg_remove_single is now
	very close to our liblvm function.
	
	TODO: Refactor lvremove in a similar way.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.88&r2=1.89
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.242&r2=1.243
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52

--- LVM2/lib/metadata/metadata-exported.h	2009/07/10 20:05:29	1.88
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/10 20:07:02	1.89
@@ -425,7 +425,7 @@
 
 vg_t *vg_create(struct cmd_context *cmd, const char *vg_name);
 int vg_remove(struct volume_group *vg);
-int vg_remove_single(vg_t *vg, force_t force);
+int vg_remove_single(vg_t *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
@@ -436,6 +436,10 @@
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
+/* FIXME: refactor / unexport when lvremove liblvm refactoring dones */
+int remove_lvs_in_vg(struct cmd_context *cmd,
+		     struct volume_group *vg,
+		     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.
--- LVM2/lib/metadata/metadata.c	2009/07/10 20:05:29	1.242
+++ LVM2/lib/metadata/metadata.c	2009/07/10 20:07:02	1.243
@@ -343,9 +343,9 @@
 	return 1;
 }
 
-static int remove_lvs_in_vg(struct cmd_context *cmd,
-			    struct volume_group *vg,
-			    force_t force)
+int remove_lvs_in_vg(struct cmd_context *cmd,
+		     struct volume_group *vg,
+		     force_t force)
 {
 	struct dm_list *lst;
 	struct lv_list *lvl;
@@ -359,7 +359,7 @@
 	return 1;
 }
 
-int vg_remove_single(vg_t *vg, force_t force)
+int vg_remove_single(vg_t *vg)
 {
 	struct physical_volume *pv;
 	struct pv_list *pvl;
@@ -380,21 +380,6 @@
 	lv_count = vg_visible_lvs(vg);
 
 	if (lv_count) {
-		if ((force == PROMPT) &&
-		    (yes_no_prompt("Do you really want to remove volume "
-				   "group \"%s\" containing %u "
-				   "logical volumes? [y/n]: ",
-				   vg->name, lv_count) == 'n')) {
-			log_print("Volume group \"%s\" not removed", vg_name);
-			return 0;
-		}
-		if (!remove_lvs_in_vg(vg->cmd, vg, force))
-			return 0;
-	}
-
-	lv_count = vg_visible_lvs(vg);
-
-	if (lv_count) {
 		log_error("Volume group \"%s\" still contains %u "
 			  "logical volume(s)", vg->name, lv_count);
 		return 0;
--- LVM2/tools/vgremove.c	2009/07/10 20:05:29	1.51
+++ LVM2/tools/vgremove.c	2009/07/10 20:07:03	1.52
@@ -19,7 +19,29 @@
 			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
-	if (!vg_remove_single(vg, arg_count(cmd, force_ARG)))
+	unsigned lv_count;
+	force_t force;
+
+	if (!vg_check_status(vg, EXPORTED_VG))
+		return ECMD_FAILED;
+
+	lv_count = vg_visible_lvs(vg);
+
+	force = arg_count(cmd, force_ARG);
+	if (lv_count) {
+		if ((force == PROMPT) &&
+		    (yes_no_prompt("Do you really want to remove volume "
+				   "group \"%s\" containing %u "
+				   "logical volumes? [y/n]: ",
+				   vg_name, lv_count) == 'n')) {
+			log_print("Volume group \"%s\" not removed", vg_name);
+			return ECMD_FAILED;
+		}
+		if (!remove_lvs_in_vg(cmd, vg, force))
+			return ECMD_FAILED;
+	}
+
+	if (!vg_remove_single(vg))
 		return ECMD_FAILED;
 
 	return ECMD_PROCESSED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-10 20:05 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-10 20:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-10 20:05:29

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgremove.c 

Log message:
	Remove unnecessary parameters from vg_remove_single().
	
	Use vg_t instead of struct volume_group.
	Should be no functional change.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.241&r2=1.242
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51

--- LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:09:33	1.87
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/10 20:05:29	1.88
@@ -425,9 +425,7 @@
 
 vg_t *vg_create(struct cmd_context *cmd, const char *vg_name);
 int vg_remove(struct volume_group *vg);
-int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
-		     struct volume_group *vg,
-		     force_t force);
+int vg_remove_single(vg_t *vg, force_t force);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:09:33	1.241
+++ LVM2/lib/metadata/metadata.c	2009/07/10 20:05:29	1.242
@@ -359,10 +359,7 @@
 	return 1;
 }
 
-/* FIXME: remove redundant vg_name */
-int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
-		     struct volume_group *vg,
-		     force_t force __attribute((unused)))
+int vg_remove_single(vg_t *vg, force_t force)
 {
 	struct physical_volume *pv;
 	struct pv_list *pvl;
@@ -371,7 +368,7 @@
 
 	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);
+			  "or has PVs missing.", vg ? vg->name : "");
 		log_error("Consider vgreduce --removemissing if metadata "
 			  "is inconsistent.");
 		return 0;
@@ -387,11 +384,11 @@
 		    (yes_no_prompt("Do you really want to remove volume "
 				   "group \"%s\" containing %u "
 				   "logical volumes? [y/n]: ",
-				   vg_name, lv_count) == 'n')) {
+				   vg->name, lv_count) == 'n')) {
 			log_print("Volume group \"%s\" not removed", vg_name);
 			return 0;
 		}
-		if (!remove_lvs_in_vg(cmd, vg, force))
+		if (!remove_lvs_in_vg(vg->cmd, vg, force))
 			return 0;
 	}
 
@@ -399,7 +396,7 @@
 
 	if (lv_count) {
 		log_error("Volume group \"%s\" still contains %u "
-			  "logical volume(s)", vg_name, lv_count);
+			  "logical volume(s)", vg->name, lv_count);
 		return 0;
 	}
 
@@ -407,7 +404,7 @@
 		return 0;
 
 	if (!vg_remove(vg)) {
-		log_error("vg_remove %s failed", vg_name);
+		log_error("vg_remove %s failed", vg->name);
 		return 0;
 	}
 
@@ -415,7 +412,7 @@
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		pv = pvl->pv;
 		log_verbose("Removing physical volume \"%s\" from "
-			    "volume group \"%s\"", pv_dev_name(pv), vg_name);
+			    "volume group \"%s\"", pv_dev_name(pv), vg->name);
 		pv->vg_name = vg->fid->fmt->orphan_vg_name;
 		pv->status = ALLOCATABLE_PV;
 
@@ -426,20 +423,20 @@
 		}
 
 		/* FIXME Write to same sector label was read from */
-		if (!pv_write(cmd, pv, NULL, INT64_C(-1))) {
+		if (!pv_write(vg->cmd, pv, NULL, INT64_C(-1))) {
 			log_error("Failed to remove physical volume \"%s\""
 				  " from volume group \"%s\"",
-				  pv_dev_name(pv), vg_name);
+				  pv_dev_name(pv), vg->name);
 			ret = 0;
 		}
 	}
 
-	backup_remove(cmd, vg_name);
+	backup_remove(vg->cmd, vg->name);
 
 	if (ret)
-		log_print("Volume group \"%s\" successfully removed", vg_name);
+		log_print("Volume group \"%s\" successfully removed", vg->name);
 	else
-		log_error("Volume group \"%s\" not properly removed", vg_name);
+		log_error("Volume group \"%s\" not properly removed", vg->name);
 
 	return ret;
 }
--- LVM2/tools/vgremove.c	2009/07/08 14:33:17	1.50
+++ LVM2/tools/vgremove.c	2009/07/10 20:05:29	1.51
@@ -19,8 +19,7 @@
 			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
-	if (!vg_remove_single(cmd, vg_name, vg,
-			      arg_count(cmd, force_ARG)))
+	if (!vg_remove_single(vg, arg_count(cmd, force_ARG)))
 		return ECMD_FAILED;
 
 	return ECMD_PROCESSED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-09 10:09 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-09 10:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 10:09:33

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgcreate.c vgsplit.c 

Log message:
	Change vg_create() to take only minimal parameters and obtain a lock.
	
	vg_t *vg_create(struct cmd_context *cmd, const char *vg_name);
	This is the first step towards the API called to create a VG.
	Call vg_lock_newname() inside this function.  Use _vg_make_handle()
	where possible.
	Now we have 2 ways to construct a volume group:
	1) vg_read: Used when constructing an existing VG from disks
	2) vg_create: Used when constructing a new VG
	Both of these interfaces obtain a lock, and return a vg_t *.
	The usage of _vg_make_handle() inside vg_create() doesn't fit
	perfectly but it's ok for now.  Needs some cleanup though and I've
	noted "FIXME" in the code.
	
	Add the new vg_create() plus vg 'set' functions for non-default
	VG parameters in the following tools:
	- vgcreate: Fairly straightforward refactoring.  We just moved
	vg_lock_newname inside vg_create so we check the return via
	vg_read_error.
	- vgsplit: The refactoring here is a bit more tricky.  Originally
	we called vg_lock_newname and depending on the error code, we either
	read the existing vg or created the new one.  Now vg_create()
	calls vg_lock_newname, so we first try to create the VG.  If this
	fails with FAILED_EXIST, we can then do the vg_read.  If the
	create succeeds, we check the input parameters and set any new
	values on the VG.
	
	TODO in future patches:
	1. The VG_ORPHAN lock needs some thought.  We may want to treat
	this as any other VG, and require the application to obtain a handle
	and pass it to other API calls (for example, vg_extend).  Or,
	we may find that hiding the VG_ORPHAN lock inside other APIs is
	the way to go.  I thought of placing the VG_ORPHAN lock inside
	vg_create() and tying it to the vg handle, but was not certain
	this was the right approach.
	2. Cleanup error paths. Integrate vg_read_error() with vg_create and
	vg_read* error codes and/or the new error APIs.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.240&r2=1.241
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83

--- LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:08:54	1.86
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:09:33	1.87
@@ -423,10 +423,7 @@
 /* FIXME: move internal to library */
 uint32_t pv_list_extents_free(const struct dm_list *pvh);
 
-struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
-			       uint32_t extent_size, uint32_t max_pv,
-			       uint32_t max_lv, alloc_policy_t alloc,
-			       int pv_count, char **pv_names);
+vg_t *vg_create(struct cmd_context *cmd, const char *vg_name);
 int vg_remove(struct volume_group *vg);
 int vg_remove_single(struct cmd_context *cmd, const char *vg_name,
 		     struct volume_group *vg,
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:08:54	1.240
+++ LVM2/lib/metadata/metadata.c	2009/07/09 10:09:33	1.241
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -67,6 +67,10 @@
 static struct physical_volume *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
 						      const struct id *id);
 
+static vg_t *_vg_make_handle(struct cmd_context *cmd,
+			     struct volume_group *vg,
+			     uint32_t failure);
+
 unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignment)
 {
 	if (pv->pe_align)
@@ -515,24 +519,43 @@
 	return 0;
 }
 
-struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
-			       uint32_t extent_size, uint32_t max_pv,
-			       uint32_t max_lv, alloc_policy_t alloc,
-			       int pv_count, char **pv_names)
+/*
+ * Create a VG with default parameters.
+ * Returns:
+ * - vg_t* with SUCCESS code: VG structure created
+ * - NULL or vg_t* with FAILED_* code: error creating VG structure
+ * Use vg_read_error() to determine success or failure.
+ * FIXME: cleanup usage of _vg_make_handle()
+ */
+vg_t *vg_create(struct cmd_context *cmd, const char *vg_name)
 {
-	struct volume_group *vg;
+	vg_t *vg;
 	int consistent = 0;
 	struct dm_pool *mem;
+	uint32_t rc;
 
+	if (!validate_name(vg_name)) {
+		log_error("Invalid vg name %s", vg_name);
+		/* FIXME: use _vg_make_handle() w/proper error code */
+		return NULL;
+	}
+
+	rc = vg_lock_newname(cmd, vg_name);
+	if (rc != SUCCESS)
+		/* 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
+	   vg_lock_newname? */
 	/* is this vg name already in use ? */
 	if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
-		log_err("A volume group called '%s' already exists.", vg_name);
-		vg_release(vg);
-		return NULL;
+		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);
 	}
 
 	if (!(mem = dm_pool_create("lvm2 vg_create", VG_MEMPOOL_CHUNK)))
-		return_NULL;
+		goto_bad;
 
 	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
 		goto_bad;
@@ -559,14 +582,14 @@
 
 	*vg->system_id = '\0';
 
-	vg->extent_size = extent_size;
+	vg->extent_size = DEFAULT_EXTENT_SIZE * 2;
 	vg->extent_count = 0;
 	vg->free_count = 0;
 
-	vg->max_lv = max_lv;
-	vg->max_pv = max_pv;
+	vg->max_lv = DEFAULT_MAX_LV;
+	vg->max_pv = DEFAULT_MAX_PV;
 
-	vg->alloc = alloc;
+	vg->alloc = DEFAULT_ALLOC_POLICY;
 
 	vg->pv_count = 0;
 	dm_list_init(&vg->pvs);
@@ -587,15 +610,11 @@
 			  vg_name);
 		goto bad;
 	}
+	return _vg_make_handle(cmd, vg, SUCCESS);
 
-	/* attach the pv's */
-	if (!vg_extend(vg, pv_count, pv_names))
-		goto_bad;
-
-	return vg;
-
-      bad:
-	dm_pool_destroy(mem);
+bad:
+	unlock_and_release_vg(cmd, vg, vg_name);
+	/* FIXME: use _vg_make_handle() w/proper error code */
 	return NULL;
 }
 
--- LVM2/tools/vgcreate.c	2009/07/09 10:00:36	1.62
+++ LVM2/tools/vgcreate.c	2009/07/09 10:09:33	1.63
@@ -46,22 +46,26 @@
 	if (validate_vg_create_params(cmd, &vp_new))
 	    return EINVALID_CMD_LINE;
 
+	/* FIXME: orphan lock needs tied to vg handle or inside library call */
 	if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
 		log_error("Can't get lock for orphan PVs");
 		return ECMD_FAILED;
 	}
 
-	if (vg_lock_newname(cmd, vp_new.vg_name) != SUCCESS) {
-		log_error("Can't get lock for %s", vp_new.vg_name);
-		unlock_vg(cmd, VG_ORPHANS);
-		return ECMD_FAILED;
-	}
-
 	/* Create the new VG */
-	if (!(vg = vg_create(cmd, vp_new.vg_name, vp_new.extent_size,
-			     vp_new.max_pv, vp_new.max_lv, vp_new.alloc,
-			     argc - 1, argv + 1)))
-		goto bad;
+	vg = vg_create(cmd, vp_new.vg_name);
+	if (vg_read_error(vg))
+		goto_bad;
+
+	if (!vg_set_extent_size(vg, vp_new.extent_size) ||
+	    !vg_set_max_lv(vg, vp_new.max_lv) ||
+	    !vg_set_max_pv(vg, vp_new.max_pv) ||
+	    !vg_set_alloc_policy(vg, vp_new.alloc))
+		goto_bad;
+
+	/* attach the pv's */
+	if (!vg_extend(vg, argc - 1, argv + 1))
+		goto_bad;
 
 	if (vp_new.max_lv != vg->max_lv)
 		log_warn("WARNING: Setting maxlogicalvolumes to %d "
--- LVM2/tools/vgsplit.c	2009/07/09 10:00:36	1.82
+++ LVM2/tools/vgsplit.c	2009/07/09 10:09:33	1.83
@@ -284,7 +284,6 @@
 	int existing_vg = 0;
 	int r = ECMD_FAILED;
 	const char *lv_name;
-	uint32_t rc;
 
 	if ((arg_count(cmd, name_ARG) + argc) < 3) {
 		log_error("Existing VG, new VG and either physical volumes "
@@ -322,24 +321,34 @@
 		return ECMD_FAILED;
 	}
 
+	/*
+	 * Set metadata format of original VG.
+	 * NOTE: We must set the format before calling vg_create()
+	 * since vg_create() calls the per-format constructor.
+	 */
+	cmd->fmt = vg_from->fid->fmt;
+
 	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
 	/*
-	 * Try to lock the name of the new VG.  If we cannot reserve it,
-	 * then we assume it exists, and we will not be holding a lock.
-	 * We then try to read it - the vgsplit will be into an existing VG.
+	 * First try to create a new VG.  If we cannot create it,
+	 * and we get FAILED_EXIST (we will not be holding a lock),
+	 * a VG must already exist with this name.  We then try to
+	 * read the existing VG - the vgsplit will be into an existing VG.
 	 *
 	 * Otherwise, if the lock was successful, it must be the case that
 	 * we obtained a WRITE lock and could not find the vgname in the
 	 * system.  Thus, the split will be into a new VG.
 	 */
-	rc = vg_lock_newname(cmd, vg_name_to);
-	if (rc == FAILED_LOCKING) {
+	vg_to = vg_create(cmd, vg_name_to);
+	if (vg_read_error(vg_to) == FAILED_LOCKING) {
 		log_error("Can't get lock for %s", vg_name_to);
+		vg_release(vg_to);
 		unlock_and_release_vg(cmd, vg_from, vg_name_from);
 		return ECMD_FAILED;
 	}
-	if (rc == FAILED_EXIST) {
+	if (vg_read_error(vg_to) == FAILED_EXIST) {
 		existing_vg = 1;
+		vg_release(vg_to);
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
 					   READ_REQUIRE_RESIZEABLE);
 
@@ -356,13 +365,9 @@
 		}
 		if (!vgs_are_compatible(cmd, vg_from,vg_to))
 			goto_bad;
-	} else if (rc == SUCCESS) {
+	} else if (vg_read_error(vg_to) == SUCCESS) {
 		existing_vg = 0;
 
-		/* Set metadata format of original VG */
-		/* FIXME: need some common logic */
-		cmd->fmt = vg_from->fid->fmt;
-
 		vp_def.vg_name = NULL;
 		vp_def.extent_size = vg_from->extent_size;
 		vp_def.max_pv = vg_from->max_pv;
@@ -380,9 +385,10 @@
 			goto bad;
 		}
 
-		if (!(vg_to = vg_create(cmd, vg_name_to, vp_new.extent_size,
-					vp_new.max_pv, vp_new.max_lv,
-					vp_new.alloc, 0, NULL)))
+		if (!vg_set_extent_size(vg_to, vp_new.extent_size) ||
+		    !vg_set_max_lv(vg_to, vp_new.max_lv) ||
+		    !vg_set_max_pv(vg_to, vp_new.max_pv) ||
+		    !vg_set_alloc_policy(vg_to, vp_new.alloc))
 			goto_bad;
 
 		if (vg_is_clustered(vg_from))


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-09 10:08 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-09 10:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 10:08:54

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Add vg_set_alloc_policy() liblvm function and move vgchange logic inside.
	
	NOTE: vg_set_alloc_policy() returns success if you try to set a value that
	is already stored.  The behavior of vgchange is the same though - it fails.
	There is a fixme noted in the code about this inconsistency, which should
	be resolved if possible.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.85&r2=1.86
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.239&r2=1.240
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80

--- LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:07:47	1.85
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:08:54	1.86
@@ -437,6 +437,7 @@
 int vg_set_extent_size(vg_t *vg, uint32_t new_extent_size);
 int vg_set_max_lv(vg_t *vg, uint32_t max_lv);
 int vg_set_max_pv(vg_t *vg, uint32_t max_pv);
+int vg_set_alloc_policy(vg_t *vg, alloc_policy_t alloc);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:07:47	1.239
+++ LVM2/lib/metadata/metadata.c	2009/07/09 10:08:54	1.240
@@ -829,6 +829,24 @@
 	return 1;
 }
 
+int vg_set_alloc_policy(vg_t *vg, alloc_policy_t alloc)
+{
+	if (alloc == ALLOC_INHERIT) {
+		log_error("Volume Group allocation policy cannot inherit "
+			  "from anything");
+		return 0;
+	}
+
+	if (alloc == vg->alloc) {
+		log_print("Volume group allocation policy is already %s",
+			  get_alloc_string(vg->alloc));
+		return 1;
+	}
+	vg->alloc = alloc;
+	return 1;
+}
+
+
 /*
  * Separate metadata areas after splitting a VG.
  * Also accepts orphan VG as destination (for vgreduce).
--- LVM2/tools/vgchange.c	2009/07/09 10:07:47	1.79
+++ LVM2/tools/vgchange.c	2009/07/09 10:08:54	1.80
@@ -179,23 +179,18 @@
 
 	alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
 
-	if (alloc == ALLOC_INHERIT) {
-		log_error("Volume Group allocation policy cannot inherit "
-			  "from anything");
-		return EINVALID_CMD_LINE;
-	}
+	if (!archive(vg))
+		return ECMD_FAILED;
 
+	/* FIXME: make consistent with vg_set_alloc_policy() */
 	if (alloc == vg->alloc) {
 		log_error("Volume group allocation policy is already %s",
 			  get_alloc_string(vg->alloc));
 		return ECMD_FAILED;
 	}
-
-	if (!archive(vg))
+	if (!vg_set_alloc_policy(vg, alloc))
 		return ECMD_FAILED;
 
-	vg->alloc = alloc;
-
 	if (!vg_write(vg) || !vg_commit(vg))
 		return ECMD_FAILED;
 


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-09 10:07 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-09 10:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 10:07:47

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Add vg_set_max_pv() liblvm function and move vgchange logic inside.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.238&r2=1.239
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79

--- LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:06:00	1.84
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:07:47	1.85
@@ -436,6 +436,7 @@
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
 int vg_set_extent_size(vg_t *vg, uint32_t new_extent_size);
 int vg_set_max_lv(vg_t *vg, uint32_t max_lv);
+int vg_set_max_pv(vg_t *vg, uint32_t max_pv);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:06:00	1.238
+++ LVM2/lib/metadata/metadata.c	2009/07/09 10:07:47	1.239
@@ -802,6 +802,33 @@
 	return 1;
 }
 
+int vg_set_max_pv(vg_t *vg, uint32_t max_pv)
+{
+	if (!(vg_status(vg) & RESIZEABLE_VG)) {
+		log_error("Volume group \"%s\" must be resizeable "
+			  "to change MaxPhysicalVolumes", vg->name);
+		return 0;
+	}
+
+	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
+		if (!max_pv)
+			max_pv = 255;
+		else if (max_pv > 255) {
+			log_error("MaxPhysicalVolume limit is 255");
+			return 0;
+		}
+	}
+
+	if (max_pv && max_pv < vg->pv_count) {
+		log_error("MaxPhysicalVolumes is less than the current number "
+			  "%d of PVs for \"%s\"", vg->pv_count,
+			  vg->name);
+		return 0;
+	}
+	vg->max_pv = max_pv;
+	return 1;
+}
+
 /*
  * Separate metadata areas after splitting a VG.
  * Also accepts orphan VG as destination (for vgreduce).
--- LVM2/tools/vgchange.c	2009/07/09 10:06:01	1.78
+++ LVM2/tools/vgchange.c	2009/07/09 10:07:47	1.79
@@ -314,37 +314,16 @@
 {
 	uint32_t max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
 
-	if (!(vg_status(vg) & RESIZEABLE_VG)) {
-		log_error("Volume group \"%s\" must be resizeable "
-			  "to change MaxPhysicalVolumes", vg->name);
-		return ECMD_FAILED;
-	}
-
 	if (arg_sign_value(cmd, maxphysicalvolumes_ARG, 0) == SIGN_MINUS) {
 		log_error("MaxPhysicalVolumes may not be negative");
 		return EINVALID_CMD_LINE;
 	}
 
-	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
-		if (!max_pv)
-			max_pv = 255;
-		else if (max_pv > 255) {
-			log_error("MaxPhysicalVolume limit is 255");
-			return ECMD_FAILED;
-		}
-	}
-
-	if (max_pv && max_pv < vg->pv_count) {
-		log_error("MaxPhysicalVolumes is less than the current number "
-			  "%d of PVs for \"%s\"", vg->pv_count,
-			  vg->name);
-		return ECMD_FAILED;
-	}
-
 	if (!archive(vg))
 		return ECMD_FAILED;
 
-	vg->max_pv = max_pv;
+	if (!vg_set_max_pv(vg, max_pv))
+		return ECMD_FAILED;
 
 	if (!vg_write(vg) || !vg_commit(vg))
 		return ECMD_FAILED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-09 10:06 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-09 10:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 10:06:01

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Add vg_set_max_lv() liblvm function and move vgchange logic inside.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.237&r2=1.238
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78

--- LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:04:52	1.83
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:06:00	1.84
@@ -435,6 +435,7 @@
 	      const char *new_name);
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
 int vg_set_extent_size(vg_t *vg, uint32_t new_extent_size);
+int vg_set_max_lv(vg_t *vg, uint32_t max_lv);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:04:52	1.237
+++ LVM2/lib/metadata/metadata.c	2009/07/09 10:06:00	1.238
@@ -774,6 +774,34 @@
 	return 1;
 }
 
+int vg_set_max_lv(vg_t *vg, uint32_t max_lv)
+{
+	if (!(vg_status(vg) & RESIZEABLE_VG)) {
+		log_error("Volume group \"%s\" must be resizeable "
+			  "to change MaxLogicalVolume", vg->name);
+		return 0;
+	}
+
+	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
+		if (!max_lv)
+			max_lv = 255;
+		else if (max_lv > 255) {
+			log_error("MaxLogicalVolume limit is 255");
+			return 0;
+		}
+	}
+
+	if (max_lv && max_lv < vg_visible_lvs(vg)) {
+		log_error("MaxLogicalVolume is less than the current number "
+			  "%d of LVs for %s", vg_visible_lvs(vg),
+			  vg->name);
+		return 0;
+	}
+	vg->max_lv = max_lv;
+
+	return 1;
+}
+
 /*
  * Separate metadata areas after splitting a VG.
  * Also accepts orphan VG as destination (for vgreduce).
--- LVM2/tools/vgchange.c	2009/07/09 10:04:52	1.77
+++ LVM2/tools/vgchange.c	2009/07/09 10:06:01	1.78
@@ -293,32 +293,11 @@
 {
 	uint32_t max_lv = arg_uint_value(cmd, logicalvolume_ARG, 0);
 
-	if (!(vg_status(vg) & RESIZEABLE_VG)) {
-		log_error("Volume group \"%s\" must be resizeable "
-			  "to change MaxLogicalVolume", vg->name);
-		return ECMD_FAILED;
-	}
-
-	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS)) {
-		if (!max_lv)
-			max_lv = 255;
-		else if (max_lv > 255) {
-			log_error("MaxLogicalVolume limit is 255");
-			return ECMD_FAILED;
-		}
-	}
-
-	if (max_lv && max_lv < vg_visible_lvs(vg)) {
-		log_error("MaxLogicalVolume is less than the current number "
-			  "%d of LVs for %s", vg_visible_lvs(vg),
-			  vg->name);
-		return ECMD_FAILED;
-	}
-
 	if (!archive(vg))
 		return ECMD_FAILED;
 
-	vg->max_lv = max_lv;
+	if (!vg_set_max_lv(vg, max_lv))
+		return ECMD_FAILED;
 
 	if (!vg_write(vg) || !vg_commit(vg))
 		return ECMD_FAILED;


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-09 10:04 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-09 10:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 10:04:52

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Rename vg_change_pesize to vg_set_extent_size and use vg_t.
	
	In liblvm, we will reserve the word 'change' to mean an API that
	both sets one or more values, and commits to disk.  This will be
	consistent with the LVM commandline.  The existing vg_change_pesize()
	function does not commit to disk, but just changes the extent_size
	and ensures all internal structures are updated.  This logic should
	be contained in a function that sets the value.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.82&r2=1.83
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.236&r2=1.237
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77

--- LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:03:37	1.82
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:04:52	1.83
@@ -434,7 +434,7 @@
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
-int vg_change_pesize(struct volume_group *vg, uint32_t new_extent_size);
+int vg_set_extent_size(vg_t *vg, uint32_t new_extent_size);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:03:37	1.236
+++ LVM2/lib/metadata/metadata.c	2009/07/09 10:04:52	1.237
@@ -624,7 +624,7 @@
 	return 1;
 }
 
-int vg_change_pesize(struct volume_group *vg, uint32_t new_size)
+int vg_set_extent_size(vg_t *vg, uint32_t new_size)
 {
 	uint32_t old_size = vg->extent_size;
 	struct pv_list *pvl;
--- LVM2/tools/vgchange.c	2009/07/09 10:03:37	1.76
+++ LVM2/tools/vgchange.c	2009/07/09 10:04:52	1.77
@@ -397,7 +397,7 @@
 	if (!archive(vg))
 		return ECMD_FAILED;
 
-	if (!vg_change_pesize(vg, extent_size)) {
+	if (!vg_set_extent_size(vg, extent_size)) {
 		stack;
 		return EINVALID_CMD_LINE;
 	}


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-09 10:03 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-09 10:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 10:03:37

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgchange.c 

Log message:
	Remove unused 'cmd' from vg_change_pesize().
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.235&r2=1.236
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76

--- LVM2/lib/metadata/metadata-exported.h	2009/07/08 14:33:17	1.81
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/09 10:03:37	1.82
@@ -434,8 +434,7 @@
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
 int vg_extend(struct volume_group *vg, int pv_count, char **pv_names);
-int vg_change_pesize(struct cmd_context *cmd, struct volume_group *vg,
-		     uint32_t new_extent_size);
+int vg_change_pesize(struct volume_group *vg, uint32_t new_extent_size);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
 
--- LVM2/lib/metadata/metadata.c	2009/07/09 10:02:15	1.235
+++ LVM2/lib/metadata/metadata.c	2009/07/09 10:03:37	1.236
@@ -624,8 +624,7 @@
 	return 1;
 }
 
-int vg_change_pesize(struct cmd_context *cmd __attribute((unused)),
-		     struct volume_group *vg, uint32_t new_size)
+int vg_change_pesize(struct volume_group *vg, uint32_t new_size)
 {
 	uint32_t old_size = vg->extent_size;
 	struct pv_list *pvl;
--- LVM2/tools/vgchange.c	2009/07/09 10:02:15	1.75
+++ LVM2/tools/vgchange.c	2009/07/09 10:03:37	1.76
@@ -397,7 +397,7 @@
 	if (!archive(vg))
 		return ECMD_FAILED;
 
-	if (!vg_change_pesize(cmd, vg, extent_size)) {
+	if (!vg_change_pesize(vg, extent_size)) {
 		stack;
 		return EINVALID_CMD_LINE;
 	}


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-08 14:33 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-08 14:33 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-08 14:33:17

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : vgextend.c vgmerge.c vgreduce.c vgremove.c 
	                 vgsplit.c 

Log message:
	Remove unneeded LOCK_NONBLOCKING from vg_read() API.
	
	Remove unneeded LOCK_NONBLOCKING from vg_read() API and tools that
	use it.  We no longer need this flag anywhere since we now automatically
	set LCK_NONBLOCK inside lock_vol() if vgs_locked().
	For further details, see:
	commit d52b3fd3fe2006e2d13e42f8518b6512bff03710
	Author: Dave Wysochanski <dwysocha@redhat.com>
	Date:   Wed May 13 13:02:52 2009 +0000
	
	Remove NON_BLOCKING lock flag from tools and set a policy to auto-set.
	
	As a simplification to the tools and further liblvm, this patch pushes
	the setting of NON_BLOCKING lock flag inside the lock_vol() call.
	The policy we set is if any existing VGs are currently locked, we
	set the NON_BLOCKING flag.
	
	At some point it may make sense to add this flag back if we get an
	RFE from a liblvm user, but for now let's keep it as simple as
	possible.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.80&r2=1.81
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.233&r2=1.234
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80

--- LVM2/lib/metadata/metadata-exported.h	2009/07/08 14:31:17	1.80
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/08 14:33:17	1.81
@@ -110,9 +110,6 @@
 #define READ_ALLOW_EXPORTED	0x00020000U
 #define READ_REQUIRE_RESIZEABLE	0x00040000U
 
-/* FIXME Deduce these next requirements internally instead of having caller specify. */
-#define LOCK_NONBLOCKING	0x00000100U	/* Fail if not available immediately. */
-
 /* A meta-flag, useful with toollib for_each_* functions. */
 #define READ_FOR_UPDATE 	0x00100000U
 
--- LVM2/lib/metadata/metadata.c	2009/07/08 14:31:17	1.233
+++ LVM2/lib/metadata/metadata.c	2009/07/08 14:33:17	1.234
@@ -2845,9 +2845,6 @@
 	if (flags & READ_REQUIRE_RESIZEABLE)
 		status |= RESIZEABLE_VG;
 
-	if (flags & LOCK_NONBLOCKING)
-		lock_flags |= LCK_NONBLOCK;
-
 	return _vg_lock_and_read(cmd, vg_name, vgid, lock_flags, status, flags);
 }
 
--- LVM2/tools/vgextend.c	2009/07/07 01:18:35	1.44
+++ LVM2/tools/vgextend.c	2009/07/08 14:33:17	1.45
@@ -43,7 +43,7 @@
 
 	log_verbose("Checking for volume group \"%s\"", vg_name);
 	vg = vg_read_for_update(cmd, vg_name, NULL,
-				READ_REQUIRE_RESIZEABLE | LOCK_NONBLOCKING);
+				READ_REQUIRE_RESIZEABLE);
 	if (vg_read_error(vg)) {
 		vg_release(vg);
 		unlock_vg(cmd, VG_ORPHANS);
--- LVM2/tools/vgmerge.c	2009/07/07 01:18:35	1.59
+++ LVM2/tools/vgmerge.c	2009/07/08 14:33:17	1.60
@@ -35,8 +35,7 @@
 	}
 
 	log_verbose("Checking for volume group \"%s\"", vg_name_from);
-	vg_from = vg_read_for_update(cmd, vg_name_from, NULL,
-				     LOCK_NONBLOCKING);
+	vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
 	if (vg_read_error(vg_from)) {
 		vg_release(vg_from);
 		unlock_and_release_vg(cmd, vg_to, vg_name_to);
--- LVM2/tools/vgreduce.c	2009/07/01 17:01:46	1.93
+++ LVM2/tools/vgreduce.c	2009/07/08 14:33:17	1.94
@@ -424,7 +424,7 @@
 	vg->extent_count -= pv_pe_count(pv);
 
 	orphan_vg = vg_read_for_update(cmd, vg->fid->fmt->orphan_vg_name,
-				       NULL, LOCK_NONBLOCKING);
+				       NULL, 0);
 
 	if (vg_read_error(orphan_vg))
 		goto bad;
--- LVM2/tools/vgremove.c	2009/07/01 17:00:52	1.49
+++ LVM2/tools/vgremove.c	2009/07/08 14:33:17	1.50
@@ -41,7 +41,7 @@
 	}
 
 	ret = process_each_vg(cmd, argc, argv,
-			      READ_FOR_UPDATE | LOCK_NONBLOCKING,
+			      READ_FOR_UPDATE,
 			      NULL, &vgremove_single);
 
 	unlock_vg(cmd, VG_ORPHANS);
--- LVM2/tools/vgsplit.c	2009/07/08 14:27:37	1.79
+++ LVM2/tools/vgsplit.c	2009/07/08 14:33:17	1.80
@@ -341,8 +341,7 @@
 	if (rc == FAILED_EXIST) {
 		existing_vg = 1;
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
-					   READ_REQUIRE_RESIZEABLE |
-					   LOCK_NONBLOCKING);
+					   READ_REQUIRE_RESIZEABLE);
 
 		if (vg_read_error(vg_to)) {
 			vg_release(vg_to);


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2009-07-01 17:01 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2009-07-01 17:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-01 17:00:52

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : lvchange.c lvdisplay.c lvremove.c lvscan.c 
	                 polldaemon.c reporter.c toollib.c toollib.h 
	                 vgcfgbackup.c vgchange.c vgck.c vgconvert.c 
	                 vgdisplay.c vgexport.c vgimport.c vgremove.c 
	                 vgscan.c 

Log message:
	Rework the toollib interface (process_each_*) on top of new vg_read.
	
	Sun May  3 12:32:30 CEST 2009  Petr Rockai <me@mornfall.net>
	* Rework the toollib interface (process_each_*) on top of new vg_read.
	
	Rebased 6/26/09 by Dave W.
	- Add skipping message to process_each_lv
	- Remove inconsistent_t.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.228&r2=1.229
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvdisplay.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvremove.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvscan.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.158&r2=1.159
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcfgbackup.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgck.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgdisplay.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgexport.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgimport.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgscan.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34

--- LVM2/lib/metadata/metadata-exported.h	2009/06/09 14:29:10	1.77
+++ LVM2/lib/metadata/metadata-exported.h	2009/07/01 17:00:50	1.78
@@ -155,16 +155,6 @@
 	DONT_PROMPT_OVERRIDE = 2 /* Skip prompt + override a second condition */
 } force_t;
 
-/*
- * What to do if VG is inconsistent
- * FIXME: remove this after vg_read changes
- */
-typedef enum {
-	VG_INCONSISTENT_ABORT    = 0, /* Abort operation */
-	VG_INCONSISTENT_CONTINUE = 1, /* Process operation but do not try repair */
-	VG_INCONSISTENT_REPAIR   = 2  /* Try to repair VG before processing */
-} inconsistent_t;
-
 struct cmd_context;
 struct format_handler;
 struct labeller;
@@ -445,7 +435,7 @@
 			       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);
--- LVM2/lib/metadata/metadata.c	2009/06/30 18:39:31	1.228
+++ LVM2/lib/metadata/metadata.c	2009/07/01 17:00:51	1.229
@@ -357,7 +357,7 @@
 
 /* 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;
@@ -365,7 +365,7 @@
 	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 "
--- LVM2/tools/lvchange.c	2009/06/06 22:00:20	1.104
+++ LVM2/tools/lvchange.c	2009/07/01 17:00:52	1.105
@@ -726,6 +726,6 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
+	return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, NULL,
 			       &lvchange_single);
 }
--- LVM2/tools/lvdisplay.c	2009/05/13 21:27:44	1.22
+++ LVM2/tools/lvdisplay.c	2009/07/01 17:00:52	1.23
@@ -54,6 +54,6 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
+	return process_each_lv(cmd, argc, argv, 0, NULL,
 			       &_lvdisplay_single);
 }
--- LVM2/tools/lvremove.c	2009/04/25 01:18:00	1.57
+++ LVM2/tools/lvremove.c	2009/07/01 17:00:52	1.58
@@ -41,6 +41,6 @@
 
 	cmd->handles_missing_pvs = 1;
 
-	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
+	return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, NULL,
 			       &lvremove_single);
 }
--- LVM2/tools/lvscan.c	2009/05/13 21:27:44	1.38
+++ LVM2/tools/lvscan.c	2009/07/01 17:00:52	1.39
@@ -80,6 +80,6 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
+	return process_each_lv(cmd, argc, argv, 0, NULL,
 			       &lvscan_single);
 }
--- LVM2/tools/polldaemon.c	2009/07/01 16:59:37	1.18
+++ LVM2/tools/polldaemon.c	2009/07/01 17:00:52	1.19
@@ -175,7 +175,7 @@
 }
 
 static int _poll_vg(struct cmd_context *cmd, const char *vgname,
-		    struct volume_group *vg, int consistent, void *handle)
+		    struct volume_group *vg, void *handle)
 {
 	struct daemon_parms *parms = (struct daemon_parms *) handle;
 	struct lv_list *lvl;
@@ -183,7 +183,7 @@
 	const char *name;
 	int finished;
 
-	if (!vg_check_status(vg, EXPORTED_VG))
+	if (vg_read_error(vg))
 		return ECMD_FAILED;
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
@@ -208,9 +208,7 @@
 {
 	while (1) {
 		parms->outstanding_count = 0;
-		/* FIXME Should we silently recover it here or not? */
-		process_each_vg(cmd, 0, NULL, LCK_VG_WRITE,
-				VG_INCONSISTENT_ABORT, parms, _poll_vg);
+		process_each_vg(cmd, 0, NULL, READ_FOR_UPDATE, parms, _poll_vg);
 		if (!parms->outstanding_count)
 			break;
 		sleep(parms->interval);
--- LVM2/tools/reporter.c	2009/07/01 16:59:37	1.52
+++ LVM2/tools/reporter.c	2009/07/01 17:00:52	1.53
@@ -18,8 +18,11 @@
 
 static int _vgs_single(struct cmd_context *cmd __attribute((unused)),
 		       const char *vg_name, struct volume_group *vg,
-		       int consistent __attribute((unused)), void *handle)
+		       void *handle)
 {
+	if (vg_read_error(vg))
+		return ECMD_FAILED;
+
 	if (!report_object(handle, vg, NULL, NULL, NULL, NULL))
 		return ECMD_FAILED;
 
@@ -176,17 +179,21 @@
 
 static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
 		      struct volume_group *vg,
-		      int consistent __attribute((unused)),
 		      void *handle)
 {
+	if (vg_read_error(vg))
+		return ECMD_FAILED;
+
 	return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single);
 }
 
 static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
 			 struct volume_group *vg,
-			 int consistent __attribute((unused)),
 			 void *handle)
 {
+	if (vg_read_error(vg))
+		return ECMD_FAILED;
+
 	return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single);
 }
 
@@ -363,12 +370,11 @@
 
 	switch (report_type) {
 	case LVS:
-		r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
+		r = process_each_lv(cmd, argc, argv, 0, report_handle,
 				    &_lvs_single);
 		break;
 	case VGS:
-		r = process_each_vg(cmd, argc, argv, LCK_VG_READ,
-				    VG_INCONSISTENT_CONTINUE,
+		r = process_each_vg(cmd, argc, argv, 0,
 				    report_handle, &_vgs_single);
 		break;
 	case LABEL:
@@ -380,12 +386,11 @@
 			r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
 					    0, report_handle, &_pvs_single);
 		else
-			r = process_each_vg(cmd, argc, argv, LCK_VG_READ,
-					    VG_INCONSISTENT_CONTINUE,
+			r = process_each_vg(cmd, argc, argv, 0,
 					    report_handle, &_pvs_in_vg);
 		break;
 	case SEGS:
-		r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
+		r = process_each_lv(cmd, argc, argv, 0, report_handle,
 				    &_lvsegs_single);
 		break;
 	case PVSEGS:
@@ -393,8 +398,7 @@
 			r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
 					    0, report_handle, &_pvsegs_single);
 		else
-			r = process_each_vg(cmd, argc, argv, LCK_VG_READ,
-					    VG_INCONSISTENT_CONTINUE,
+			r = process_each_vg(cmd, argc, argv, 0,
 					    report_handle, &_pvsegs_in_vg);
 		break;
 	}
--- LVM2/tools/toollib.c	2009/06/10 11:15:29	1.158
+++ LVM2/tools/toollib.c	2009/07/01 17:00:52	1.159
@@ -164,7 +164,7 @@
 }
 
 int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
-		    uint32_t lock_type, void *handle,
+		    uint32_t flags, void *handle,
 		    int (*process_single) (struct cmd_context * cmd,
 					   struct logical_volume * lv,
 					   void *handle))
@@ -172,7 +172,6 @@
 	int opt = 0;
 	int ret_max = ECMD_PROCESSED;
 	int ret = 0;
-	int consistent;
 
 	struct dm_list *tags_arg;
 	struct dm_list *vgnames;	/* VGs to process */
@@ -287,44 +286,14 @@
 		vgname = strl->str;
 		if (is_orphan_vg(vgname))
 			continue;	/* FIXME Unnecessary? */
-		if (!lock_vol(cmd, vgname, lock_type)) {
-			log_error("Can't lock %s: skipping", vgname);
-			ret_max = ECMD_FAILED;
-			continue;
-		}
-		if (lock_type & LCK_WRITE)
-			consistent = 1;
-		else
-			consistent = 0;
-		if (!(vg = vg_read_internal(cmd, vgname, NULL, &consistent)) || !consistent) {
-			unlock_vg(cmd, vgname);
-			if (!vg)
-				log_error("Volume group \"%s\" "
-					  "not found", vgname);
-			else {
-				if (!vg_check_status(vg, CLUSTERED)) {
-					if (ret_max < ECMD_FAILED)
-						ret_max = ECMD_FAILED;
-					vg_release(vg);
-					continue;
-				}
-				log_error("Volume group \"%s\" "
-					  "inconsistent", vgname);
-			}
+		vg = vg_read(cmd, vgname, NULL, flags);
 
+		if (vg_read_error(vg)) {
 			vg_release(vg);
-			if (!vg || !(vg = recover_vg(cmd, vgname, lock_type))) {
-				if (ret_max < ECMD_FAILED)
-					ret_max = ECMD_FAILED;
-				vg_release(vg);
-				continue;
-			}
-		}
-
-		if (!vg_check_status(vg, CLUSTERED)) {
-			unlock_and_release_vg(cmd, vg, vgname);
-			if (ret_max < ECMD_FAILED)
+			if (ret_max < ECMD_FAILED) {
+				log_error("Skipping volume group %s", vgname);
 				ret_max = ECMD_FAILED;
+			}
 			continue;
 		}
 
@@ -383,8 +352,8 @@
 	if (is_pv(pv) && !vg && !is_orphan(pv)) {
 		vg_name = pv_vg_name(pv);
 
-		if (!(vg = vg_lock_and_read(cmd, vg_name, NULL, LCK_VG_READ,
-					    CLUSTERED, 0))) {
+		vg = vg_read(cmd, vg_name, NULL, 0);
+		if (vg_read_error(vg)) {
 			log_error("Skipping volume group %s", vg_name);
 			return ECMD_FAILED;
 		}
@@ -449,33 +418,18 @@
 static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
 			   const char *vgid,
 			   struct dm_list *tags, struct dm_list *arg_vgnames,
-			   uint32_t lock_type, inconsistent_t repair_vg, void *handle,
-			   int ret_max,
+			   uint32_t flags, void *handle, int ret_max,
 			   int (*process_single) (struct cmd_context * cmd,
 						  const char *vg_name,
 						  struct volume_group * vg,
-						  int consistent, void *handle))
+						  void *handle))
 {
 	struct volume_group *vg;
-	int consistent = 0;
 	int ret = 0;
 
-	if (!lock_vol(cmd, vg_name, lock_type)) {
-		log_error("Can't lock volume group %s: skipping", vg_name);
-		return ECMD_FAILED;
-	}
-
 	log_verbose("Finding volume group \"%s\"", vg_name);
-	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;
-	}
 
-	if (!vg_check_status(vg, CLUSTERED)) {
-		ret_max = ECMD_FAILED;
-		goto out;
-	}
+	vg = vg_read(cmd, vg_name, vgid, flags);
 
 	if (!dm_list_empty(tags)) {
 		/* Only process if a tag matches or it's on arg_vgnames */
@@ -484,26 +438,7 @@
 			goto out;
 	}
 
-	if (!consistent)
-		switch (repair_vg) {
-		case VG_INCONSISTENT_ABORT:
-			log_error("Volume group %s inconsistent - skipping", vg_name);
-			ret_max = ECMD_FAILED;
-			goto out;
-		case VG_INCONSISTENT_CONTINUE:
-			log_error("Volume group %s inconsistent", vg_name);
-			break;
-		case VG_INCONSISTENT_REPAIR:
-			unlock_and_release_vg(cmd, vg, vg_name);
-			dev_close_all();
-			log_error("Volume group %s inconsistent", vg_name);
-			if (!(vg = recover_vg(cmd, vg_name, LCK_VG_WRITE)))
-				return ECMD_FAILED;
-			consistent = 1;
-			break;
-		}
-
-	if ((ret = process_single(cmd, vg_name, vg, consistent,
+	if ((ret = process_single(cmd, vg_name, vg,
 				  handle)) > ret_max) {
 		ret_max = ret;
 	}
@@ -514,11 +449,11 @@
 }
 
 int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
-		    uint32_t lock_type, inconsistent_t repair_vg, void *handle,
+		    uint32_t flags, void *handle,
 		    int (*process_single) (struct cmd_context * cmd,
 					   const char *vg_name,
 					   struct volume_group * vg,
-					   int consistent, void *handle))
+					   void *handle))
 {
 	int opt = 0;
 	int ret_max = ECMD_PROCESSED;
@@ -581,7 +516,7 @@
 				continue;
 			ret_max = _process_one_vg(cmd, vg_name, vgid, &tags,
 						  &arg_vgnames,
-					  	  lock_type, repair_vg, handle,
+						  flags, handle,
 					  	  ret_max, process_single);
 			if (sigint_caught())
 				return ret_max;
@@ -593,7 +528,7 @@
 				continue;	/* FIXME Unnecessary? */
 			ret_max = _process_one_vg(cmd, vg_name, NULL, &tags,
 						  &arg_vgnames,
-					  	  lock_type, repair_vg, handle,
+						  flags, handle,
 					  	  ret_max, process_single);
 			if (sigint_caught())
 				return ret_max;
@@ -1200,34 +1135,6 @@
 	return r;
 }
 
-/*
- * Attempt metadata recovery
- */
-struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
-				uint32_t lock_type)
-{
-	int consistent = 1;
-	struct volume_group *vg;
-
-	/* Don't attempt automatic recovery without proper locking */
-	if (lockingfailed())
-		return NULL;
-
-	lock_type &= ~LCK_TYPE_MASK;
-	lock_type |= LCK_WRITE;
-
-	if (!lock_vol(cmd, vgname, lock_type)) {
-		log_error("Can't lock %s for metadata recovery: skipping",
-			  vgname);
-		return NULL;
-	}
-
-	if (!(vg = vg_read_internal(cmd, vgname, NULL, &consistent)))
-		unlock_vg(cmd, vgname);
-
-	return vg;
-}
-
 int apply_lvname_restrictions(const char *name)
 {
 	if (!strncmp(name, "snapshot", 8)) {
--- LVM2/tools/toollib.h	2009/06/05 20:00:52	1.62
+++ LVM2/tools/toollib.h	2009/07/01 17:00:52	1.63
@@ -27,11 +27,11 @@
 				uint32_t lock_type);
 
 int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
-		    uint32_t lock_type, inconsistent_t repair_vg, void *handle,
+		    uint32_t flags, void *handle,
 		    int (*process_single) (struct cmd_context * cmd,
 					   const char *vg_name,
 					   struct volume_group * vg,
-					   int consistent, void *handle));
+					   void *handle));
 
 int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
 		    struct volume_group *vg, uint32_t lock_type,
@@ -51,7 +51,7 @@
 						      void *handle));
 
 int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
-		    uint32_t lock_type, void *handle,
+		    uint32_t flags, void *handle,
 		    int (*process_single) (struct cmd_context * cmd,
 					   struct logical_volume * lv,
 					   void *handle));
--- LVM2/tools/vgcfgbackup.c	2009/06/05 20:00:52	1.27
+++ LVM2/tools/vgcfgbackup.c	2009/07/01 17:00:52	1.28
@@ -48,12 +48,15 @@
 }
 
 static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
-			    struct volume_group *vg, int consistent,
+			    struct volume_group *vg,
 			    void *handle)
 {
 	char **last_filename = (char **)handle;
 	char *filename;
 
+	if (vg_read_error(vg) && !vg_read_error(vg) == FAILED_INCONSISTENT)
+		return ECMD_FAILED;
+
 	if (arg_count(cmd, file_ARG)) {
 		if (!(filename = _expand_filename(arg_value(cmd, file_ARG),
 						  vg->name, last_filename))) {
@@ -64,7 +67,7 @@
 		if (!backup_to_file(filename, vg->cmd->cmd_line, vg))
 			return ECMD_FAILED;
 	} else {
-		if (!consistent) {
+		if (vg_read_error(vg) == FAILED_INCONSISTENT) {
 			log_error("No backup taken: specify filename with -f "
 				  "to backup an inconsistent VG");
 			stack;
@@ -90,8 +93,7 @@
 
 	init_pvmove(1);
 
-	ret = process_each_vg(cmd, argc, argv, LCK_VG_READ,
-			      VG_INCONSISTENT_CONTINUE,
+	ret = process_each_vg(cmd, argc, argv, 0,
 			      &last_filename, &vg_backup_single);
 
 	dm_free(last_filename);
--- LVM2/tools/vgchange.c	2009/06/05 20:00:52	1.73
+++ LVM2/tools/vgchange.c	2009/07/01 17:00:52	1.74
@@ -521,15 +521,13 @@
 }
 
 static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
-			   struct volume_group *vg, int consistent,
+			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
 	int r = ECMD_FAILED;
 
-	if (!(vg_status(vg) & LVM_WRITE) && !arg_count(cmd, available_ARG)) {
-		log_error("Volume group \"%s\" is read-only", vg->name);
+	if (vg_read_error(vg))
 		return ECMD_FAILED;
-	}
 
 	if (vg_status(vg) & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg_name);
@@ -620,7 +618,7 @@
 
 	return process_each_vg(cmd, argc, argv,
 			       (arg_count(cmd, available_ARG)) ?
-			       LCK_VG_READ : LCK_VG_WRITE,
-			       VG_INCONSISTENT_REPAIR, NULL,
+			       0 : READ_FOR_UPDATE,
+			       NULL,
 			       &vgchange_single);
 }
--- LVM2/tools/vgck.c	2009/06/05 20:00:52	1.21
+++ LVM2/tools/vgck.c	2009/07/01 17:00:52	1.22
@@ -18,7 +18,7 @@
 
 static int vgck_single(struct cmd_context *cmd __attribute((unused)),
 		       const char *vg_name,
-		       struct volume_group *vg, int consistent,
+		       struct volume_group *vg,
 		       void *handle __attribute((unused)))
 {
 	if (!vg_check_status(vg, EXPORTED_VG))
@@ -32,7 +32,6 @@
 
 int vgck(struct cmd_context *cmd, int argc, char **argv)
 {
-	return process_each_vg(cmd, argc, argv, LCK_VG_READ,
-			       VG_INCONSISTENT_ABORT, NULL,
+	return process_each_vg(cmd, argc, argv, 0, NULL,
 			       &vgck_single);
 }
--- LVM2/tools/vgconvert.c	2009/06/05 20:00:52	1.35
+++ LVM2/tools/vgconvert.c	2009/07/01 17:00:52	1.36
@@ -16,7 +16,7 @@
 #include "tools.h"
 
 static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
-			    struct volume_group *vg, int consistent,
+			    struct volume_group *vg,
 			    void *handle __attribute((unused)))
 {
 	struct physical_volume *pv, *existing_pv;
@@ -32,6 +32,9 @@
 	struct lvinfo info;
 	int active = 0;
 
+	if (vg_read_error(vg))
+		return ECMD_FAILED;
+
 	if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
 		return ECMD_FAILED;
 
@@ -220,7 +223,6 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	return process_each_vg(cmd, argc, argv, LCK_VG_WRITE,
-			       VG_INCONSISTENT_REPAIR, NULL,
+	return process_each_vg(cmd, argc, argv, READ_FOR_UPDATE, NULL,
 			       &vgconvert_single);
 }
--- LVM2/tools/vgdisplay.c	2009/06/05 20:00:52	1.23
+++ LVM2/tools/vgdisplay.c	2009/07/01 17:00:52	1.24
@@ -16,10 +16,12 @@
 #include "tools.h"
 
 static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
-			    struct volume_group *vg, int consistent,
+			    struct volume_group *vg,
 			    void *handle __attribute((unused)))
 {
 	/* FIXME Do the active check here if activevolumegroups_ARG ? */
+	if (vg_read_error(vg))
+		return ECMD_FAILED;
 
 	vg_check_status(vg, EXPORTED_VG);
 
@@ -91,8 +93,7 @@
 	}
 **********/
 
-	return process_each_vg(cmd, argc, argv, LCK_VG_READ,
-			       VG_INCONSISTENT_CONTINUE, NULL,
+	return process_each_vg(cmd, argc, argv, 0, NULL,
 			       vgdisplay_single);
 
 /******** FIXME Need to count number processed
--- LVM2/tools/vgexport.c	2009/06/05 20:00:52	1.20
+++ LVM2/tools/vgexport.c	2009/07/01 17:00:52	1.21
@@ -17,15 +17,14 @@
 
 static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
 			   const char *vg_name,
-			   struct volume_group *vg, int consistent,
+			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
 	struct pv_list *pvl;
 	struct physical_volume *pv;
 
-	if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE)) {
+	if (vg_read_error(vg))
 		goto error;
-	}
 
 	if (lvs_in_vg_activated(vg)) {
 		log_error("Volume group \"%s\" has active logical volumes",
@@ -68,7 +67,6 @@
 		return ECMD_FAILED;
 	}
 
-	return process_each_vg(cmd, argc, argv, LCK_VG_WRITE,
-			       VG_INCONSISTENT_ABORT, NULL,
+	return process_each_vg(cmd, argc, argv, READ_FOR_UPDATE, NULL,
 			       &vgexport_single);
 }
--- LVM2/tools/vgimport.c	2009/06/05 20:00:52	1.19
+++ LVM2/tools/vgimport.c	2009/07/01 17:00:52	1.20
@@ -17,12 +17,15 @@
 
 static int vgimport_single(struct cmd_context *cmd __attribute((unused)),
 			   const char *vg_name,
-			   struct volume_group *vg, int consistent,
+			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
 	struct pv_list *pvl;
 	struct physical_volume *pv;
 
+	if (vg_read_error(vg))
+		goto error;
+
 	if (!(vg_status(vg) & EXPORTED_VG)) {
 		log_error("Volume group \"%s\" is not exported", vg_name);
 		goto error;
@@ -68,7 +71,8 @@
 		return ECMD_FAILED;
 	}
 
-	return process_each_vg(cmd, argc, argv, LCK_VG_WRITE,
-			       VG_INCONSISTENT_ABORT, NULL,
+	return process_each_vg(cmd, argc, argv,
+			       READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
+			       NULL,
 			       &vgimport_single);
 }
--- LVM2/tools/vgremove.c	2009/06/05 20:00:52	1.48
+++ LVM2/tools/vgremove.c	2009/07/01 17:00:52	1.49
@@ -16,10 +16,10 @@
 #include "tools.h"
 
 static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
-			   struct volume_group *vg, int consistent,
+			   struct volume_group *vg,
 			   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;
 
@@ -40,10 +40,8 @@
 		return ECMD_FAILED;
 	}
 
-	ret = process_each_vg(cmd, argc, argv, LCK_VG_WRITE,
-			      arg_count(cmd, force_ARG) ?
-			      VG_INCONSISTENT_REPAIR :
-			      VG_INCONSISTENT_ABORT,
+	ret = process_each_vg(cmd, argc, argv,
+			      READ_FOR_UPDATE | LOCK_NONBLOCKING,
 			      NULL, &vgremove_single);
 
 	unlock_vg(cmd, VG_ORPHANS);
--- LVM2/tools/vgscan.c	2009/06/05 20:00:52	1.33
+++ LVM2/tools/vgscan.c	2009/07/01 17:00:52	1.34
@@ -16,9 +16,12 @@
 #include "tools.h"
 
 static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
-			 struct volume_group *vg, int consistent,
+			 struct volume_group *vg,
 			 void *handle __attribute((unused)))
 {
+	if (vg_read_error(vg))
+		return ECMD_FAILED;
+
 	log_print("Found %svolume group \"%s\" using metadata type %s",
 		  (vg_status(vg) & EXPORTED_VG) ? "exported " : "", vg_name,
 		  vg->fid->fmt->name);
@@ -47,8 +50,7 @@
 
 	log_print("Reading all physical volumes.  This may take a while...");
 
-	maxret = process_each_vg(cmd, argc, argv, LCK_VG_READ,
-				 VG_INCONSISTENT_REPAIR, NULL,
+	maxret = process_each_vg(cmd, argc, argv, 0, NULL,
 				 &vgscan_single);
 
 	if (arg_count(cmd, mknodes_ARG)) {


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2008-06-24 20:10 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2008-06-24 20:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-06-24 20:10:32

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : pvcreate.c vgconvert.c 

Log message:
	Refactor pv_create() to take cmd_context - no functional change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.182&r2=1.183
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28

--- LVM2/lib/metadata/metadata-exported.h	2008/04/23 14:33:05	1.48
+++ LVM2/lib/metadata/metadata-exported.h	2008/06/24 20:10:31	1.49
@@ -347,7 +347,7 @@
 
 /* pe_start and pe_end relate to any existing data so that new metadata
 * areas can avoid overlap */
-pv_t *pv_create(const struct format_type *fmt,
+pv_t *pv_create(const struct cmd_context *cmd,
 		      struct device *dev,
 		      struct id *id,
 		      uint64_t size,
--- LVM2/lib/metadata/metadata.c	2008/06/23 19:04:34	1.182
+++ LVM2/lib/metadata/metadata.c	2008/06/24 20:10:31	1.183
@@ -747,7 +747,7 @@
  * Note:
  *   FIXME - liblvm todo - tidy up arguments for external use (fmt, mdas, etc)
  */
-pv_t *pv_create(const struct format_type *fmt,
+pv_t *pv_create(const struct cmd_context *cmd,
 		struct device *dev,
 		struct id *id, uint64_t size,
 		uint64_t pe_start,
@@ -756,7 +756,7 @@
 		int pvmetadatacopies,
 		uint64_t pvmetadatasize, struct list *mdas)
 {
-	return _pv_create(fmt, dev, id, size, pe_start,
+	return _pv_create(cmd->fmt, dev, id, size, pe_start,
 			  existing_extent_count,
 			  existing_extent_size,
 			  pvmetadatacopies,
--- LVM2/tools/pvcreate.c	2008/04/08 12:49:21	1.62
+++ LVM2/tools/pvcreate.c	2008/06/24 20:10:32	1.63
@@ -225,7 +225,7 @@
 	}
 
 	list_init(&mdas);
-	if (!(pv = pv_create(cmd->fmt, dev, idp, size, pe_start,
+	if (!(pv = pv_create(cmd, dev, idp, size, pe_start,
 			     extent_count, extent_size,
 			     pvmetadatacopies, pvmetadatasize, &mdas))) {
 		log_error("Failed to setup physical volume \"%s\"", pv_name);
--- LVM2/tools/vgconvert.c	2007/11/14 00:08:25	1.27
+++ LVM2/tools/vgconvert.c	2008/06/24 20:10:32	1.28
@@ -112,7 +112,7 @@
 		    + pe_start - 1;
 
 		list_init(&mdas);
-		if (!(pv = pv_create(cmd->fmt, pv_dev(existing_pv),
+		if (!(pv = pv_create(cmd, pv_dev(existing_pv),
 				     &existing_pv->id, size,
 				     pe_start, pv_pe_count(existing_pv),
 				     pv_pe_size(existing_pv), pvmetadatacopies,


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2008-01-16 19:54 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2008-01-16 19:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-01-16 19:54:39

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	test           : t-vgsplit-operation.sh 
	tools          : toollib.c vgmerge.c vgsplit.c 
Added files:
	test           : t-vgmerge-usage.sh 

Log message:
	Create vgs_are_compatible() fn to check whether vgs are compatible for merging.
	Add new vgmerge and vgsplit tests to check rejection of incompatible vgs.
	Cleanup comments.
	Bugzilla: bz251992
	
	---
	lib/metadata/metadata-exported.h |    3 +
	lib/metadata/metadata.c          |   89 +++++++++++++++++++++++++++++++++-
	test/t-vgmerge-usage.sh          |  101 +++++++++++++++++++++++++++++++++++++++
	test/t-vgsplit-operation.sh      |   20 +++++++
	tools/vgmerge.c                  |   69 --------------------------
	tools/vgsplit.c                  |    5 -
	6 files changed, 215 insertions(+), 72 deletions(-)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.149&r2=1.150
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgmerge-usage.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46

--- LVM2/lib/metadata/metadata-exported.h	2008/01/16 19:13:51	1.36
+++ LVM2/lib/metadata/metadata-exported.h	2008/01/16 19:54:39	1.37
@@ -317,6 +317,9 @@
 int is_pv(pv_t *pv);
 int is_orphan_vg(const char *vg_name);
 int is_orphan(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,
--- LVM2/lib/metadata/metadata.c	2008/01/16 18:15:26	1.149
+++ LVM2/lib/metadata/metadata.c	2008/01/16 19:54:39	1.150
@@ -429,8 +429,8 @@
 
 /*
  * Validate parameters to vg_create() before calling.
- * FIXME: move this inside the library, maybe inside vg_create
- * - TODO: resolve error codes
+ * FIXME: Move inside vg_create library function.
+ * FIXME: Change vgcreate_params struct to individual gets/sets
  */
 int validate_vg_create_params(struct cmd_context *cmd,
 			      struct vgcreate_params *vp)
@@ -1084,6 +1084,91 @@
 	return 1;
 }
 
+
+/*
+ * Determine whether two vgs are compatible for merging.
+ */
+int vgs_are_compatible(struct cmd_context *cmd,
+		       struct volume_group *vg_from,
+		       struct volume_group *vg_to)
+{
+	struct lv_list *lvl1, *lvl2;
+	struct pv_list *pvl;
+
+	if (lvs_in_vg_activated(vg_from)) {
+		log_error("Logical volumes in \"%s\" must be inactive",
+			  vg_from->name);
+		goto error;
+	}
+
+	/* Check compatibility */
+	if (vg_to->extent_size != vg_from->extent_size) {
+		log_error("Extent sizes differ: %d (%s) and %d (%s)",
+			  vg_to->extent_size, vg_to->name,
+			  vg_from->extent_size, vg_from->name);
+		goto error;
+	}
+
+	if (vg_to->max_pv &&
+	    (vg_to->max_pv < vg_to->pv_count + vg_from->pv_count)) {
+		log_error("Maximum number of physical volumes (%d) exceeded "
+			  " for \"%s\" and \"%s\"", vg_to->max_pv, vg_to->name,
+			  vg_from->name);
+		goto error;
+	}
+
+	if (vg_to->max_lv &&
+	    (vg_to->max_lv < vg_to->lv_count + vg_from->lv_count)) {
+		log_error("Maximum number of logical volumes (%d) exceeded "
+			  " for \"%s\" and \"%s\"", vg_to->max_lv, vg_to->name,
+			  vg_from->name);
+		goto error;
+	}
+
+	/* Check no conflicts with LV names */
+	list_iterate_items(lvl1, &vg_to->lvs) {
+		char *name1 = lvl1->lv->name;
+
+		list_iterate_items(lvl2, &vg_from->lvs) {
+			char *name2 = lvl2->lv->name;
+
+			if (!strcmp(name1, name2)) {
+				log_error("Duplicate logical volume "
+					  "name \"%s\" "
+					  "in \"%s\" and \"%s\"",
+					  name1, vg_to->name, vg_from->name);
+				goto error;
+			}
+		}
+	}
+
+	/* Check no PVs are constructed from either VG */
+	list_iterate_items(pvl, &vg_to->pvs) {
+		if (pv_uses_vg(pvl->pv, vg_from)) {
+			log_error("Physical volume %s might be constructed "
+				  "from same volume group %s.",
+				  pv_dev_name(pvl->pv), vg_from->name);
+			goto error;
+		}
+	}
+
+	list_iterate_items(pvl, &vg_from->pvs) {
+		if (pv_uses_vg(pvl->pv, vg_to)) {
+			log_error("Physical volume %s might be constructed "
+				  "from same volume group %s.",
+				  pv_dev_name(pvl->pv), vg_to->name);
+			goto error;
+		}
+	}
+
+	return 1;
+
+error:
+	return 0;
+}
+
+
+
 int vg_validate(struct volume_group *vg)
 {
 	struct pv_list *pvl, *pvl2;
/cvs/lvm2/LVM2/test/t-vgmerge-usage.sh,v  -->  standard output
revision 1.1
--- LVM2/test/t-vgmerge-usage.sh
+++ -	2008-01-16 19:54:39.725157000 +0000
@@ -0,0 +1,101 @@
+#!/bin/sh
+# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+test_description='Exercise some vgmerge diagnostics'
+privileges_required_=1
+
+. ./test-lib.sh
+
+cleanup_()
+{
+  test -n "$d1" && losetup -d "$d1"
+  test -n "$d2" && losetup -d "$d2"
+  test -n "$d3" && losetup -d "$d3"
+  test -n "$d4" && losetup -d "$d4"
+  rm -f "$f1" "$f2" "$f3" "$f4"
+}
+
+test_expect_success \
+  'set up temp files, loopback devices, PVs, vgnames' \
+  'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
+   f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
+   f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
+   f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
+   vg1=$(this_test_)-test-vg1-$$          &&
+   vg2=$(this_test_)-test-vg2-$$          &&
+   pvcreate $d1 $d2 $d3 $d4'
+
+test_expect_success \
+  'vgmerge normal operation' \
+  'vgcreate $vg1 $d1 $d2 &&
+   vgcreate $vg2 $d3 $d4 &&
+   vgmerge $vg1 $vg2 &&
+   vgremove $vg1'
+
+test_expect_success \
+  'vgmerge rejects duplicate vg name' \
+  'vgcreate $vg1 $d1 $d2 &&
+   vgcreate $vg2 $d3 $d4 &&
+   vgmerge $vg1 $vg1 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Duplicate volume group name \"$vg1\"\$" err &&
+   vgremove $vg2 &&
+   vgremove $vg1'
+
+test_expect_success \
+  'vgmerge rejects vgs with incompatible extent_size' \
+  'vgcreate --physicalextentsize 4M $vg1 $d1 $d2 &&
+   vgcreate --physicalextentsize 8M $vg2 $d3 $d4 &&
+   vgmerge $vg1 $vg2 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Extent sizes differ" err &&
+   vgremove $vg2 &&
+   vgremove $vg1'
+
+test_expect_success \
+  'vgmerge rejects vgmerge because max_pv is exceeded' \
+  'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 &&
+   vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 &&
+   vgmerge $vg1 $vg2 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Maximum number of physical volumes (2) exceeded" err &&
+   vgremove $vg2 &&
+   vgremove $vg1'
+
+# FIXME: error with device mapper
+#test_expect_success \
+#  'vgmerge rejects vgmerge because max_lv is exceeded' \
+#  'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 &&
+#   vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 &&
+#   lvcreate -l 4 -n lv1 $vg1 &&
+#   lvcreate -l 4 -n lv2 $vg1 &&
+#   lvcreate -l 4 -n lv3 $vg2 &&
+#   vgmerge $vg1 $vg2 2>err;
+#   status=$?; echo status=$?; test $status = 5 &&
+#   grep "^  Maximum number of logical volumes (2) exceeded" err &&
+#   vgremove $vg2 &&
+#   vgremove $vg1'
+
+#test_expect_success \
+#  'vgmerge rejects vg with active lv' \
+#  'vgcreate $vg1 $d1 $d2 &&
+#   vgcreate $vg2 $d3 $d4 &&
+#   lvcreate -l 64 -n lv1 $vg1 &&
+#   vgmerge $vg1 $vg1 2>err;
+#   status=$?; echo status=$?; test $status = 5 &&
+#   grep "^  Logical volumes in \"$vg1\" must be inactive\$" err &&
+#   vgremove -f $vg2 &&
+#   vgremove -f $vg1'
+
+test_done
+# Local Variables:
+# indent-tabs-mode: nil
+# End:
--- LVM2/test/t-vgsplit-operation.sh	2008/01/14 21:07:58	1.2
+++ LVM2/test/t-vgsplit-operation.sh	2008/01/16 19:54:39	1.3
@@ -78,6 +78,26 @@
    vgremove $vg1 &&
    vgremove $vg2'
 
+test_expect_success \
+  'vgsplit rejects vgs with incompatible extent_size' \
+  'vgcreate --physicalextentsize 4M $vg1 $d1 $d2 &&
+   vgcreate --physicalextentsize 8M $vg2 $d3 $d4 &&
+   vgsplit $vg1 $vg2 $d1 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Extent sizes differ" err &&
+   vgremove $vg2 &&
+   vgremove $vg1'
+
+test_expect_success \
+  'vgsplit rejects split because max_pv of destination would be exceeded' \
+  'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 &&
+   vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 &&
+   vgsplit $vg1 $vg2 $d1 2>err;
+   status=$?; echo status=$?; test $status = 5 &&
+   grep "^  Maximum number of physical volumes (2) exceeded" err &&
+   vgremove $vg2 &&
+   vgremove $vg1'
+
 test_done
 # Local Variables:
 # indent-tabs-mode: nil
--- LVM2/tools/toollib.c	2008/01/16 18:15:26	1.126
+++ LVM2/tools/toollib.c	2008/01/16 19:54:39	1.127
@@ -1247,8 +1247,7 @@
  * Set members of struct vgcreate_params from cmdline.
  * Do preliminary validation with arg_*() interface.
  * Further, more generic validation is done in validate_vgcreate_params().
- * This function is to remain in tools directory, while
- * validate_vgcreate_params() will be moved into the LVM library.
+ * This function is to remain in tools directory.
  */
 int fill_vg_create_params(struct cmd_context *cmd,
 			  char *vg_name, struct vgcreate_params *vp_new,
--- LVM2/tools/vgmerge.c	2007/11/15 02:20:03	1.42
+++ LVM2/tools/vgmerge.c	2008/01/16 19:54:39	1.43
@@ -20,8 +20,6 @@
 {
 	struct volume_group *vg_to, *vg_from;
 	struct lv_list *lvl1, *lvl2;
-	struct pv_list *pvl;
-	int active;
 
 	if (!strcmp(vg_name_to, vg_name_from)) {
 		log_error("Duplicate volume group name \"%s\"", vg_name_from);
@@ -43,71 +41,8 @@
 		return ECMD_FAILED;
 	}
 
-	if ((active = lvs_in_vg_activated(vg_from))) {
-		log_error("Logical volumes in \"%s\" must be inactive",
-			  vg_name_from);
-		goto error;
-	}
-
-	/* Check compatibility */
-	if (vg_to->extent_size != vg_from->extent_size) {
-		log_error("Extent sizes differ: %d (%s) and %d (%s)",
-			  vg_to->extent_size, vg_to->name,
-			  vg_from->extent_size, vg_from->name);
-		goto error;
-	}
-
-	if (vg_to->max_pv &&
-	    (vg_to->max_pv < vg_to->pv_count + vg_from->pv_count)) {
-		log_error("Maximum number of physical volumes (%d) exceeded "
-			  " for \"%s\" and \"%s\"", vg_to->max_pv, vg_to->name,
-			  vg_from->name);
-		goto error;
-	}
-
-	if (vg_to->max_lv &&
-	    (vg_to->max_lv < vg_to->lv_count + vg_from->lv_count)) {
-		log_error("Maximum number of logical volumes (%d) exceeded "
-			  " for \"%s\" and \"%s\"", vg_to->max_lv, vg_to->name,
-			  vg_from->name);
-		goto error;
-	}
-
-	/* Check no conflicts with LV names */
-	list_iterate_items(lvl1, &vg_to->lvs) {
-		char *name1 = lvl1->lv->name;
-
-		list_iterate_items(lvl2, &vg_from->lvs) {
-			char *name2 = lvl2->lv->name;
-
-			if (!strcmp(name1, name2)) {
-				log_error("Duplicate logical volume "
-					  "name \"%s\" "
-					  "in \"%s\" and \"%s\"",
-					  name1, vg_to->name, vg_from->name);
-				goto error;
-			}
-		}
-	}
-
-	/* Check no PVs are constructed from either VG */
-	list_iterate_items(pvl, &vg_to->pvs) {
-		if (pv_uses_vg(pvl->pv, vg_from)) {
-			log_error("Physical volume %s might be constructed "
-				  "from same volume group %s.",
-				  pv_dev_name(pvl->pv), vg_from->name);
-			goto error;
-		}
-	}
-
-	list_iterate_items(pvl, &vg_from->pvs) {
-		if (pv_uses_vg(pvl->pv, vg_to)) {
-			log_error("Physical volume %s might be constructed "
-				  "from same volume group %s.",
-				  pv_dev_name(pvl->pv), vg_to->name);
-			goto error;
-		}
-	}
+	if (!vgs_are_compatible(cmd, vg_from, vg_to))
+	    goto error;
 
 	/* FIXME List arg: vg_show_with_pv_and_lv(vg_to); */
 
--- LVM2/tools/vgsplit.c	2008/01/15 22:56:30	1.45
+++ LVM2/tools/vgsplit.c	2008/01/16 19:54:39	1.46
@@ -254,7 +254,8 @@
 				      LCK_VG_WRITE | LCK_NONBLOCK,
 				      0, 0))) {
 		log_warn("Volume group \"%s\" already exists", vg_name_to);
-		/* FIXME: check compatibility with existing vg, esp attribs */
+		if (!vgs_are_compatible(cmd, vg_from,vg_to))
+			goto error;
 	} else {
 
 		/* Set metadata format of original VG */
@@ -274,8 +275,6 @@
 		if (validate_vg_create_params(cmd, &vp_new))
 			return EINVALID_CMD_LINE;
 
-		/* Create new VG structure */
-		/* FIXME: allow user input same params as to vgcreate tool */
 		if (!(vg_to = vg_create(cmd, vg_name_to, vp_new.extent_size,
 					vp_new.max_pv, vp_new.max_lv,
 					vp_new.alloc, 0, NULL)))


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2008-01-15 22:56 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2008-01-15 22:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-01-15 22:56:30

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : toollib.c toollib.h vgcreate.c vgrename.c 
	                 vgsplit.c 
Added files:
	test           : t-vgrename-usage.sh 

Log message:
	Move more parameter validation into the library.
	Update vgrename to call validate_vg_rename_params().
	Fix vgcreate and vgsplit default arguments by adding defaults parameter to
	fill_vg_create_params().
	Add t-vgrename-usage.sh test.
	Bugzilla: bz251992
	---
	tools/toollib.c  |   32 ++++++++------------------------
	tools/toollib.h  |    5 ++---
	tools/vgcreate.c |   35 +++++++++++++++++++++--------------
	tools/vgrename.c |   35 ++++++-----------------------------
	tools/vgsplit.c  |   21 ++++++++++++++-------
	5 files changed, 51 insertions(+), 77 deletions(-)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.147&r2=1.148
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgrename-usage.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45

--- LVM2/lib/metadata/metadata-exported.h	2008/01/14 21:07:58	1.32
+++ LVM2/lib/metadata/metadata-exported.h	2008/01/15 22:56:30	1.33
@@ -540,4 +540,7 @@
 int validate_vg_create_params(struct cmd_context *cmd,
 			      struct vgcreate_params *vp);
 
+int validate_vg_rename_params(struct cmd_context *cmd,
+			      const char *vg_name_old,
+			      const char *vg_name_new);
 #endif
--- LVM2/lib/metadata/metadata.c	2008/01/14 21:07:58	1.147
+++ LVM2/lib/metadata/metadata.c	2008/01/15 22:56:30	1.148
@@ -18,6 +18,7 @@
 #include "metadata.h"
 #include "toolcontext.h"
 #include "lvm-string.h"
+#include "lvm-file.h"
 #include "lvmcache.h"
 #include "memlock.h"
 #include "str_list.h"
@@ -227,6 +228,54 @@
 	return 0;
 }
 
+static int validate_new_vg_name(struct cmd_context *cmd, const char *vg_name)
+{
+	char vg_path[PATH_MAX];
+
+	if (!validate_name(vg_name))
+		return 0;
+
+	snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
+	if (path_exists(vg_path)) {
+		log_error("%s: already exists in filesystem", vg_path);
+		return 0;
+	}
+
+	return 1;
+}
+
+
+int validate_vg_rename_params(struct cmd_context *cmd,
+			      const char *vg_name_old,
+			      const char *vg_name_new)
+{
+	unsigned length;
+	char *dev_dir;
+
+	dev_dir = cmd->dev_dir;
+	length = strlen(dev_dir);
+
+	/* Check sanity of new name */
+	if (strlen(vg_name_new) > NAME_LEN - length - 2) {
+		log_error("New volume group path exceeds maximum length "
+			  "of %d!", NAME_LEN - length - 2);
+		return 0;
+	}
+
+	if (!validate_new_vg_name(cmd, vg_name_new)) {
+		log_error("New volume group name \"%s\" is invalid",
+			  vg_name_new);
+		return 0;
+	}
+
+	if (!strcmp(vg_name_old, vg_name_new)) {
+		log_error("Old and new volume group names must differ");
+		return 0;
+	}
+
+	return 1;
+}
+
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name)
 {
/cvs/lvm2/LVM2/test/t-vgrename-usage.sh,v  -->  standard output
revision 1.1
--- LVM2/test/t-vgrename-usage.sh
+++ -	2008-01-15 22:56:31.402467000 +0000
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+test_description='Exercise some vgrename diagnostics'
+privileges_required_=1
+
+. ./test-lib.sh
+
+cleanup_()
+{
+  test -n "$d1" && losetup -d "$d1"
+  test -n "$d2" && losetup -d "$d2"
+  test -n "$d3" && losetup -d "$d3"
+  test -n "$d4" && losetup -d "$d4"
+  rm -f "$f1" "$f2" "$f3" "$f4"
+}
+
+test_expect_success \
+  'set up temp files, loopback devices, PVs, vgnames' \
+  'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") &&
+   f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") &&
+   f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") &&
+   f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") &&
+   vg1=$(this_test_)-1-$$          &&
+   vg2=$(this_test_)-2-$$          &&
+   pvcreate $d1 $d2 $d3 $d4'
+
+test_expect_success \
+  'vgrename normal operation - rename vg1 to vg2' \
+  'vgcreate $vg1 $d1 $d2 &&
+   vgrename $vg1 $vg2 &&
+   check_vg_field_ $vg2 vg_name $vg2 &&
+   vgremove $vg2'
+
+test_done
+# Local Variables:
+# indent-tabs-mode: nil
+# End:
--- LVM2/tools/toollib.c	2008/01/14 21:07:58	1.124
+++ LVM2/tools/toollib.c	2008/01/15 22:56:30	1.125
@@ -1218,23 +1218,6 @@
 	return 1;
 }
 
-int validate_new_vg_name(struct cmd_context *cmd, const char *vg_name)
-{
-	char vg_path[PATH_MAX];
-
-	if (!validate_name(vg_name))
-		return 0;
-
-	snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
-	if (path_exists(vg_path)) {
-		log_error("%s: already exists in filesystem", vg_path);
-		return 0;
-	}
-
-	return 1;
-}
-
-
 /*
  * Set members of struct vgcreate_params from cmdline.
  * Do preliminary validation with arg_*() interface.
@@ -1243,23 +1226,27 @@
  * validate_vgcreate_params() will be moved into the LVM library.
  */
 int fill_vg_create_params(struct cmd_context *cmd,
-			  char *vg_name, struct vgcreate_params *vp)
+			  char *vg_name, struct vgcreate_params *vp_new,
+			  struct vgcreate_params *vp_def)
 {
-	vp->vg_name = skip_dev_dir(cmd, vg_name, NULL);
-	vp->max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, 0);
-	vp->max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
-	vp->alloc = arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
+	vp_new->vg_name = skip_dev_dir(cmd, vg_name, NULL);
+	vp_new->max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG,
+					vp_def->max_lv);
+	vp_new->max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG,
+					vp_def->max_pv);
+	vp_new->alloc = arg_uint_value(cmd, alloc_ARG, vp_def->alloc);
 
 	/* Units of 512-byte sectors */
-	vp->extent_size =
-	    arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_PE_SIZE);
+	vp_new->extent_size =
+	    arg_uint_value(cmd, physicalextentsize_ARG, vp_def->extent_size);
 
 	if (arg_count(cmd, clustered_ARG))
-        	vp->clustered =
-			!strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y");
+        	vp_new->clustered =
+			!strcmp(arg_str_value(cmd, clustered_ARG,
+					      vp_def->clustered ? "y":"n"), "y");
 	else
 		/* Default depends on current locking type */
-		vp->clustered = locking_is_clustered();
+		vp_new->clustered = locking_is_clustered();
 
 	if (arg_sign_value(cmd, physicalextentsize_ARG, 0) == SIGN_MINUS) {
 		log_error("Physical extent size may not be negative");
@@ -1278,4 +1265,3 @@
 
 	return 0;
 }
-
--- LVM2/tools/toollib.h	2008/01/14 21:07:58	1.55
+++ LVM2/tools/toollib.h	2008/01/15 22:56:30	1.56
@@ -96,8 +96,7 @@
 
 int apply_lvname_restrictions(const char *name);
 
-int validate_new_vg_name(struct cmd_context *cmd, const char *vg_name);
-
 int fill_vg_create_params(struct cmd_context *cmd,
-			  char *vg_name, struct vgcreate_params *vp);
+			  char *vg_name, struct vgcreate_params *vp_new,
+			  struct vgcreate_params *vp_def);
 #endif
--- LVM2/tools/vgcreate.c	2008/01/14 21:07:58	1.54
+++ LVM2/tools/vgcreate.c	2008/01/15 22:56:30	1.55
@@ -17,7 +17,8 @@
 
 int vgcreate(struct cmd_context *cmd, int argc, char **argv)
 {
-	struct vgcreate_params vp;
+	struct vgcreate_params vp_new;
+	struct vgcreate_params vp_def;
 	struct volume_group *vg;
 	const char *tag;
 
@@ -32,23 +33,29 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	if (fill_vg_create_params(cmd, argv[0], &vp))
+	vp_def.vg_name = NULL;
+	vp_def.extent_size = DEFAULT_PE_SIZE;
+	vp_def.max_pv = 0;
+	vp_def.max_lv = 0;
+	vp_def.alloc = ALLOC_NORMAL;
+	vp_def.clustered = 0;
+	if (fill_vg_create_params(cmd, argv[0], &vp_new, &vp_def))
 		return EINVALID_CMD_LINE;
 
-	if (validate_vg_create_params(cmd, &vp))
+	if (validate_vg_create_params(cmd, &vp_new))
 	    return EINVALID_CMD_LINE;
 
 	/* Create the new VG */
-	if (!(vg = vg_create(cmd, vp.vg_name, vp.extent_size, vp.max_pv,
-			     vp.max_lv, vp.alloc,
+	if (!(vg = vg_create(cmd, vp_new.vg_name, vp_new.extent_size,
+			     vp_new.max_pv, vp_new.max_lv, vp_new.alloc,
 			     argc - 1, argv + 1)))
 		return ECMD_FAILED;
 
-	if (vp.max_lv != vg->max_lv)
+	if (vp_new.max_lv != vg->max_lv)
 		log_warn("WARNING: Setting maxlogicalvolumes to %d "
 			 "(0 means unlimited)", vg->max_lv);
 
-	if (vp.max_pv != vg->max_pv)
+	if (vp_new.max_pv != vg->max_pv)
 		log_warn("WARNING: Setting maxphysicalvolumes to %d "
 			 "(0 means unlimited)", vg->max_pv);
 
@@ -65,13 +72,13 @@
 
 		if (!str_list_add(cmd->mem, &vg->tags, tag)) {
 			log_error("Failed to add tag %s to volume group %s",
-				  tag, vp.vg_name);
+				  tag, vp_new.vg_name);
 			return ECMD_FAILED;
 		}
 	}
 
 	/* FIXME: move this inside vg_create? */
-	if (vp.clustered)
+	if (vp_new.clustered)
 		vg->status |= CLUSTERED;
 	else
 		vg->status &= ~CLUSTERED;
@@ -81,26 +88,26 @@
 		return ECMD_FAILED;
 	}
 
-	if (!lock_vol(cmd, vp.vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) {
-		log_error("Can't get lock for %s", vp.vg_name);
+	if (!lock_vol(cmd, vp_new.vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) {
+		log_error("Can't get lock for %s", vp_new.vg_name);
 		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
 	}
 
 	if (!archive(vg)) {
-		unlock_vg(cmd, vp.vg_name);
+		unlock_vg(cmd, vp_new.vg_name);
 		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
 	}
 
 	/* Store VG on disk(s) */
 	if (!vg_write(vg) || !vg_commit(vg)) {
-		unlock_vg(cmd, vp.vg_name);
+		unlock_vg(cmd, vp_new.vg_name);
 		unlock_vg(cmd, VG_ORPHANS);
 		return ECMD_FAILED;
 	}
 
-	unlock_vg(cmd, vp.vg_name);
+	unlock_vg(cmd, vp_new.vg_name);
 	unlock_vg(cmd, VG_ORPHANS);
 
 	backup(vg);
--- LVM2/tools/vgrename.c	2007/11/02 20:40:05	1.48
+++ LVM2/tools/vgrename.c	2008/01/15 22:56:30	1.49
@@ -19,7 +19,6 @@
 			  const char *new_vg_path)
 {
 	char *dev_dir;
-	unsigned length;
 	struct id id;
 	int consistent = 1;
 	int match = 0;
@@ -35,25 +34,9 @@
 	vg_name_new = skip_dev_dir(cmd, new_vg_path, NULL);
 
 	dev_dir = cmd->dev_dir;
-	length = strlen(dev_dir);
 
-	/* Check sanity of new name */
-	if (strlen(vg_name_new) > NAME_LEN - length - 2) {
-		log_error("New volume group path exceeds maximum length "
-			  "of %d!", NAME_LEN - length - 2);
+	if (!validate_vg_rename_params(cmd, vg_name_old, vg_name_new))
 		return 0;
-	}
-
-	if (!validate_new_vg_name(cmd, vg_name_new)) {
-		log_error("New volume group name \"%s\" is invalid",
-			  vg_name_new);
-		return 0;
-	}
-
-	if (!strcmp(vg_name_old, vg_name_new)) {
-		log_error("Old and new volume group names must differ");
-		return 0;
-	}
 
 	log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
 
--- LVM2/tools/vgsplit.c	2008/01/14 21:07:58	1.44
+++ LVM2/tools/vgsplit.c	2008/01/15 22:56:30	1.45
@@ -212,7 +212,8 @@
 
 int vgsplit(struct cmd_context *cmd, int argc, char **argv)
 {
-	struct vgcreate_params vp;
+	struct vgcreate_params vp_new;
+	struct vgcreate_params vp_def;
 	char *vg_name_from, *vg_name_to;
 	struct volume_group *vg_to, *vg_from;
 	int opt;
@@ -260,18 +261,24 @@
 		/* FIXME: need some common logic */
 		cmd->fmt = vg_from->fid->fmt;
 
-		/* FIXME: original code took defaults from vg_from */
-		if (fill_vg_create_params(cmd, vg_name_to, &vp))
+		vp_def.vg_name = NULL;
+		vp_def.extent_size = vg_from->extent_size;
+		vp_def.max_pv = vg_from->max_pv;
+		vp_def.max_lv = vg_from->max_lv;
+		vp_def.alloc = vg_from->alloc;
+		vp_def.clustered = 0;
+
+		if (fill_vg_create_params(cmd, vg_name_to, &vp_new, &vp_def))
 			return EINVALID_CMD_LINE;
 
-		if (validate_vg_create_params(cmd, &vp))
+		if (validate_vg_create_params(cmd, &vp_new))
 			return EINVALID_CMD_LINE;
 
 		/* Create new VG structure */
 		/* FIXME: allow user input same params as to vgcreate tool */
-		if (!(vg_to = vg_create(cmd, vg_name_to, vp.extent_size,
-					vp.max_pv, vp.max_lv,
-					vp.alloc, 0, NULL)))
+		if (!(vg_to = vg_create(cmd, vg_name_to, vp_new.extent_size,
+					vp_new.max_pv, vp_new.max_lv,
+					vp_new.alloc, 0, NULL)))
 			goto error;
 
 		if (vg_from->status & CLUSTERED)


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2007-12-22  2:13 agk
  0 siblings, 0 replies; 41+ messages in thread
From: agk @ 2007-12-22  2:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-12-22 02:13:00

Modified files:
	lib/metadata   : metadata-exported.h mirror.c 
	lib/report     : report.c 
	man            : lvs.8 
	tools          : lvconvert.c lvcreate.c toollib.c 

Log message:
	a few more changes/fixes to recent code

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122

--- LVM2/lib/metadata/metadata-exported.h	2007/12/20 22:37:42	1.28
+++ LVM2/lib/metadata/metadata-exported.h	2007/12/22 02:12:59	1.29
@@ -41,6 +41,9 @@
 #define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 #define MAX_RESTRICTED_LVS 255	/* Used by FMT_RESTRICTED_LVIDS */
 
+/* Layer suffix */
+#define MIRROR_SYNC_LAYER "_mimagetmp"
+
 /* Various flags */
 /* Note that the bits no longer necessarily correspond to LVM1 disk format */
 
--- LVM2/lib/metadata/mirror.c	2007/12/20 23:12:27	1.49
+++ LVM2/lib/metadata/mirror.c	2007/12/22 02:12:59	1.50
@@ -1030,7 +1030,8 @@
 static struct logical_volume *_create_mirror_log(struct logical_volume *lv,
 						 struct alloc_handle *ah,
 						 alloc_policy_t alloc,
-						 const char *lv_name)
+						 const char *lv_name,
+						 const char *suffix)
 {
 	struct logical_volume *log_lv;
 	char *log_name;
@@ -1042,7 +1043,7 @@
 		return NULL;
 	}
 
-	if (dm_snprintf(log_name, len, "%s_mlog", lv->name) < 0) {
+	if (dm_snprintf(log_name, len, "%s%s", lv->name, suffix) < 0) {
 		log_error("log_name allocation failed.");
 		return NULL;
 	}
@@ -1075,7 +1076,9 @@
 		return NULL;
 	}
 
-	if (!(log_lv = _create_mirror_log(lv, ah, alloc, lv->name))) {
+	if (!(log_lv = _create_mirror_log(lv, ah, alloc, lv->name,
+					  strstr(lv->name, MIRROR_SYNC_LAYER)
+						? "_mlogtmp_%d" : "_mlog"))) {
 		log_error("Failed to create mirror log.");
 		return NULL;
 	}
--- LVM2/lib/report/report.c	2007/12/20 16:49:37	1.69
+++ LVM2/lib/report/report.c	2007/12/22 02:12:59	1.70
@@ -272,6 +272,24 @@
 	return dm_report_field_uint64(rh, field, &_minusone);
 }
 
+static int _lv_mimage_in_sync(struct logical_volume *lv)
+{
+	float percent;
+	struct lv_segment *seg = first_seg(lv);
+
+	if (!(lv->status & MIRROR_IMAGE) || !seg->mirror_seg)
+		return_0;
+
+	if (!lv_mirror_percent(lv->vg->cmd, seg->mirror_seg->lv, 0,
+			       &percent, NULL))
+		return_0;
+
+	if (percent >= 100.0)
+		return 1;
+
+	return 0;
+}
+
 static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
 			  struct dm_report_field *field,
 			  const void *data, void *private __attribute((unused)))
@@ -294,7 +312,10 @@
 		else
 			repstr[0] = 'm';
 	}else if (lv->status & MIRROR_IMAGE)
-		repstr[0] = 'i';
+		if (_lv_mimage_in_sync(lv))
+			repstr[0] = 'i';
+		else
+			repstr[0] = 'I';
 	else if (lv->status & MIRROR_LOG)
 		repstr[0] = 'l';
 	else if (lv->status & VIRTUAL)
--- LVM2/man/lvs.8	2007/03/27 13:35:33	1.6
+++ LVM2/man/lvs.8	2007/12/22 02:12:59	1.7
@@ -47,7 +47,7 @@
 .RS
 .IP 1 3
 Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (p)vmove, (s)napshot, 
-invalid (S)napshot, (v)irtual
+invalid (S)napshot, (v)irtual, mirror (i)mage, mirror (I)mage out-of-sync
 .IP 2 3
 Permissions: (w)riteable, (r)ead-only
 .IP 3 3
--- LVM2/tools/lvconvert.c	2007/12/21 01:08:18	1.50
+++ LVM2/tools/lvconvert.c	2007/12/22 02:13:00	1.51
@@ -227,6 +227,50 @@
 	return 1;
 }
 
+static int _insert_lvconvert_layer(struct cmd_context *cmd,
+				   struct logical_volume *lv)
+{
+	char *format, *layer_name;
+	size_t len;
+	int i;
+
+	/*
+ 	 * We would like to give the same number for this layer
+ 	 * and the newly added mimage.
+ 	 * However, LV name of newly added mimage is determined *after*
+	 * the LV name of this layer is determined.
+	 *
+	 * So, use generate_lv_name() to generate mimage name first
+	 * and take the number from it.
+	 */
+
+	len = strlen(lv->name) + 32;
+	if (!(format = alloca(len)) ||
+	    !(layer_name = alloca(len)) ||
+	    dm_snprintf(format, len, "%s_mimage_%%d", lv->name) < 0) {
+		log_error("lvconvert: layer name allocation failed.");
+		return 0;
+	}
+
+	if (!generate_lv_name(lv->vg, format, layer_name, len) ||
+	    sscanf(layer_name, format, &i) != 1) {
+		log_error("lvconvert: layer name generation failed.");
+		return 0;
+	}
+
+	if (dm_snprintf(layer_name, len, MIRROR_SYNC_LAYER "_%d", i) < 0) {
+		log_error("layer name allocation failed.");
+		return 0;
+	}
+
+	if (!insert_layer_for_lv(cmd, lv, 0, layer_name)) {
+		log_error("Failed to insert resync layer");
+		return 0;
+	}
+
+	return 1;
+}
+
 static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * lv,
 			     struct lvconvert_params *lp)
 {
@@ -376,9 +420,14 @@
 			return 1;
 		}
 	} else if (lp->mirrors > existing_mirrors) {
+		if (lv->status & MIRROR_NOTSYNCED) {
+			log_error("Not adding mirror to mirrored LV "
+				  "without initial resync");
+			return 0;
+		}
 		/* FIXME: can't have multiple mlogs. force corelog. */
 		corelog = 1;
-		if (!insert_layer_for_lv(cmd, lv, 0, "_resync%d")) {
+		if (!_insert_lvconvert_layer(cmd, lv)) {
 			log_error("Failed to insert resync layer");
 			return 0;
 		}
--- LVM2/tools/lvcreate.c	2007/12/20 15:42:55	1.164
+++ LVM2/tools/lvcreate.c	2007/12/22 02:13:00	1.165
@@ -525,7 +525,7 @@
 	uint32_t status = 0;
 	uint64_t tmp_size;
 	struct logical_volume *lv, *org = NULL;
-	struct list *pvh, tags;
+	struct list *pvh;
 	const char *tag = NULL;
 	int origin_active = 0;
 	char lv_name_buf[128];
@@ -744,6 +744,16 @@
 		}
 	}
 
+	if (lp->mirrors > 1) {
+		init_mirror_in_sync(lp->nosync);
+
+		if (lp->nosync) {
+			log_warn("WARNING: New mirror won't be synchronised. "
+				  "Don't read what you didn't write!");
+			status |= MIRROR_NOTSYNCED;
+		}
+	}
+
 	if (!(lv = lv_create_empty(lv_name ? lv_name : "lvol%d", NULL,
 				   status, lp->alloc, 0, vg))) {
 		stack;
@@ -774,18 +784,6 @@
 		return_0;
 
 	if (lp->mirrors > 1) {
-		init_mirror_in_sync(lp->nosync);
-
-		if (lp->nosync) {
-			log_warn("WARNING: New mirror won't be synchronised. "
-				  "Don't read what you didn't write!");
-			status |= MIRROR_NOTSYNCED;
-		}
-
-		list_init(&tags);
-		if (tag)
-			str_list_add(cmd->mem, &tags, tag);
-
 		if (!lv_add_mirrors(cmd, lv, lp->mirrors - 1, lp->stripes,
 				    adjusted_mirror_region_size(
 						vg->extent_size,
--- LVM2/tools/toollib.c	2007/12/20 22:37:42	1.121
+++ LVM2/tools/toollib.c	2007/12/22 02:13:00	1.122
@@ -1222,12 +1222,6 @@
 		return 0;
 	}
 
-	if (strstr(name, "_resync")) {
-		log_error("Names including \"_resync\" are reserved. "
-			  "Please choose a different LV name.");
-		return 0;
-	}
-
 	return 1;
 }
 


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2007-11-15 22:11 agk
  0 siblings, 0 replies; 41+ messages in thread
From: agk @ 2007-11-15 22:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-11-15 22:11:18

Modified files:
	lib/metadata   : metadata-exported.h pv_manip.c 
	tools          : pvresize.c 

Log message:
	move pvresize_single back under tools

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/pv_manip.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18

--- LVM2/lib/metadata/metadata-exported.h	2007/11/15 02:20:03	1.24
+++ LVM2/lib/metadata/metadata-exported.h	2007/11/15 22:11:18	1.25
@@ -325,10 +325,6 @@
 		      uint64_t pvmetadatasize, struct list *mdas);
 int pv_resize(struct physical_volume *pv, struct volume_group *vg,
              uint32_t new_pe_count);
-int pv_resize_single(struct cmd_context *cmd,
-		     struct volume_group *vg,
-		     struct physical_volume *pv,
-		     uint64_t new_size);
 int pv_analyze(struct cmd_context *cmd, const char *pv_name,
 	       uint64_t label_sector);
 
--- LVM2/lib/metadata/pv_manip.c	2007/11/02 20:40:04	1.17
+++ LVM2/lib/metadata/pv_manip.c	2007/11/15 22:11:18	1.18
@@ -439,157 +439,3 @@
 	else
 		return _reduce_pv(pv, vg, new_pe_count);
 }
-
-int pv_resize_single(struct cmd_context *cmd,
-		     struct volume_group *vg,
-		     struct physical_volume *pv,
-		     const uint64_t new_size)
-{
-	struct pv_list *pvl;
-	int consistent = 1;
-	uint64_t size = 0;
-	uint32_t new_pe_count = 0;
-	struct list mdas;
-	const char *pv_name = pv_dev_name(pv);
-	const char *vg_name;
-
-	list_init(&mdas);
-
-	if (is_orphan_vg(pv_vg_name(pv))) {
-		vg_name = VG_ORPHANS;
-		if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
-			log_error("Can't get lock for orphans");
-			return 0;
-		}
-
-		if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
-			unlock_vg(cmd, vg_name);
-			log_error("Unable to read PV \"%s\"", pv_name);
-			return 0;
-		}
-
-		/* FIXME Create function to test compatibility properly */
-		if (list_size(&mdas) > 1) {
-			log_error("%s: too many metadata areas for pvresize",
-				  pv_name);
-			unlock_vg(cmd, vg_name);
-			return 0;
-		}
-	} else {
-		vg_name = pv_vg_name(pv);
-
-		if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
-			log_error("Can't get lock for %s", pv_vg_name(pv));
-			return 0;
-		}
-
-		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
-			unlock_vg(cmd, vg_name);
-			log_error("Unable to find volume group of \"%s\"",
-				  pv_name);
-			return 0;
-		}
-
-		if (!vg_check_status(vg, CLUSTERED | EXPORTED_VG | LVM_WRITE)) {
-			unlock_vg(cmd, vg_name);
-			return 0;
-		}
-
-		if (!(pvl = find_pv_in_vg(vg, pv_name))) {
-			unlock_vg(cmd, vg_name);
-			log_error("Unable to find \"%s\" in volume group \"%s\"",
-				  pv_name, vg->name);
-			return 0;
-		}
-
-		pv = pvl->pv;
-
-		if (!archive(vg))
-			return 0;
-	}
-
-	if (!(pv->fmt->features & FMT_RESIZE_PV)) {
-		log_error("Physical volume %s format does not support resizing.",
-			  pv_name);
-		unlock_vg(cmd, vg_name);
-		return 0;
-	}
-
-	/* Get new size */
-	if (!dev_get_size(pv_dev(pv), &size)) {
-		log_error("%s: Couldn't get size.", pv_name);
-		unlock_vg(cmd, vg_name);
-		return 0;
-	}
-	
-	if (new_size) {
-		if (new_size > size)
-			log_warn("WARNING: %s: Overriding real size. "
-				  "You could lose data.", pv_name);
-		log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
-			    " sectors.", pv_name, new_size, pv_size(pv));
-		size = new_size;
-	}
-
-	if (size < PV_MIN_SIZE) {
-		log_error("%s: Size must exceed minimum of %ld sectors.",
-			  pv_name, PV_MIN_SIZE);
-		unlock_vg(cmd, vg_name);
-		return 0;
-	}
-
-	if (size < pv_pe_start(pv)) {
-		log_error("%s: Size must exceed physical extent start of "
-			  "%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
-		unlock_vg(cmd, vg_name);
-		return 0;
-	}
-
-	pv->size = size;
-
-	if (vg) {
-		pv->size -= pv_pe_start(pv);
-		new_pe_count = pv_size(pv) / vg->extent_size;
-		
- 		if (!new_pe_count) {
-			log_error("%s: Size must leave space for at "
-				  "least one physical extent of "
-				  "%" PRIu32 " sectors.", pv_name,
-				  pv_pe_size(pv));
-			unlock_vg(cmd, vg_name);
-			return 0;
-		}
-
-		if (!pv_resize(pv, vg, new_pe_count)) {
-			stack;
-			unlock_vg(cmd, vg_name);
-			return 0;
-		}
-	}
-
-	log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
-		    pv_name, pv_size(pv));
-
-	log_verbose("Updating physical volume \"%s\"", pv_name);
-	if (!is_orphan_vg(pv_vg_name(pv))) {
-		if (!vg_write(vg) || !vg_commit(vg)) {
-			unlock_vg(cmd, pv_vg_name(pv));
-			log_error("Failed to store physical volume \"%s\" in "
-				  "volume group \"%s\"", pv_name, vg->name);
-			return 0;
-		}
-		backup(vg);
-		unlock_vg(cmd, vg_name);
-	} else {
-		if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
-			unlock_vg(cmd, VG_ORPHANS);
-			log_error("Failed to store physical volume \"%s\"",
-				  pv_name);
-			return 0;
-		}
-		unlock_vg(cmd, vg_name);
-	}
-
-	log_print("Physical volume \"%s\" changed", pv_name);
-	return 1;
-}
--- LVM2/tools/pvresize.c	2007/11/14 18:41:05	1.17
+++ LVM2/tools/pvresize.c	2007/11/15 22:11:18	1.18
@@ -23,6 +23,160 @@
 	unsigned total;
 };
 
+int pv_resize_single(struct cmd_context *cmd,
+		     struct volume_group *vg,
+		     struct physical_volume *pv,
+		     const uint64_t new_size)
+{
+	struct pv_list *pvl;
+	int consistent = 1;
+	uint64_t size = 0;
+	uint32_t new_pe_count = 0;
+	struct list mdas;
+	const char *pv_name = pv_dev_name(pv);
+	const char *vg_name;
+
+	list_init(&mdas);
+
+	if (is_orphan_vg(pv_vg_name(pv))) {
+		vg_name = VG_ORPHANS;
+		if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+			log_error("Can't get lock for orphans");
+			return 0;
+		}
+
+		if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
+			unlock_vg(cmd, vg_name);
+			log_error("Unable to read PV \"%s\"", pv_name);
+			return 0;
+		}
+
+		/* FIXME Create function to test compatibility properly */
+		if (list_size(&mdas) > 1) {
+			log_error("%s: too many metadata areas for pvresize",
+				  pv_name);
+			unlock_vg(cmd, vg_name);
+			return 0;
+		}
+	} else {
+		vg_name = pv_vg_name(pv);
+
+		if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
+			log_error("Can't get lock for %s", pv_vg_name(pv));
+			return 0;
+		}
+
+		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
+			unlock_vg(cmd, vg_name);
+			log_error("Unable to find volume group of \"%s\"",
+				  pv_name);
+			return 0;
+		}
+
+		if (!vg_check_status(vg, CLUSTERED | EXPORTED_VG | LVM_WRITE)) {
+			unlock_vg(cmd, vg_name);
+			return 0;
+		}
+
+		if (!(pvl = find_pv_in_vg(vg, pv_name))) {
+			unlock_vg(cmd, vg_name);
+			log_error("Unable to find \"%s\" in volume group \"%s\"",
+				  pv_name, vg->name);
+			return 0;
+		}
+
+		pv = pvl->pv;
+
+		if (!archive(vg))
+			return 0;
+	}
+
+	if (!(pv->fmt->features & FMT_RESIZE_PV)) {
+		log_error("Physical volume %s format does not support resizing.",
+			  pv_name);
+		unlock_vg(cmd, vg_name);
+		return 0;
+	}
+
+	/* Get new size */
+	if (!dev_get_size(pv_dev(pv), &size)) {
+		log_error("%s: Couldn't get size.", pv_name);
+		unlock_vg(cmd, vg_name);
+		return 0;
+	}
+	
+	if (new_size) {
+		if (new_size > size)
+			log_warn("WARNING: %s: Overriding real size. "
+				  "You could lose data.", pv_name);
+		log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
+			    " sectors.", pv_name, new_size, pv_size(pv));
+		size = new_size;
+	}
+
+	if (size < PV_MIN_SIZE) {
+		log_error("%s: Size must exceed minimum of %ld sectors.",
+			  pv_name, PV_MIN_SIZE);
+		unlock_vg(cmd, vg_name);
+		return 0;
+	}
+
+	if (size < pv_pe_start(pv)) {
+		log_error("%s: Size must exceed physical extent start of "
+			  "%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
+		unlock_vg(cmd, vg_name);
+		return 0;
+	}
+
+	pv->size = size;
+
+	if (vg) {
+		pv->size -= pv_pe_start(pv);
+		new_pe_count = pv_size(pv) / vg->extent_size;
+		
+ 		if (!new_pe_count) {
+			log_error("%s: Size must leave space for at "
+				  "least one physical extent of "
+				  "%" PRIu32 " sectors.", pv_name,
+				  pv_pe_size(pv));
+			unlock_vg(cmd, vg_name);
+			return 0;
+		}
+
+		if (!pv_resize(pv, vg, new_pe_count)) {
+			stack;
+			unlock_vg(cmd, vg_name);
+			return 0;
+		}
+	}
+
+	log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
+		    pv_name, pv_size(pv));
+
+	log_verbose("Updating physical volume \"%s\"", pv_name);
+	if (!is_orphan_vg(pv_vg_name(pv))) {
+		if (!vg_write(vg) || !vg_commit(vg)) {
+			unlock_vg(cmd, pv_vg_name(pv));
+			log_error("Failed to store physical volume \"%s\" in "
+				  "volume group \"%s\"", pv_name, vg->name);
+			return 0;
+		}
+		backup(vg);
+		unlock_vg(cmd, vg_name);
+	} else {
+		if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
+			unlock_vg(cmd, VG_ORPHANS);
+			log_error("Failed to store physical volume \"%s\"",
+				  pv_name);
+			return 0;
+		}
+		unlock_vg(cmd, vg_name);
+	}
+
+	log_print("Physical volume \"%s\" changed", pv_name);
+	return 1;
+}
+
 static int _pvresize_single(struct cmd_context *cmd,
 			    struct volume_group *vg,
 			    struct physical_volume *pv,


^ permalink raw reply	[flat|nested] 41+ messages in thread

* LVM2 lib/metadata/metadata-exported.h lib/meta ...
@ 2007-07-23 21:03 wysochanski
  0 siblings, 0 replies; 41+ messages in thread
From: wysochanski @ 2007-07-23 21:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-07-23 21:03:42

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : pvmove.c vgextend.c vgmerge.c vgsplit.c 

Log message:
	Add CORRECT_INCONSISTENT and FAIL_INCONSISTENT flags to vg_lock_and_read

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33

--- LVM2/lib/metadata/metadata-exported.h	2007/07/23 17:27:54	1.2
+++ LVM2/lib/metadata/metadata-exported.h	2007/07/23 21:03:42	1.3
@@ -83,6 +83,10 @@
 #define FMT_RESIZE_PV		0x00000080U	/* Supports pvresize? */
 #define FMT_UNLIMITED_STRIPESIZE 0x00000100U	/* Unlimited stripe size? */
 
+/* LVM2 external library flags */
+#define CORRECT_INCONSISTENT    0x00000001U /* Correct inconsistent metadata */
+#define FAIL_INCONSISTENT       0x00000002U /* Fail if metadata inconsistent */
+
 /* Ordered list - see lv_manip.c */
 typedef enum {
 	ALLOC_INVALID,
@@ -293,7 +297,8 @@
 	     struct list *mdas, int64_t label_sector);
 int is_orphan(pv_t *pv);
 vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
-		       uint32_t lock_flags, uint32_t status_flags);
+		       uint32_t lock_flags, uint32_t status_flags,
+		       uint32_t misc_flags);
 
 /* pe_start and pe_end relate to any existing data so that new metadata
 * areas can avoid overlap */
--- LVM2/lib/metadata/metadata.c	2007/07/23 17:27:54	1.128
+++ LVM2/lib/metadata/metadata.c	2007/07/23 21:03:42	1.129
@@ -1798,23 +1798,29 @@
  * @vg_name - name of the volume group to lock and read
  * @lock_flags - locking flags to use
  * @status_flags - status flags to check
+ * @misc_flags - function modifier flags
  *
  * Returns:
  * NULL - failure
  * non-NULL - success; volume group handle
  */
 vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
-		       uint32_t lock_flags, uint32_t status_flags)
+		       uint32_t lock_flags, uint32_t status_flags,
+		       uint32_t misc_flags)
 {
 	struct volume_group *vg;
 	int consistent = 1;
-	
+
+	if (!(misc_flags & CORRECT_INCONSISTENT))
+		consistent = 0;
+
 	if (!lock_vol(cmd, vg_name, lock_flags)) {
 		log_error("Can't get lock for %s", vg_name);
 		return NULL;
 	}
 
-	if (!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent) {
+	if (!(vg = vg_read(cmd, vg_name, NULL, &consistent)) ||
+	    ((misc_flags & FAIL_INCONSISTENT) && !consistent)) {
 		log_error("Volume group \"%s\" not found", vg_name);
 		unlock_vg(cmd, vg_name);
 		return NULL;
--- LVM2/tools/pvmove.c	2007/07/23 17:27:55	1.39
+++ LVM2/tools/pvmove.c	2007/07/23 21:03:42	1.40
@@ -55,7 +55,8 @@
 	dev_close_all();
 
 	if (!(vg = vg_lock_and_read(cmd, vgname, LCK_VG_WRITE,
-				    CLUSTERED | EXPORTED_VG | LVM_WRITE)))
+				    CLUSTERED | EXPORTED_VG | LVM_WRITE,
+				    CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
 		 return NULL;
 
 	return vg;
--- LVM2/tools/vgextend.c	2007/07/23 17:27:55	1.32
+++ LVM2/tools/vgextend.c	2007/07/23 21:03:42	1.33
@@ -49,7 +49,8 @@
 	log_verbose("Checking for volume group \"%s\"", vg_name);
 	if (!(vg = vg_lock_and_read(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK,
 				    CLUSTERED | EXPORTED_VG | 
-				    LVM_WRITE | RESIZEABLE_VG))) {
+				    LVM_WRITE | RESIZEABLE_VG,
+				    CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
 		 unlock_vg(cmd, ORPHAN);
 		return ECMD_FAILED;
 	 }
--- LVM2/tools/vgmerge.c	2007/07/23 17:27:55	1.38
+++ LVM2/tools/vgmerge.c	2007/07/23 21:03:42	1.39
@@ -30,13 +30,15 @@
 
 	log_verbose("Checking for volume group \"%s\"", vg_name_to);
 	if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, LCK_VG_WRITE,
-				    CLUSTERED | EXPORTED_VG | LVM_WRITE)))
+				       CLUSTERED | EXPORTED_VG | LVM_WRITE,
+				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
 		 return ECMD_FAILED;
 
 	log_verbose("Checking for volume group \"%s\"", vg_name_from);
 	if (!(vg_from = vg_lock_and_read(cmd, vg_name_from,
 					 LCK_VG_WRITE | LCK_NONBLOCK,
-					 CLUSTERED | EXPORTED_VG | LVM_WRITE))) {
+					 CLUSTERED | EXPORTED_VG | LVM_WRITE,
+					 CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
 		unlock_vg(cmd, vg_name_to);
 		return ECMD_FAILED;
 	}
--- LVM2/tools/vgsplit.c	2007/07/23 17:27:55	1.32
+++ LVM2/tools/vgsplit.c	2007/07/23 21:03:42	1.33
@@ -242,7 +242,8 @@
 	log_verbose("Checking for volume group \"%s\"", vg_name_from);
 	if (!(vg_to = vg_lock_and_read(cmd, vg_name_from, LCK_VG_WRITE,
 				       CLUSTERED | EXPORTED_VG |
-				       RESIZEABLE_VG | LVM_WRITE)))
+				       RESIZEABLE_VG | LVM_WRITE,
+				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
 		 return ECMD_FAILED;
 
 	log_verbose("Checking for volume group \"%s\"", vg_name_to);


^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2011-02-21 12:29 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-12 16:41 LVM2 lib/metadata/metadata-exported.h lib/meta mornfall
  -- strict thread matches above, loose matches on Subject: below --
2011-02-21 12:29 prajnoha
2010-06-30 20:03 agk
2010-06-30 18:03 wysochanski
2010-06-29 21:32 wysochanski
2010-06-28 20:40 wysochanski
2010-02-24 18:15 wysochanski
2010-02-24 18:15 wysochanski
2010-02-14  3:21 wysochanski
2010-02-14  3:21 wysochanski
2009-11-01 20:05 wysochanski
2009-11-01 19:51 wysochanski
2009-10-31 17:30 wysochanski
2009-10-05 20:03 wysochanski
2009-10-05 20:02 wysochanski
2009-10-01  1:04 agk
2009-09-14 15:45 wysochanski
2009-09-02 21:39 wysochanski
2009-09-02 21:39 wysochanski
2009-07-28 15:14 wysochanski
2009-07-28 13:17 wysochanski
2009-07-26  2:34 wysochanski
2009-07-26  1:53 wysochanski
2009-07-15  5:50 mornfall
2009-07-14  2:15 wysochanski
2009-07-10 20:07 wysochanski
2009-07-10 20:05 wysochanski
2009-07-09 10:09 wysochanski
2009-07-09 10:08 wysochanski
2009-07-09 10:07 wysochanski
2009-07-09 10:06 wysochanski
2009-07-09 10:04 wysochanski
2009-07-09 10:03 wysochanski
2009-07-08 14:33 wysochanski
2009-07-01 17:01 wysochanski
2008-06-24 20:10 wysochanski
2008-01-16 19:54 wysochanski
2008-01-15 22:56 wysochanski
2007-12-22  2:13 agk
2007-11-15 22:11 agk
2007-07-23 21:03 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).