Skip to contentSkip to conversation

LVM2/tools pvresize.c

PATCH [email protected] 1 participant 1 message Feb 28, 2011

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2011-02-28 17:08:09

Modified files:
tools : pvresize.c

Log message:
Add a hint for manual revert if there's an error in pv_write, vg_write, vg_commit for pvresize.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43

tools/pvresize.c +6 -1
@@ -35,6 +35,7 @@
 	const char *pv_name = pv_dev_name(pv);
 	const char *vg_name = pv_vg_name(pv);
 	struct volume_group *old_vg = vg;
+	int vg_needs_pv_write = 0;
 
 	if (is_orphan_vg(vg_name)) {
 		if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
@@ -100,7 +101,8 @@
 
 	/* Write PV label only if this an orphan PV or it has 2nd mda. */
 	if ((is_orphan_vg(vg_name) ||
-	    fid_get_mda_indexed(vg->fid, (const char *) &pv->id, ID_LEN, 1)) &&
+	     (vg_needs_pv_write = (fid_get_mda_indexed(vg->fid,
+			(const char *) &pv->id, ID_LEN, 1) != NULL))) &&
 	    !pv_write(cmd, pv, 1)) {
 		log_error("Failed to store physical volume \"%s\"",
 			  pv_name);
@@ -120,6 +122,9 @@
 	r = 1;
 
 out:
+	if (!r && vg_needs_pv_write)
+		log_error("Use pvcreate and vgcfgrestore "
+			  "to repair from archived metadata.");
 	unlock_vg(cmd, vg_name);
 	if (!old_vg)
 		free_vg(vg);