aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2015-08-13 17:31:55 -0400
committerNeilBrown <neilb@suse.com>2015-10-24 02:16:18 -0400
commitbac624f3f86a8c7db395c7f85ccad6a504b9c4b4 (patch)
tree0b9240c0fb33d6adf4ddcfd85afd95321cc96552
parentc4d4c91b44d8309082127893221a1971a27c50ca (diff)
MD: add a new disk role to present write journal device
Next patches will use a disk as raid5/6 journaling. We need a new disk role to present the journal device and add MD_FEATURE_JOURNAL to feature_map for backward compability. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
-rw-r--r--drivers/md/md.c23
-rw-r--r--drivers/md/md.h5
-rw-r--r--include/uapi/linux/raid/md_p.h3
3 files changed, 29 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index cfe5c8704a26..391341a772c7 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1638,6 +1638,15 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
1638 case MD_DISK_ROLE_FAULTY: /* faulty */ 1638 case MD_DISK_ROLE_FAULTY: /* faulty */
1639 set_bit(Faulty, &rdev->flags); 1639 set_bit(Faulty, &rdev->flags);
1640 break; 1640 break;
1641 case MD_DISK_ROLE_JOURNAL: /* journal device */
1642 if (!(le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL)) {
1643 /* journal device without journal feature */
1644 printk(KERN_WARNING
1645 "md: journal device provided without journal feature, ignoring the device\n");
1646 return -EINVAL;
1647 }
1648 set_bit(Journal, &rdev->flags);
1649 break;
1641 default: 1650 default:
1642 rdev->saved_raid_disk = role; 1651 rdev->saved_raid_disk = role;
1643 if ((le32_to_cpu(sb->feature_map) & 1652 if ((le32_to_cpu(sb->feature_map) &
@@ -1796,7 +1805,10 @@ retry:
1796 sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_FAULTY); 1805 sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_FAULTY);
1797 else if (test_bit(In_sync, &rdev2->flags)) 1806 else if (test_bit(In_sync, &rdev2->flags))
1798 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); 1807 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
1799 else if (rdev2->raid_disk >= 0) 1808 else if (test_bit(Journal, &rdev2->flags)) {
1809 sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_JOURNAL);
1810 sb->feature_map |= cpu_to_le32(MD_FEATURE_JOURNAL);
1811 } else if (rdev2->raid_disk >= 0)
1800 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); 1812 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
1801 else 1813 else
1802 sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_SPARE); 1814 sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_SPARE);
@@ -5840,7 +5852,8 @@ static int get_disk_info(struct mddev *mddev, void __user * arg)
5840 else if (test_bit(In_sync, &rdev->flags)) { 5852 else if (test_bit(In_sync, &rdev->flags)) {
5841 info.state |= (1<<MD_DISK_ACTIVE); 5853 info.state |= (1<<MD_DISK_ACTIVE);
5842 info.state |= (1<<MD_DISK_SYNC); 5854 info.state |= (1<<MD_DISK_SYNC);
5843 } 5855 } else if (test_bit(Journal, &rdev->flags))
5856 info.state |= (1<<MD_DISK_JOURNAL);
5844 if (test_bit(WriteMostly, &rdev->flags)) 5857 if (test_bit(WriteMostly, &rdev->flags))
5845 info.state |= (1<<MD_DISK_WRITEMOSTLY); 5858 info.state |= (1<<MD_DISK_WRITEMOSTLY);
5846 } else { 5859 } else {
@@ -5955,6 +5968,8 @@ static int add_new_disk(struct mddev *mddev, mdu_disk_info_t *info)
5955 else 5968 else
5956 clear_bit(WriteMostly, &rdev->flags); 5969 clear_bit(WriteMostly, &rdev->flags);
5957 5970
5971 if (info->state & (1<<MD_DISK_JOURNAL))
5972 set_bit(Journal, &rdev->flags);
5958 /* 5973 /*
5959 * check whether the device shows up in other nodes 5974 * check whether the device shows up in other nodes
5960 */ 5975 */
@@ -7330,6 +7345,10 @@ static int md_seq_show(struct seq_file *seq, void *v)
7330 seq_printf(seq, "(F)"); 7345 seq_printf(seq, "(F)");
7331 continue; 7346 continue;
7332 } 7347 }
7348 if (test_bit(Journal, &rdev->flags)) {
7349 seq_printf(seq, "(J)");
7350 continue;
7351 }
7333 if (rdev->raid_disk < 0) 7352 if (rdev->raid_disk < 0)
7334 seq_printf(seq, "(S)"); /* spare */ 7353 seq_printf(seq, "(S)"); /* spare */
7335 if (test_bit(Replacement, &rdev->flags)) 7354 if (test_bit(Replacement, &rdev->flags))
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 2ea00356bb23..88dc6312f5d5 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -172,6 +172,11 @@ enum flag_bits {
172 * This device is seen locally but not 172 * This device is seen locally but not
173 * by the whole cluster 173 * by the whole cluster
174 */ 174 */
175 Journal, /* This device is used as journal for
176 * raid-5/6.
177 * Usually, this device should be faster
178 * than other devices in the array
179 */
175}; 180};
176 181
177#define BB_LEN_MASK (0x00000000000001FFULL) 182#define BB_LEN_MASK (0x00000000000001FFULL)
diff --git a/include/uapi/linux/raid/md_p.h b/include/uapi/linux/raid/md_p.h
index d1fc8a637368..eaaab52077a3 100644
--- a/include/uapi/linux/raid/md_p.h
+++ b/include/uapi/linux/raid/md_p.h
@@ -89,9 +89,11 @@
89 * read requests will only be sent here in 89 * read requests will only be sent here in
90 * dire need 90 * dire need
91 */ 91 */
92#define MD_DISK_JOURNAL 18 /* disk is used as the write journal in RAID-5/6 */
92 93
93#define MD_DISK_ROLE_SPARE 0xffff 94#define MD_DISK_ROLE_SPARE 0xffff
94#define MD_DISK_ROLE_FAULTY 0xfffe 95#define MD_DISK_ROLE_FAULTY 0xfffe
96#define MD_DISK_ROLE_JOURNAL 0xfffd
95#define MD_DISK_ROLE_MAX 0xff00 /* max value of regular disk role */ 97#define MD_DISK_ROLE_MAX 0xff00 /* max value of regular disk role */
96 98
97typedef struct mdp_device_descriptor_s { 99typedef struct mdp_device_descriptor_s {
@@ -307,6 +309,7 @@ struct mdp_superblock_1 {
307 * is guided by bitmap. 309 * is guided by bitmap.
308 */ 310 */
309#define MD_FEATURE_CLUSTERED 256 /* clustered MD */ 311#define MD_FEATURE_CLUSTERED 256 /* clustered MD */
312#define MD_FEATURE_JOURNAL 512 /* support write cache */
310#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \ 313#define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET \
311 |MD_FEATURE_RECOVERY_OFFSET \ 314 |MD_FEATURE_RECOVERY_OFFSET \
312 |MD_FEATURE_RESHAPE_ACTIVE \ 315 |MD_FEATURE_RESHAPE_ACTIVE \