Skip to content

Commit 3c462c8

Browse files
committed
md: Increment version for clustered bitmaps
Add BITMAP_MAJOR_CLUSTERED as 5, in order to prevent older kernels to assemble a clustered device. In order to maximize compatibility, the major version is set to BITMAP_MAJOR_CLUSTERED *only* if the bitmap is clustered. Added MD_FEATURE_CLUSTERED in order to return error for older kernels which would assemble MD even if the bitmap is corrupted. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
1 parent 9ed38ff commit 3c462c8

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎drivers/md/bitmap.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,10 @@ static int bitmap_read_sb(struct bitmap *bitmap)
613613
daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
614614
write_behind = le32_to_cpu(sb->write_behind);
615615
sectors_reserved = le32_to_cpu(sb->sectors_reserved);
616-
/* XXX: This is a hack to ensure that we don't use clustering
617-
* in case:
618-
* - dm-raid is in use and
619-
* - the nodes written in bitmap_sb is erroneous.
616+
/* Setup nodes/clustername only if bitmap version is
617+
* cluster-compatible
620618
*/
621-
if (!bitmap->mddev->sync_super) {
619+
if (sb->version == cpu_to_le32(BITMAP_MAJOR_CLUSTERED)) {
622620
nodes = le32_to_cpu(sb->nodes);
623621
strlcpy(bitmap->mddev->bitmap_info.cluster_name,
624622
sb->cluster_name, 64);
@@ -628,7 +626,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
628626
if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
629627
reason = "bad magic";
630628
else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO ||
631-
le32_to_cpu(sb->version) > BITMAP_MAJOR_HI)
629+
le32_to_cpu(sb->version) > BITMAP_MAJOR_CLUSTERED)
632630
reason = "unrecognized superblock version";
633631
else if (chunksize < 512)
634632
reason = "bitmap chunksize too small";

‎drivers/md/bitmap.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#define BITMAP_MAJOR_LO 3
1010
/* version 4 insists the bitmap is in little-endian order
1111
* with version 3, it is host-endian which is non-portable
12+
* Version 5 is currently set only for clustered devices
1213
*/
1314
#define BITMAP_MAJOR_HI 4
15+
#define BITMAP_MAJOR_CLUSTERED 5
1416
#define BITMAP_MAJOR_HOSTENDIAN 3
1517

1618
/*

‎drivers/md/md.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,9 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
17351735
}
17361736
}
17371737

1738+
if (mddev_is_clustered(mddev))
1739+
sb->feature_map |= cpu_to_le32(MD_FEATURE_CLUSTERED);
1740+
17381741
if (rdev->badblocks.count == 0)
17391742
/* Nothing to do for bad blocks*/ ;
17401743
else if (sb->bblog_offset == 0)

‎include/uapi/linux/raid/md_p.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ struct mdp_superblock_1 {
302302
#define MD_FEATURE_RECOVERY_BITMAP 128 /* recovery that is happening
303303
* is guided by bitmap.
304304
*/
305+
#define MD_FEATURE_CLUSTERED 256 /* clustered MD */
305306
#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \
306307
|MD_FEATURE_RECOVERY_OFFSET \
307308
|MD_FEATURE_RESHAPE_ACTIVE \
@@ -310,6 +311,7 @@ struct mdp_superblock_1 {
310311
|MD_FEATURE_RESHAPE_BACKWARDS \
311312
|MD_FEATURE_NEW_OFFSET \
312313
|MD_FEATURE_RECOVERY_BITMAP \
314+
|MD_FEATURE_CLUSTERED \
313315
)
314316

315317
#endif

0 commit comments

Comments
 (0)