diff options
author | Song Liu <songliubraving@fb.com> | 2015-08-13 14:31:55 -0700 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2015-10-24 17:16:18 +1100 |
commit | bac624f3f86a8c7db395c7f85ccad6a504b9c4b4 (patch) | |
tree | 0b9240c0fb33d6adf4ddcfd85afd95321cc96552 /drivers/md/md.c | |
parent | c4d4c91b44d8309082127893221a1971a27c50ca (diff) | |
download | linux-bac624f3f86a8c7db395c7f85ccad6a504b9c4b4.tar.gz linux-bac624f3f86a8c7db395c7f85ccad6a504b9c4b4.tar.bz2 linux-bac624f3f86a8c7db395c7f85ccad6a504b9c4b4.zip |
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>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 23 |
1 files changed, 21 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) 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<<MD_DISK_ACTIVE); info.state |= (1<<MD_DISK_SYNC); - } + } else if (test_bit(Journal, &rdev->flags)) + info.state |= (1<<MD_DISK_JOURNAL); if (test_bit(WriteMostly, &rdev->flags)) info.state |= (1<<MD_DISK_WRITEMOSTLY); } else { @@ -5955,6 +5968,8 @@ static int add_new_disk(struct mddev *mddev, mdu_disk_info_t *info) else clear_bit(WriteMostly, &rdev->flags); + if (info->state & (1<<MD_DISK_JOURNAL)) + set_bit(Journal, &rdev->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)) |