From bac624f3f86a8c7db395c7f85ccad6a504b9c4b4 Mon Sep 17 00:00:00 2001 From: Song Liu Date: Thu, 13 Aug 2015 14:31:55 -0700 Subject: 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 Signed-off-by: Shaohua Li Signed-off-by: NeilBrown --- drivers/md/md.c | 23 +++++++++++++++++++++-- drivers/md/md.h | 5 +++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'drivers/md') 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) case MD_DISK_ROLE_FAULTY: /* faulty */ set_bit(Faulty, &rdev->flags); break; + case MD_DISK_ROLE_JOURNAL: /* journal device */ + if (!(le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL)) { + /* journal device without journal feature */ + printk(KERN_WARNING + "md: journal device provided without journal feature, ignoring the device\n"); + return -EINVAL; + } + set_bit(Journal, &rdev->flags); + break; default: rdev->saved_raid_disk = role; if ((le32_to_cpu(sb->feature_map) & @@ -1796,7 +1805,10 @@ retry: sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_FAULTY); else if (test_bit(In_sync, &rdev2->flags)) sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); - else if (rdev2->raid_disk >= 0) + else if (test_bit(Journal, &rdev2->flags)) { + sb->dev_roles[i] = cpu_to_le16(MD_DISK_ROLE_JOURNAL); + sb->feature_map |= cpu_to_le32(MD_FEATURE_JOURNAL); + } else if (rdev2->raid_disk >= 0) sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); else 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) else if (test_bit(In_sync, &rdev->flags)) { info.state |= (1<flags)) + info.state |= (1<flags)) info.state |= (1<flags); + if (info->state & (1<flags); /* * check whether the device shows up in other nodes */ @@ -7330,6 +7345,10 @@ static int md_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "(F)"); continue; } + if (test_bit(Journal, &rdev->flags)) { + seq_printf(seq, "(J)"); + continue; + } if (rdev->raid_disk < 0) seq_printf(seq, "(S)"); /* spare */ 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 { * This device is seen locally but not * by the whole cluster */ + Journal, /* This device is used as journal for + * raid-5/6. + * Usually, this device should be faster + * than other devices in the array + */ }; #define BB_LEN_MASK (0x00000000000001FFULL) -- cgit v1.2.3