[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 1/3] Fix 'lvchange --resync'



Fix 'lvchange --resync' breakage (since 2.02.30)

# lvchange --resync vg/lv
  LV lv_mlog is used by LV lv:0, but missing ptr from lv to lv_mlog
  Internal error: LV segments corrupted in lv_mlog.
  Failed to write intermediate VG metadata.

When changing seg->log_lv, it needs to do corresponding
add_seg_to_segs_using_this_lv/remove_seg_from_segs_using_this_lv.
Without them, the metadata validator will detect inconsistency
and report like the above.

Attached patch fixes the issue.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
When seg->log_lv is changed, log_lv->segs_using_this_lv should be
updated as well.

Otherwise, the internal metadata becomes inconsistent.
(The validator will detect that.)

Index: LVM2.work/tools/lvchange.c
===================================================================
--- LVM2.work.orig/tools/lvchange.c
+++ LVM2.work/tools/lvchange.c
@@ -274,6 +274,7 @@ static int lvchange_resync(struct cmd_co
 		first_seg(lv)->log_lv = NULL;
 		log_lv->status &= ~MIRROR_LOG;
 		log_lv->status |= VISIBLE_LV;
+		remove_seg_from_segs_using_this_lv(log_lv, first_seg(lv));
 
 		if (!vg_write(lv->vg)) {
 			log_error("Failed to write intermediate VG metadata.");
@@ -281,6 +282,7 @@ static int lvchange_resync(struct cmd_co
 				first_seg(lv)->log_lv = log_lv;
 				log_lv->status |= MIRROR_LOG;
 				log_lv->status &= ~VISIBLE_LV;
+				add_seg_to_segs_using_this_lv(log_lv, first_seg(lv));
 				if (!activate_lv(cmd, lv))
 					stack;
 			}
@@ -295,6 +297,7 @@ static int lvchange_resync(struct cmd_co
 				first_seg(lv)->log_lv = log_lv;
 				log_lv->status |= MIRROR_LOG;
 				log_lv->status &= ~VISIBLE_LV;
+				add_seg_to_segs_using_this_lv(log_lv, first_seg(lv));
 				if (!activate_lv(cmd, lv))
 					stack;
 			}
@@ -326,6 +329,7 @@ static int lvchange_resync(struct cmd_co
 		first_seg(lv)->log_lv = log_lv;
 		log_lv->status |= MIRROR_LOG;
 		log_lv->status &= ~VISIBLE_LV;
+		add_seg_to_segs_using_this_lv(log_lv, first_seg(lv));
 	}
 
 	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]