Skip to contentSkip to conversation

master - lvchange: Allow device specification when requesting a repair

PATCH Heinz Mauelshagen 1 participant 1 message Aug 5, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d2c3b23e6dc39565093256c97ff66984e8648bda
Commit:        d2c3b23e6dc39565093256c97ff66984e8648bda
Parent:        91f866f7866eed6eb8ead5a876efcac5a58511da
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Fri Aug 5 15:54:49 2016 +0200
Committer:     Heinz Mauelshagen <[email protected]>
CommitterDate: Fri Aug 5 16:01:46 2016 +0200

lvchange: Allow device specification when requesting a repair

'lvchange --resync LV' or 'lvchange --syncaction repair LV' request the RAID layout specific parity blocks in raid4/5/6 to be recreated or the mirrored blocks to be copied again from the master leg/copy for raid1/10, thus not allowing a rebuild of a particular PV.

Introduce repeatable option '--[raid]rebuild PV' to allow to request rebuilds of specific PVs in a RaidLV which are known to contain corrupt data (e.g. rebuild a raid1 master leg).

Add test lvchange-rebuild-raid.sh to test/shell doing rebuild variations on raid1/10 and 5; add aux function check_status_chars to support the new test.

- Resolves rhbz1064592

---
 lib/metadata/metadata-exported.h |    1 +
 lib/metadata/raid_manip.c        |   99 +++++++++++++++++++++++++++++---------
 man/lvchange.8.in                |   27 ++++++++++
 test/lib/aux.sh                  |    6 ++
 tools/args.h                     |    2 +
 tools/commands.h                 |   10 ++--
 tools/lvchange.c                 |   63 ++++++++++++++++++++++++
 tools/lvmcmdline.c               |    1 +
 8 files changed, 182 insertions(+), 27 deletions(-)
lib/metadata/metadata-exported.h +1 -0
index e1a3538..3329535 100644
@@ -1204,6 +1204,7 @@ int lv_raid_convert(struct logical_volume *lv,
 		    const unsigned new_stripe_size,
 		    const uint32_t new_region_size,
 		    struct dm_list *allocate_pvs);
+int lv_raid_rebuild(struct logical_volume *lv, struct dm_list *rebuild_pvs);
 int lv_raid_replace(struct logical_volume *lv, struct dm_list *remove_pvs,
 		    struct dm_list *allocate_pvs);
 int lv_raid_remove_missing(struct logical_volume *lv);
lib/metadata/raid_manip.c +76 -23

171 lines not on this page · raw message

man/lvchange.8.in +27 -0
index 3800369..8da9f2d 100644
@@ -25,6 +25,8 @@ lvchange \(em change attributes of a logical volume
 .IR AllocationPolicy ]
 .RB [ \-A | \-\-autobackup
 .RB { y | n }]
+.RB [ \-\-rebuild
+.IR PhysicalVolume ]
 .RB [ \-\-cachemode
 .RB { passthrough | writeback | writethrough }]
 .RB [ \-\-cachepolicy
@@ -326,6 +328,31 @@ immediately poll a logical volume when it is activated, use
 \fB\-\-poll n\fP to defer and then \fB\-\-poll y\fP to restart the process.
 .
 .HP
+.BR \-\- [ raid ] rebuild 
+.BR \fIPhysicalVolume
+.br
+Option can be repeated multiple times.
+Selects PhysicalVolume(s) to be rebuild in a RaidLV.
+Use this option instead of
+.BR \-\-resync
+or
+.BR \-\- [ raid ] syncaction
+\fBrepair\fP in case the PVs with corrupted data are known and their data
+should be reconstructed rather than reconstructing default (rotating) data.
+.br
+E.g. in a raid1 mirror, the master leg on /dev/sda may hold corrupt data due
+to a known transient disk error, thus
+.br
+\fBlvchange --rebuild /dev/sda LV\fP
+.br
+will request the master leg to be rebuild rather than rebuilding
+all other legs from the master.
+On a raid5 with rotating data and parity
+.br
+\fBlvchange --rebuild /dev/sda LV\fP
+.br
+will rebuild all data and parity blocks in the stripe on /dev/sda.
+.HP
 .BR \-\- [ raid ] maxrecoveryrate
 .BR \fIRate [ b | B | s | S | k | K | m | M | g | G ]
 .br
test/lib/aux.sh +6 -0
index 90f2ab1..726cfe3 100644
@@ -1265,6 +1265,12 @@ wait_for_sync() {
 	return 1
 }
 
+# aux check_status_chars $vg $lv "Aaaaa"
+check_status_chars() {
+	[ `dmsetup status $1-$2|awk '{print $6}'` = $3 ] && return
+	return 1
+}
+
 # Check if tests are running on 64bit architecture
 can_use_16T() {
 	test "$(getconf LONG_BIT)" -eq 64
tools/args.h +2 -0
index 5902513..a04d81d 100644
@@ -88,6 +88,7 @@ arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0, 0)
 arg(poolmetadataspare_ARG, '\0', "poolmetadataspare", yes_no_arg, 0, 0)
 arg(profile_ARG, '\0', "profile", string_arg, 0, 0)
 arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0, 0)
