Skip to contentSkip to conversation

LVM2 lib/metadata/metadata-exported.h lib/meta ...

PATCH [email protected] 1 participant 1 message Jun 29, 2010

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at 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.

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

lib/metadata/metadata-exported.h +1 -0
@@ -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);
 
lib/metadata/metadata.c +44 -0

50 lines not on this page · raw message

tools/pvchange.c +1 -35
@@ -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)) {