Skip to contentSkip to conversation

dev-dct-process-latest - lvchange: backup final metadata

PATCH David Teigland 1 participant 1 message Sep 22, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3adc50ac22f5a3e355db5d143303c8b7dfb7c828
Commit:        3adc50ac22f5a3e355db5d143303c8b7dfb7c828
Parent:        f09f85d027d8833727483efd6077f52d2e5b6ba2
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Sep 19 15:16:26 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Sep 19 15:55:34 2014 +0200

lvchange: backup final metadata

Shift backup after final metadata commit.

Synchronize with wiping.

---
 WHATS_NEW        |    1 +
 tools/lvchange.c |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
index a2c4577..c5ba9fa 100644
@@ -1,5 +1,6 @@
 Version 2.02.112 - 
 =====================================
+  Backup final metadata after resync of mirror/raid.
   Unify handling of --persistent option for lvcreate and lvchange.
   Validate major and minor numbers stored in metadata.
   Use -fPIE when linking -pie executables.
tools/lvchange.c +8 -1
index 8ccbe19..b196591 100644
@@ -14,6 +14,7 @@
  */
 
 #include "tools.h"
+#include "memlock.h"
 
 static int lvchange_permission(struct cmd_context *cmd,
 			       struct logical_volume *lv)
@@ -416,7 +417,8 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
 		return 0;
 	}
 
-	backup(lv->vg);
+	/* No backup for intermediate metadata, so just unlock memory */
+	memlock_unlock(lv->vg->cmd);
 
 	dm_list_iterate_items(lvl, &device_list) {
 		if (!activate_lv_excl_local(cmd, lvl->lv)) {
@@ -449,6 +451,8 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
 		}
 	}
 
+	sync_local_dev_names(lv->vg->cmd);  /* Wait until devices are away */
+
 	/* Put metadata sub-LVs back in place */
 	if (!attach_metadata_devices(seg, &device_list)) {
 		log_error("Failed to reattach %s device after clearing",
@@ -463,11 +467,14 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
 	}
 
 	if (!_reactivate_lv(lv, active, exclusive)) {
+		backup(lv->vg);
 		log_error("Failed to reactivate %s after resync",
 			  lv->name);
 		return 0;
 	}
 
+	backup(lv->vg);
+
 	return 1;
 }