Skip to contentSkip to conversation

LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ...

PATCH [email protected] 1 participant 1 message Jan 16, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2008-01-16 18:15:26

Modified files:

	.              : WHATS_NEW 
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : lvmcmdline.c pvcreate.c pvdisplay.c toollib.c 

Log message:
use scan_vgs_for_pvs to detect non-orphans without MDAs

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.762&r2=1.763
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.148&r2=1.149
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.30 -
 ===================================
+  Fix process_all_pvs to detect non-orphans with no MDAs correctly.
   Don't use block_on_error with mirror targets version 1.12 and above.
   Update vgsplit to include vgcreate-style options when new VG is destination.
   Update vgsplit to accept existing VG as destination.
lib/metadata/metadata-exported.h +1 -0
@@ -310,6 +310,7 @@
 /* Set full_scan to 1 to re-read every (filtered) device label */
 struct list *get_vgs(struct cmd_context *cmd, int full_scan);
 struct list *get_vgids(struct cmd_context *cmd, int full_scan);
+int scan_vgs_for_pvs(struct cmd_context *cmd);
 
 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
 	     struct list *mdas, int64_t label_sector);
lib/metadata/metadata.c +42 -11

89 lines not on this page · raw message

tools/lvmcmdline.c +0 -1
@@ -584,7 +584,6 @@
 		a->ui64_value = 0;
 	}
 
-	memset(str, 0, sizeof(str));
 	/* fill in the short and long opts */
 	for (i = 0; i < cmd->command->num_args; i++)
 		_add_getopt_arg(cmd->command->valid_args[i], &ptr, &o);
tools/pvcreate.c +2 -1
@@ -51,7 +51,8 @@
          * system.
 	 */
 	if (pv && is_orphan(pv)) {
-		(void) get_vgs(cmd, 1);
+		if (!scan_vgs_for_pvs(cmd))
+			return_0;
 		pv = pv_read(cmd, name, NULL, NULL, 0);
 	}
 
tools/pvdisplay.c +1 -1
@@ -26,7 +26,7 @@
 	const char *pv_name = pv_dev_name(pv);
 	const char *vg_name = NULL;
 
-	 if (!is_orphan(pv) && !vg) {
+	if (!is_orphan(pv) && !vg) {
 		vg_name = pv_vg_name(pv);
 		if (!(vg = vg_lock_and_read(cmd, vg_name, (char *)&pv->vgid,
 					    LCK_VG_READ, CLUSTERED, 0))) {
tools/toollib.c +25 -0
@@ -696,6 +696,7 @@
 	struct str_list *sll;
 	char *tagname;
 	int consistent = 1;
+	int scanned = 0;
 
 	list_init(&tags);
 
@@ -738,6 +739,30 @@
 					ret_max = ECMD_FAILED;
 					continue;
 				}
+
+        			/*
+			         * 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 (!scanned && is_orphan(pv)) {
+					if (!scan_vgs_for_pvs(cmd)) {
+						stack;
+						ret_max = ECMD_FAILED;
+						continue;
+					}
+					scanned = 1;
+					if (!(pv = pv_read(cmd, argv[opt],
+							   NULL, NULL, 1))) {
+						log_error("Failed to read "
+							  "physical volume "
+							  "\"%s\"", argv[opt]);
+						ret_max = ECMD_FAILED;
+						continue;
+					}
+				}
 			}
 
 			ret = process_single(cmd, vg, pv, handle);