Skip to contentSkip to conversation

master - lvconvert: prevent non-synced raid1 primary leg repair

PATCH Heinz Mauelshagen 1 participant 1 message Oct 28, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8270ff5702e0fa846714ac7366aade84b3e85209
Commit:        8270ff5702e0fa846714ac7366aade84b3e85209
Parent:        e118b65d651d921390d3e8bbcac7170c3894d048
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Fri Oct 28 15:54:27 2016 +0200
Committer:     Heinz Mauelshagen <[email protected]>
CommitterDate: Fri Oct 28 15:55:10 2016 +0200

lvconvert: prevent non-synced raid1 primary leg repair

(Automatic) repair may not be allowed during the initial sync of an upconverted linear LV, because the data on the failing, primary leg hasn't been completely synchronized to the N-1 other legs of the raid1 LV (replacing failed legs during repair involves discontinuing access to any replaced legs data, thus preventing data recovery on the primary leg e.g. via dd_rescue).

Even though repair would not cause data loss when adding legs to a fully synced raid1 LV, we don't have information yet defining this state yet (e.g. a raid1 LV flag telling the fully synchronized status before any legs were added), hence can't automatically decide to allow to repair.

If nonetheless a repair on a non-synced raid1 LVs is intended, the "--force" option has to be provided.

Resolves: rhbz1311765

---
 WHATS_NEW                        |    1 +
 lib/metadata/metadata-exported.h |    4 +-
 lib/metadata/raid_manip.c        |   60 ++++++++++++++++++++++++++-----------
 tools/lvconvert.c                |    4 +-
 4 files changed, 47 insertions(+), 22 deletions(-)
WHATS_NEW +1 -0
index 1d0d6dc..49af38a 100644
@@ -1,5 +1,6 @@
 Version 2.02.167 - 
 ======================================
+  Prevent non-synced raid1 repair unless --force
   Prevent raid4 creation/conversion on non-supporting kernels
   Add direct striped -> raid4 conversion
   Fix raid4 parity image pair position on conversions from striped/raid0*
lib/metadata/metadata-exported.h +2 -2
index 37db89c..cdd4984 100644
@@ -1208,8 +1208,8 @@ int lv_raid_convert(struct logical_volume *lv,
 		    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_replace(struct logical_volume *lv, int force,
+		    struct dm_list *remove_pvs, struct dm_list *allocate_pvs);
 int lv_raid_remove_missing(struct logical_volume *lv);
 int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lv);
 /* --  metadata/raid_manip.c */
lib/metadata/raid_manip.c +42 -18

143 lines not on this page · raw message

tools/lvconvert.c +2 -2
index 23b5906..8376565 100644
@@ -1994,7 +1994,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
 	}
 
 	if (lp->replace)
-		return lv_raid_replace(lv, lp->replace_pvh, lp->pvh);
+		return lv_raid_replace(lv, lp->force, lp->replace_pvh, lp->pvh);
 
 	if (lp->repair) {
 		if (!lv_is_active_exclusive_locally(lv_lock_holder(lv))) {
@@ -2017,7 +2017,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
 			if (!(failed_pvs = _failed_pv_list(lv->vg)))
 				return_0;
 
-			if (!lv_raid_replace(lv, failed_pvs, lp->pvh)) {
+			if (!lv_raid_replace(lv, lp->force, failed_pvs, lp->pvh)) {
 				log_error("Failed to replace faulty devices in %s.",
 					  display_lvname(lv));
 				return 0;