Skip to contentSkip to conversation

master - pvmove: prohibit non-resilient collocation of RAID SubLVs

PATCH Heinz Mauelshagen 1 participant 1 message Aug 15, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8e9d5d12ae3ac75852ebd74b64c28e31abb68d0e
Commit:        8e9d5d12ae3ac75852ebd74b64c28e31abb68d0e
Parent:        c7bd33d9516dd6d146a02b4af43eb142a4f0aa26
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Mon Aug 15 18:22:32 2016 +0200
Committer:     Heinz Mauelshagen <[email protected]>
CommitterDate: Mon Aug 15 18:22:32 2016 +0200

pvmove: prohibit non-resilient collocation of RAID SubLVs

'pvmove -n name pv1 pv2' allows to collocate multiple RAID SubLVs on pv2 (e.g. results in collocated raidlv_rimage_0 and raidlv_rimage_1), thus causing loss of resilence and/or performance of the RaidLV.

Fix this pvmove flaw leading to potential data loss in case of PV failure by preventing any SubLVs from collocation on any PVs of the RaidLV. Still allow to collocate any DataLVs of a RaidLV with their sibling MetaLVs and vice-versa though (e.g. raidlv_rmeta_0 on pv1 may still be moved to pv2 already holding raidlv_rimage_0).

Because access to the top-level RaidLV name is needed, promote local _top_level_lv_name() from raid_manip.c to global top_level_lv_name().

- resolves rhbz1202497

---
 WHATS_NEW                        |    1 +
 lib/metadata/metadata-exported.h |    1 +
 lib/metadata/raid_manip.c        |    9 ++--
 tools/pvmove.c                   |   85 ++++++++++++++++++++++++++++++++++++--
 4 files changed, 88 insertions(+), 8 deletions(-)
WHATS_NEW +1 -0
index d78b281..60bdc4f 100644
@@ -1,5 +1,6 @@
 Version 2.02.165 - 
 ===================================
+  Fix 'pvmove -n name ...' to prohibit collocation of RAID SubLVs
 
 Version 2.02.164 - 15th August 2016
 ===================================
lib/metadata/metadata-exported.h +1 -0
index 3329535..97692dc 100644
@@ -1272,6 +1272,7 @@ uint32_t find_free_lvnum(struct logical_volume *lv);
 dm_percent_t copy_percent(const struct logical_volume *lv_mirr);
 char *generate_lv_name(struct volume_group *vg, const char *format,
 		       char *buffer, size_t len);
+char *top_level_lv_name(struct volume_group *vg, const char *lv_name);
 
 struct generic_logical_volume *get_or_create_glv(struct dm_pool *mem, struct logical_volume *lv, int *glv_created);
 struct glv_list *get_or_create_glvl(struct dm_pool *mem, struct logical_volume *lv, int *glv_created);
lib/metadata/raid_manip.c +5 -4
index a7814a8..d0934f4 100644
@@ -109,16 +109,17 @@ static void _check_and_adjust_region_size(const struct logical_volume *lv)
 }
 
 /* Strip any raid suffix off LV name */
-static char *_top_level_raid_lv_name(struct logical_volume *lv)
+char *top_level_lv_name(struct volume_group *vg, const char *lv_name)
 {
 	char *new_lv_name, *suffix;
 
-	if (!(new_lv_name = dm_pool_strdup(lv->vg->vgmem, lv->name))) {
+	if (!(new_lv_name = dm_pool_strdup(vg->vgmem, lv_name))) {
 		log_error("Failed to allocate string for new LV name.");
 		return NULL;
 	}
         
-	if ((suffix = first_substring(new_lv_name, "_rimage_", "_mimage_", NULL)))
+	if ((suffix = first_substring(new_lv_name, "_rimage_", "_rmeta_",
+						   "_mimage_", "_mlog_", NULL)))
 		*suffix = '\0';
 
 	return new_lv_name;
@@ -731,7 +732,7 @@ static int _alloc_rmeta_for_lv(struct logical_volume *data_lv,
 		return 0;
 	}
 
-	if (!(base_name = _top_level_raid_lv_name(data_lv)))
+	if (!(base_name = top_level_lv_name(data_lv->vg, data_lv->name)))
 		return_0;
 
 	if (!(ah = allocate_extents(data_lv->vg, NULL, seg->segtype, 0, 1, 0,
tools/pvmove.c +81 -4

115 lines not on this page · raw message