diff options
author | Goldwyn Rodrigues <rgoldwyn@suse.com> | 2015-08-18 17:35:54 -0400 |
---|---|---|
committer | Goldwyn Rodrigues <rgoldwyn@suse.com> | 2015-10-12 02:31:33 -0400 |
commit | 3c462c880b52aae2cfbbb8db8b401eef118cc128 (patch) | |
tree | 47df3599c19db234cccf92933ab396926ee4b49b | |
parent | 9ed38ff53090856769b99e9d2f19740fb11e6956 (diff) |
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>
-rw-r--r-- | drivers/md/bitmap.c | 10 | ||||
-rw-r--r-- | drivers/md/bitmap.h | 2 | ||||
-rw-r--r-- | drivers/md/md.c | 3 | ||||
-rw-r--r-- | include/uapi/linux/raid/md_p.h | 2 |
4 files changed, 11 insertions, 6 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 48b5890c28e3..e9d3ee703e6d 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -613,12 +613,10 @@ re_read: | |||
613 | daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ; | 613 | daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ; |
614 | write_behind = le32_to_cpu(sb->write_behind); | 614 | write_behind = le32_to_cpu(sb->write_behind); |
615 | sectors_reserved = le32_to_cpu(sb->sectors_reserved); | 615 | sectors_reserved = le32_to_cpu(sb->sectors_reserved); |
616 | /* XXX: This is a hack to ensure that we don't use clustering | 616 | /* Setup nodes/clustername only if bitmap version is |
617 | * in case: | 617 | * cluster-compatible |
618 | * - dm-raid is in use and | ||
619 | * - the nodes written in bitmap_sb is erroneous. | ||
620 | */ | 618 | */ |
621 | if (!bitmap->mddev->sync_super) { | 619 | if (sb->version == cpu_to_le32(BITMAP_MAJOR_CLUSTERED)) { |
622 | nodes = le32_to_cpu(sb->nodes); | 620 | nodes = le32_to_cpu(sb->nodes); |
623 | strlcpy(bitmap->mddev->bitmap_info.cluster_name, | 621 | strlcpy(bitmap->mddev->bitmap_info.cluster_name, |
624 | sb->cluster_name, 64); | 622 | sb->cluster_name, 64); |
@@ -628,7 +626,7 @@ re_read: | |||
628 | if (sb->magic != cpu_to_le32(BITMAP_MAGIC)) | 626 | if (sb->magic != cpu_to_le32(BITMAP_MAGIC)) |
629 | reason = "bad magic"; | 627 | reason = "bad magic"; |
630 | else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO || | 628 | 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) |
632 | reason = "unrecognized superblock version"; | 630 | reason = "unrecognized superblock version"; |
633 | else if (chunksize < 512) | 631 | else if (chunksize < 512) |
634 | reason = "bitmap chunksize too small"; | 632 | reason = "bitmap chunksize too small"; |
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h index f1f4dd01090d..8731fa06855f 100644 --- a/drivers/md/bitmap.h +++ b/drivers/md/bitmap.h | |||
@@ -9,8 +9,10 @@ | |||
9 | #define BITMAP_MAJOR_LO 3 | 9 | #define BITMAP_MAJOR_LO 3 |
10 | /* version 4 insists the bitmap is in little-endian order | 10 | /* version 4 insists the bitmap is in little-endian order |
11 | * with version 3, it is host-endian which is non-portable | 11 | * with version 3, it is host-endian which is non-portable |
12 | * Version 5 is currently set only for clustered devices | ||
12 | */ | 13 | */ |
13 | #define BITMAP_MAJOR_HI 4 | 14 | #define BITMAP_MAJOR_HI 4 |
15 | #define BITMAP_MAJOR_CLUSTERED 5 | ||
14 | #define BITMAP_MAJOR_HOSTENDIAN 3 | 16 | #define BITMAP_MAJOR_HOSTENDIAN 3 |
15 | 17 | ||
16 | /* | 18 | /* |
diff --git a/drivers/md/md.c b/drivers/md/md.c index c702de18207a..1e1bdd86f40c 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1735,6 +1735,9 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev) | |||
1735 | } | 1735 | } |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | if (mddev_is_clustered(mddev)) | ||
1739 | sb->feature_map |= cpu_to_le32(MD_FEATURE_CLUSTERED); | ||
1740 | |||
1738 | if (rdev->badblocks.count == 0) | 1741 | if (rdev->badblocks.count == 0) |
1739 | /* Nothing to do for bad blocks*/ ; | 1742 | /* Nothing to do for bad blocks*/ ; |
1740 | else if (sb->bblog_offset == 0) | 1743 | else if (sb->bblog_offset == 0) |
diff --git a/include/uapi/linux/raid/md_p.h b/include/uapi/linux/raid/md_p.h index 2ae6131e69a5..867ee874fa80 100644 --- a/include/uapi/linux/raid/md_p.h +++ b/include/uapi/linux/raid/md_p.h | |||
@@ -302,6 +302,7 @@ struct mdp_superblock_1 { | |||
302 | #define MD_FEATURE_RECOVERY_BITMAP 128 /* recovery that is happening | 302 | #define MD_FEATURE_RECOVERY_BITMAP 128 /* recovery that is happening |
303 | * is guided by bitmap. | 303 | * is guided by bitmap. |
304 | */ | 304 | */ |
305 | #define MD_FEATURE_CLUSTERED 256 /* clustered MD */ | ||
305 | #define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \ | 306 | #define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \ |
306 | |MD_FEATURE_RECOVERY_OFFSET \ | 307 | |MD_FEATURE_RECOVERY_OFFSET \ |
307 | |MD_FEATURE_RESHAPE_ACTIVE \ | 308 | |MD_FEATURE_RESHAPE_ACTIVE \ |
@@ -310,6 +311,7 @@ struct mdp_superblock_1 { | |||
310 | |MD_FEATURE_RESHAPE_BACKWARDS \ | 311 | |MD_FEATURE_RESHAPE_BACKWARDS \ |
311 | |MD_FEATURE_NEW_OFFSET \ | 312 | |MD_FEATURE_NEW_OFFSET \ |
312 | |MD_FEATURE_RECOVERY_BITMAP \ | 313 | |MD_FEATURE_RECOVERY_BITMAP \ |
314 | |MD_FEATURE_CLUSTERED \ | ||
313 | ) | 315 | ) |
314 | 316 | ||
315 | #endif | 317 | #endif |