Commit f2076e7d authored by Shaohua Li's avatar Shaohua Li Committed by NeilBrown

MD: set journal disk ->raid_disk

Set journal disk ->raid_disk to >=0, I choose raid_disks + 1 instead of
0, because we already have a disk with ->raid_disk 0 and this causes
sysfs entry creation conflict. A lot of places assumes disk with
->raid_disk >=0 is normal raid disk, so we add check for journal disk.
Signed-off-by: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
parent a3dfbdaa
...@@ -1650,6 +1650,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1650,6 +1650,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
rdev->journal_tail = le64_to_cpu(sb->journal_tail); rdev->journal_tail = le64_to_cpu(sb->journal_tail);
if (mddev->recovery_cp == MaxSector) if (mddev->recovery_cp == MaxSector)
set_bit(MD_JOURNAL_CLEAN, &mddev->flags); set_bit(MD_JOURNAL_CLEAN, &mddev->flags);
rdev->raid_disk = mddev->raid_disks;
break; break;
default: default:
rdev->saved_raid_disk = role; rdev->saved_raid_disk = role;
...@@ -1719,7 +1720,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1719,7 +1720,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
} }
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 && !test_bit(Journal, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags)) { !test_bit(In_sync, &rdev->flags)) {
sb->feature_map |= sb->feature_map |=
cpu_to_le32(MD_FEATURE_RECOVERY_OFFSET); cpu_to_le32(MD_FEATURE_RECOVERY_OFFSET);
...@@ -2304,6 +2305,7 @@ void md_update_sb(struct mddev *mddev, int force_change) ...@@ -2304,6 +2305,7 @@ void md_update_sb(struct mddev *mddev, int force_change)
rdev_for_each(rdev, mddev) { rdev_for_each(rdev, mddev) {
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
mddev->delta_disks >= 0 && mddev->delta_disks >= 0 &&
!test_bit(Journal, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
mddev->curr_resync_completed > rdev->recovery_offset) mddev->curr_resync_completed > rdev->recovery_offset)
rdev->recovery_offset = mddev->curr_resync_completed; rdev->recovery_offset = mddev->curr_resync_completed;
...@@ -2540,6 +2542,7 @@ state_show(struct md_rdev *rdev, char *page) ...@@ -2540,6 +2542,7 @@ state_show(struct md_rdev *rdev, char *page)
sep = ","; sep = ",";
} }
if (!test_bit(Faulty, &flags) && if (!test_bit(Faulty, &flags) &&
!test_bit(Journal, &flags) &&
!test_bit(In_sync, &flags)) { !test_bit(In_sync, &flags)) {
len += sprintf(page+len, "%sspare", sep); len += sprintf(page+len, "%sspare", sep);
sep = ","; sep = ",";
...@@ -2626,7 +2629,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2626,7 +2629,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
} else if (cmd_match(buf, "insync") && rdev->raid_disk == -1) { } else if (cmd_match(buf, "insync") && rdev->raid_disk == -1) {
set_bit(In_sync, &rdev->flags); set_bit(In_sync, &rdev->flags);
err = 0; err = 0;
} else if (cmd_match(buf, "-insync") && rdev->raid_disk >= 0) { } else if (cmd_match(buf, "-insync") && rdev->raid_disk >= 0 &&
!test_bit(Journal, &rdev->flags)) {
if (rdev->mddev->pers == NULL) { if (rdev->mddev->pers == NULL) {
clear_bit(In_sync, &rdev->flags); clear_bit(In_sync, &rdev->flags);
rdev->saved_raid_disk = rdev->raid_disk; rdev->saved_raid_disk = rdev->raid_disk;
...@@ -2645,6 +2649,7 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2645,6 +2649,7 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
* check if recovery is needed. * check if recovery is needed.
*/ */
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(Journal, &rdev->flags) &&
!test_bit(Replacement, &rdev->flags)) !test_bit(Replacement, &rdev->flags))
set_bit(WantReplacement, &rdev->flags); set_bit(WantReplacement, &rdev->flags);
set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery);
...@@ -2722,7 +2727,9 @@ __ATTR(errors, S_IRUGO|S_IWUSR, errors_show, errors_store); ...@@ -2722,7 +2727,9 @@ __ATTR(errors, S_IRUGO|S_IWUSR, errors_show, errors_store);
static ssize_t static ssize_t
slot_show(struct md_rdev *rdev, char *page) slot_show(struct md_rdev *rdev, char *page)
{ {
if (rdev->raid_disk < 0) if (test_bit(Journal, &rdev->flags))
return sprintf(page, "journal\n");
else if (rdev->raid_disk < 0)
return sprintf(page, "none\n"); return sprintf(page, "none\n");
else else
return sprintf(page, "%d\n", rdev->raid_disk); return sprintf(page, "%d\n", rdev->raid_disk);
...@@ -2734,6 +2741,8 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2734,6 +2741,8 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
int slot; int slot;
int err; int err;
if (test_bit(Journal, &rdev->flags))
return -EBUSY;
if (strncmp(buf, "none", 4)==0) if (strncmp(buf, "none", 4)==0)
slot = -1; slot = -1;
else { else {
...@@ -2932,6 +2941,8 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2932,6 +2941,8 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len)
sector_t oldsectors = rdev->sectors; sector_t oldsectors = rdev->sectors;
sector_t sectors; sector_t sectors;
if (test_bit(Journal, &rdev->flags))
return -EBUSY;
if (strict_blocks_to_sectors(buf, &sectors) < 0) if (strict_blocks_to_sectors(buf, &sectors) < 0)
return -EINVAL; return -EINVAL;
if (rdev->data_offset != rdev->new_data_offset) if (rdev->data_offset != rdev->new_data_offset)
...@@ -3294,7 +3305,9 @@ static void analyze_sbs(struct mddev *mddev) ...@@ -3294,7 +3305,9 @@ static void analyze_sbs(struct mddev *mddev)
rdev->desc_nr = i++; rdev->desc_nr = i++;
rdev->raid_disk = rdev->desc_nr; rdev->raid_disk = rdev->desc_nr;
set_bit(In_sync, &rdev->flags); set_bit(In_sync, &rdev->flags);
} else if (rdev->raid_disk >= (mddev->raid_disks - min(0, mddev->delta_disks))) { } else if (rdev->raid_disk >=
(mddev->raid_disks - min(0, mddev->delta_disks)) &&
!test_bit(Journal, &rdev->flags)) {
rdev->raid_disk = -1; rdev->raid_disk = -1;
clear_bit(In_sync, &rdev->flags); clear_bit(In_sync, &rdev->flags);
} }
...@@ -7825,6 +7838,7 @@ void md_do_sync(struct md_thread *thread) ...@@ -7825,6 +7838,7 @@ void md_do_sync(struct md_thread *thread)
rcu_read_lock(); rcu_read_lock();
rdev_for_each_rcu(rdev, mddev) rdev_for_each_rcu(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(Journal, &rdev->flags) &&
!test_bit(Faulty, &rdev->flags) && !test_bit(Faulty, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
rdev->recovery_offset < j) rdev->recovery_offset < j)
...@@ -8050,6 +8064,7 @@ void md_do_sync(struct md_thread *thread) ...@@ -8050,6 +8064,7 @@ void md_do_sync(struct md_thread *thread)
rdev_for_each_rcu(rdev, mddev) rdev_for_each_rcu(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
mddev->delta_disks >= 0 && mddev->delta_disks >= 0 &&
!test_bit(Journal, &rdev->flags) &&
!test_bit(Faulty, &rdev->flags) && !test_bit(Faulty, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
rdev->recovery_offset < mddev->curr_resync) rdev->recovery_offset < mddev->curr_resync)
...@@ -8095,7 +8110,8 @@ static int remove_and_add_spares(struct mddev *mddev, ...@@ -8095,7 +8110,8 @@ static int remove_and_add_spares(struct mddev *mddev,
rdev->raid_disk >= 0 && rdev->raid_disk >= 0 &&
!test_bit(Blocked, &rdev->flags) && !test_bit(Blocked, &rdev->flags) &&
(test_bit(Faulty, &rdev->flags) || (test_bit(Faulty, &rdev->flags) ||
! test_bit(In_sync, &rdev->flags)) && (!test_bit(In_sync, &rdev->flags) &&
!test_bit(Journal, &rdev->flags))) &&
atomic_read(&rdev->nr_pending)==0) { atomic_read(&rdev->nr_pending)==0) {
if (mddev->pers->hot_remove_disk( if (mddev->pers->hot_remove_disk(
mddev, rdev) == 0) { mddev, rdev) == 0) {
...@@ -8117,6 +8133,7 @@ static int remove_and_add_spares(struct mddev *mddev, ...@@ -8117,6 +8133,7 @@ static int remove_and_add_spares(struct mddev *mddev,
continue; continue;
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
!test_bit(Journal, &rdev->flags) &&
!test_bit(Faulty, &rdev->flags)) !test_bit(Faulty, &rdev->flags))
spares++; spares++;
if (rdev->raid_disk >= 0) if (rdev->raid_disk >= 0)
......
...@@ -6560,7 +6560,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) ...@@ -6560,7 +6560,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
rdev_for_each(rdev, mddev) { rdev_for_each(rdev, mddev) {
raid_disk = rdev->raid_disk; raid_disk = rdev->raid_disk;
if (raid_disk >= max_disks if (raid_disk >= max_disks
|| raid_disk < 0) || raid_disk < 0 || test_bit(Journal, &rdev->flags))
continue; continue;
disk = conf->disks + raid_disk; disk = conf->disks + raid_disk;
...@@ -6694,8 +6694,10 @@ static int run(struct mddev *mddev) ...@@ -6694,8 +6694,10 @@ static int run(struct mddev *mddev)
rdev_for_each(rdev, mddev) { rdev_for_each(rdev, mddev) {
long long diff; long long diff;
if (test_bit(Journal, &rdev->flags)) if (test_bit(Journal, &rdev->flags)) {
journal_dev = rdev; journal_dev = rdev;
continue;
}
if (rdev->raid_disk < 0) if (rdev->raid_disk < 0)
continue; continue;
diff = (rdev->new_data_offset - rdev->data_offset); diff = (rdev->new_data_offset - rdev->data_offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment