Skip to contentSkip to conversation

master - lvconvert: position dedicated parity device in raid4 conversions porperly

PATCH Heinz Mauelshagen 1 participant 1 message Oct 21, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de78e8eae73cb155fdb906ef2b8ddc9ca1a918c4
Commit:        de78e8eae73cb155fdb906ef2b8ddc9ca1a918c4
Parent:        34da83d729436d245e91e24e30b6996862fe7725
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Fri Oct 21 18:59:59 2016 +0200
Committer:     Heinz Mauelshagen <[email protected]>
CommitterDate: Fri Oct 21 19:00:31 2016 +0200

lvconvert: position dedicated parity device in raid4 conversions porperly

On conversions between striped/raid0* and raid4, the kernel expects the dedicated raid4 parity SubLVs in the first segment area rather than in the last it's been allocated to, thus the data mapping ain't proper.

Enhance lvconvert (lib/metadata/raid_manip.c) to shift the dedicated parity SubLVs on conversions from striped/raid0* to raid4 and vice-versa.

In case of raid0_meta -> raid4 where the MD raid0 personality already has stored RAID array device positions in the superblocks, the MetaLVs have to be cleared so that the kernel doesn't fail validating the array positions after lvm has shifted them up by one.

Add more tests to lvconvert-raid-takeover.sh including one to check for mapping flaws by converting a created raid4 with filesystem -> striped and fsck it.

Whilst on it:
- add missing direct striped -> raid4 conversion to the takeover array to avoid an intermim conversion from striped -> raid0*
- clean up the takeover array
- allow lvconvert to actually call lv_raid_convert() on all takeover requests in order to check parameters and display messages provided by takeover functions rather than just "...not supported" from within lvconvert
- fix a typo

Resolves: rhbz1386148

---
 WHATS_NEW                             |    2 +
 lib/metadata/raid_manip.c             |  277 ++++++++++++++++++++++++++++++---
 test/shell/lvconvert-raid-takeover.sh |   53 ++++++-
 tools/lvconvert.c                     |   24 +--
 4 files changed, 314 insertions(+), 42 deletions(-)
WHATS_NEW +2 -0
index 4138685..3a8e006 100644
@@ -1,5 +1,7 @@
 Version 2.02.167 - 
 ======================================
+  Add direct striped -> raid4 conversion
+  Fix raid4 parity image pair position on conversions from striped/raid0*
   Fix a few unconverted return code values for some lvconvert error path.
   Disable lvconvert of thin pool to raid while active.
   Disable systemd service start rate limiting for lvm2-pvscan at .service.
lib/metadata/raid_manip.c +258 -19

366 lines not on this page · raw message

test/shell/lvconvert-raid-takeover.sh +47 -6

80 lines not on this page · raw message

tools/lvconvert.c +7 -17
index 772c268..1fbe1ea 100644
@@ -1937,7 +1937,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
 			return 1;
 		}
 		goto try_new_takeover_or_reshape;
-	} else if (!lp->repair && !lp->replace && (!*lp->type_str || seg->segtype == lp->segtype)) {
+	} else if (!lp->repair && !lp->replace && !*lp->type_str) {
 		log_error("Conversion operation not yet supported.");
 		return 0;
 	}
@@ -2005,28 +2005,18 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
 		return 1;
 	}
 
-
 try_new_takeover_or_reshape:
-
 	/* FIXME This needs changing globally. */
 	if (!arg_is_set(cmd, stripes_long_ARG))
 		lp->stripes = 0;
 
-	/* Only let raid4 through for now. */
-	if (lp->type_str && lp->type_str[0] && lp->segtype != seg->segtype &&
-	    ((seg_is_raid4(seg) && seg_is_striped(lp) && lp->stripes > 1) ||
-	     (seg_is_striped(seg) && seg->area_count > 1 && seg_is_raid4(lp)))) {
-		if (!lv_raid_convert(lv, lp->segtype, lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
-				     lp->region_size, lp->pvh))
-			return_0;
-
-		log_print_unless_silent("Logical volume %s successfully converted.",
-					display_lvname(lv));
-		return 1;
-	}
+	if (!lv_raid_convert(lv, lp->segtype, lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
+			     lp->region_size, lp->pvh))
+		return_0;
 
-	log_error("Conversion operation not yet supported.");
-	return 0;
+	log_print_unless_silent("Logical volume %s successfully converted.",
+				display_lvname(lv));
+	return 1;
 }
 
 static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volume *cow,