Commit 3c462c88 authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues
Browse files

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: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
parent 9ed38ff5
Loading
Loading
Loading
Loading
+4 −6
Original line number Original line Diff line number Diff line
@@ -613,12 +613,10 @@ re_read:
	daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
	daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ;
	write_behind = le32_to_cpu(sb->write_behind);
	write_behind = le32_to_cpu(sb->write_behind);
	sectors_reserved = le32_to_cpu(sb->sectors_reserved);
	sectors_reserved = le32_to_cpu(sb->sectors_reserved);
	/* XXX: This is a hack to ensure that we don't use clustering
	/* Setup nodes/clustername only if bitmap version is
	 *  in case:
	 * cluster-compatible
	 *	- dm-raid is in use and
	 *	- the nodes written in bitmap_sb is erroneous.
	 */
	 */
	if (!bitmap->mddev->sync_super) {
	if (sb->version == cpu_to_le32(BITMAP_MAJOR_CLUSTERED)) {
		nodes = le32_to_cpu(sb->nodes);
		nodes = le32_to_cpu(sb->nodes);
		strlcpy(bitmap->mddev->bitmap_info.cluster_name,
		strlcpy(bitmap->mddev->bitmap_info.cluster_name,
				sb->cluster_name, 64);
				sb->cluster_name, 64);
@@ -628,7 +626,7 @@ re_read:
	if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
	if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
		reason = "bad magic";
		reason = "bad magic";
	else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO ||
	else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO ||
		 le32_to_cpu(sb->version) > BITMAP_MAJOR_HI)
		 le32_to_cpu(sb->version) > BITMAP_MAJOR_CLUSTERED)
		reason = "unrecognized superblock version";
		reason = "unrecognized superblock version";
	else if (chunksize < 512)
	else if (chunksize < 512)
		reason = "bitmap chunksize too small";
		reason = "bitmap chunksize too small";
+2 −0
Original line number Original line Diff line number Diff line
@@ -9,8 +9,10 @@
#define BITMAP_MAJOR_LO 3
#define BITMAP_MAJOR_LO 3
/* version 4 insists the bitmap is in little-endian order
/* version 4 insists the bitmap is in little-endian order
 * with version 3, it is host-endian which is non-portable
 * with version 3, it is host-endian which is non-portable
 * Version 5 is currently set only for clustered devices
 */
 */
#define BITMAP_MAJOR_HI 4
#define BITMAP_MAJOR_HI 4
#define BITMAP_MAJOR_CLUSTERED 5
#define	BITMAP_MAJOR_HOSTENDIAN 3
#define	BITMAP_MAJOR_HOSTENDIAN 3


/*
/*
+3 −0
Original line number Original line Diff line number Diff line
@@ -1735,6 +1735,9 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
		}
		}
	}
	}


	if (mddev_is_clustered(mddev))
		sb->feature_map |= cpu_to_le32(MD_FEATURE_CLUSTERED);

	if (rdev->badblocks.count == 0)
	if (rdev->badblocks.count == 0)
		/* Nothing to do for bad blocks*/ ;
		/* Nothing to do for bad blocks*/ ;
	else if (sb->bblog_offset == 0)
	else if (sb->bblog_offset == 0)
+2 −0
Original line number Original line Diff line number Diff line
@@ -302,6 +302,7 @@ struct mdp_superblock_1 {
#define	MD_FEATURE_RECOVERY_BITMAP	128 /* recovery that is happening
#define	MD_FEATURE_RECOVERY_BITMAP	128 /* recovery that is happening
					     * is guided by bitmap.
					     * is guided by bitmap.
					     */
					     */
#define MD_FEATURE_CLUSTERED		256 /* clustered MD */
#define	MD_FEATURE_ALL			(MD_FEATURE_BITMAP_OFFSET	\
#define	MD_FEATURE_ALL			(MD_FEATURE_BITMAP_OFFSET	\
					|MD_FEATURE_RECOVERY_OFFSET	\
					|MD_FEATURE_RECOVERY_OFFSET	\
					|MD_FEATURE_RESHAPE_ACTIVE	\
					|MD_FEATURE_RESHAPE_ACTIVE	\
@@ -310,6 +311,7 @@ struct mdp_superblock_1 {
					|MD_FEATURE_RESHAPE_BACKWARDS	\
					|MD_FEATURE_RESHAPE_BACKWARDS	\
					|MD_FEATURE_NEW_OFFSET		\
					|MD_FEATURE_NEW_OFFSET		\
					|MD_FEATURE_RECOVERY_BITMAP	\
					|MD_FEATURE_RECOVERY_BITMAP	\
					|MD_FEATURE_CLUSTERED		\
					)
					)


#endif
#endif