+arg(raidrebuild_ARG, '\0', "raidrebuild", string_arg, ARG_GROUPABLE, 0)
 arg(raidmaxrecoveryrate_ARG, '\0', "raidmaxrecoveryrate", size_kb_arg, 0, 0)
 arg(raidminrecoveryrate_ARG, '\0', "raidminrecoveryrate", size_kb_arg, 0, 0)
 arg(raidsyncaction_ARG, '\0', "raidsyncaction", string_arg, 0, 0)
@@ -96,6 +97,7 @@ arg(raidwritemostly_ARG, '\0', "raidwritemostly", string_arg, ARG_GROUPABLE, 0)
 arg(readonly_ARG, '\0', "readonly", NULL, 0, 0)
 arg(refresh_ARG, '\0', "refresh", NULL, 0, 0)
 arg(removemissing_ARG, '\0', "removemissing", NULL, 0, 0)
+arg(rebuild_ARG, '\0', "rebuild", string_arg, ARG_GROUPABLE, 0)
 arg(repair_ARG, '\0', "repair", NULL, 0, 0)
 arg(replace_ARG, '\0', "replace", string_arg, ARG_GROUPABLE, 0)
 arg(reportformat_ARG, '\0', "reportformat", string_arg, 0, 0)
tools/commands.h +6 -4
index c348753..baf89b1 100644
@@ -195,6 +195,7 @@ xx(lvchange,
    "\t[--activationmode {complete|degraded|partial}"
    "\t[--addtag <Tag>]\n"
    "\t[--alloc <AllocationPolicy>]\n"
+   "\t[--rebuild PhysicalVolume]\n"
    "\t[-C|--contiguous {y|n}]\n"
    "\t[--cachemode <CacheMode>]\n"
    "\t[--cachepolicy <policyname>] [--cachesettings <parameter=value>]\n"
@@ -244,10 +245,10 @@ xx(lvchange,
    ignoreskippedcluster_ARG, major_ARG, metadataprofile_ARG, minor_ARG,
    monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, noudevsync_ARG,
    partial_ARG, permission_ARG, persistent_ARG, poll_ARG,
-   raidminrecoveryrate_ARG, raidmaxrecoveryrate_ARG, raidsyncaction_ARG,
-   raidwritebehind_ARG, raidwritemostly_ARG, readahead_ARG, reportformat_ARG,
-   resync_ARG, refresh_ARG, select_ARG, setactivationskip_ARG, syncaction_ARG,
-   sysinit_ARG, test_ARG, writebehind_ARG, writemostly_ARG, zero_ARG)
+   raidrebuild_ARG, raidminrecoveryrate_ARG, raidmaxrecoveryrate_ARG,
+   raidsyncaction_ARG, raidwritebehind_ARG, raidwritemostly_ARG, readahead_ARG,
+   reportformat_ARG, rebuild_ARG, resync_ARG, refresh_ARG, select_ARG, setactivationskip_ARG,
+   syncaction_ARG, sysinit_ARG, test_ARG, writebehind_ARG, writemostly_ARG, zero_ARG)
 
 #define COMMON_OPTS \
 	"\t[--commandprofile <ProfileName>] [-d|--debug] [-h|-?|--help]\n" \
@@ -259,6 +260,7 @@ xx(lvconvert,
    "lvconvert "
    "[-m|--mirrors <Mirrors> [--mirrorlog {disk|core|mirrored}|--corelog]]\n"
    "\t[--type <SegmentType>]\n"
+   "\t[--rebuild PhysicalVolume]\n"
    "\t[--repair [--use-policies]]\n"
    "\t[--replace PhysicalVolume]\n"
    "\t[-R|--regionsize <MirrorLogRegionSize>]\n"
tools/lvchange.c +63 -0

81 lines not on this page · raw message

tools/lvmcmdline.c +1 -0
index fd00ce6..4ad2ea6 100644
@@ -1167,6 +1167,7 @@ static int _get_settings(struct cmd_context *cmd)
 	    !_merge_synonym(cmd, allocation_ARG, resizeable_ARG) ||
 	    !_merge_synonym(cmd, virtualoriginsize_ARG, virtualsize_ARG) ||
 	    !_merge_synonym(cmd, available_ARG, activate_ARG) ||
+	    !_merge_synonym(cmd, raidrebuild_ARG, rebuild_ARG) ||
 	    !_merge_synonym(cmd, raidsyncaction_ARG, syncaction_ARG) ||
 	    !_merge_synonym(cmd, raidwritemostly_ARG, writemostly_ARG) ||
 	    !_merge_synonym(cmd, raidminrecoveryrate_ARG, minrecoveryrate_ARG) ||