Skip to contentSkip to conversation

master - raid: adjust to misordered raid table line output

PATCH Heinz Mauelshagen 1 participant 1 message Mar 21, 2017 MD RAID

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1e4462dbfbd2bbe3590936df24b3ccd83110b158
Commit:        1e4462dbfbd2bbe3590936df24b3ccd83110b158
Parent:        642d682d8ddcc3152f68b3ec8518902a0ef448ac
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Tue Mar 21 18:17:42 2017 +0100
Committer:     Heinz Mauelshagen <[email protected]>
CommitterDate: Tue Mar 21 18:17:42 2017 +0100

raid: adjust to misordered raid table line output

The libdevmapper interface compares existing table line retrieved from the kernel to new table line created to decide if it can suppress a reload. Any difference between input and output of the table line is taken to be a change thus causing a table reload.

The dm-raid target started to misorder the raid parameters (e.g. 'raid10_copies') starting with dm-raid target version 1.9.0 up to (excluding) 1.11.0. This causes runtime failures (limited to raid10 as of tests) and needs to be reversed to allow e.g. old lvm2 uspace to run properly.

Check for the aforementioned version range and adjust creation of the table line to the respective (mis)ordered sequence inside and correct order outside the range (as described for the raid target in the kernels Documentation/device-mapper/dm-raid.txt).

---
 lib/metadata/segtype.h |    1 +
 lib/raid/raid.c        |   23 ++++++++++-
 libdm/libdevmapper.h   |   10 +++++
 libdm/libdm-deptree.c  |  102 +++++++++++++++++++++++++++++++++---------------
 4 files changed, 103 insertions(+), 33 deletions(-)
lib/metadata/segtype.h +1 -0
index 2364db8..a6093e8 100644
@@ -288,6 +288,7 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd,
 #define RAID_FEATURE_RAID4			(1U << 3) /* ! version 1.8 or 1.9.0 */
 #define RAID_FEATURE_SHRINK			(1U << 4) /* version 1.9.0 */
 #define RAID_FEATURE_RESHAPE			(1U << 5) /* version 1.10.1 */
+#define RAID_FEATURE_PROPER_TABLE_ORDER		(1U << 6) /* version >= 1.9.0 and < 1.11.0 had wrong parameter order */
 
 #ifdef RAID_INTERNAL
 int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);
lib/raid/raid.c +22 -1
index df9796d..7e9f0d3 100644
@@ -228,6 +228,9 @@ static int _raid_text_export(const struct lv_segment *seg, struct formatter *f)
 	return _raid_text_export_raid(seg, f);
 }
 
+static int _raid_target_present(struct cmd_context *cmd,
+				const struct lv_segment *seg __attribute__((unused)),
+				unsigned *attributes);
 static int _raid_add_target_line(struct dev_manager *dm __attribute__((unused)),
 				 struct dm_pool *mem __attribute__((unused)),
 				 struct cmd_context *cmd __attribute__((unused)),
@@ -238,6 +241,7 @@ static int _raid_add_target_line(struct dev_manager *dm __attribute__((unused)),
 				 uint32_t *pvmove_mirror_count __attribute__((unused)))
 {
 	int delta_disks = 0, delta_disks_minus = 0, delta_disks_plus = 0, data_offset = 0;
+	unsigned attrs;
 	uint32_t s;
 	uint64_t flags = 0;
 	uint64_t rebuilds[RAID_BITMAP_SIZE];
@@ -300,6 +304,13 @@ static int _raid_add_target_line(struct dev_manager *dm __attribute__((unused)),
 			flags = DM_NOSYNC;
 	}
 
+	if (!_raid_target_present(seg->lv->vg->cmd, seg, &attrs))
+		return_0;
+
+	/* RAID target line parameters are in kernel documented order */
+	if (attrs & RAID_FEATURE_PROPER_TABLE_ORDER)
+		flags |= DM_RAID_TABLE_ORDERED;
+
 	params.raid_type = lvseg_name(seg);
 
 	if (seg->segtype->parity_devs) {
@@ -479,7 +490,7 @@ static int _raid_target_present(struct cmd_context *cmd,
 
 	static int _raid_checked = 0;
 	static int _raid_present = 0;
-	static unsigned _raid_attrs = 0;
+	static unsigned _raid_attrs;
 	uint32_t maj, min, patchlevel;
 	unsigned i;
 
@@ -488,6 +499,7 @@ static int _raid_target_present(struct cmd_context *cmd,
 
 	if (!_raid_checked) {
 		_raid_checked = 1;
+		_raid_attrs = RAID_FEATURE_PROPER_TABLE_ORDER;
 
 		if (!(_raid_present = target_present(cmd, TARGET_NAME_RAID, 1)))
 			return 0;
@@ -514,6 +526,15 @@ static int _raid_target_present(struct cmd_context *cmd,
 		else
 			log_very_verbose("Target raid does not support %s.",
 					 SEG_TYPE_NAME_RAID4);
+
+		/*
+		 * Target version range check:
+		 *
+		 * raid target line parameters were misordered (e.g. 'raid10_copies')
+		 * in target version >= 1.9.0 and < 1.11.0
+		 */
+		if (maj == 1 && min >= 9 && min < 11)
+			_raid_attrs &= ~RAID_FEATURE_PROPER_TABLE_ORDER;
 	}
 
 	if (attributes)
libdm/libdevmapper.h +10 -0
index 4bd32b4..ff84785 100644
@@ -1775,6 +1775,16 @@ int dm_tree_node_add_mirror_target(struct dm_tree_node *node,
 #define DM_BLOCK_ON_ERROR	0x00000004	/* On error, suspend I/O */
 #define DM_CORELOG		0x00000008	/* In-memory log */
 
+/*
+ * RAID flag: table line is in kernel documented order.
+ *
+ * Target version >= 1.9.0 and < 1.11.0 misordered e.g. 'raid10_copies'
+ *
+ * Keep distinct from mirror log ones above because it
+ * can be passed together with those in load segment flags!
+ */
+#define DM_RAID_TABLE_ORDERED	0x00000010
+
 int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
 				       uint32_t region_size,
 				       unsigned clustered,
libdm/libdm-deptree.c +70 -32

123 lines not on this page · raw message