Skip to content

Commit d595567

Browse files
committed
MD: fix invalid stored role for a disk
If we change the number of array's device after device is removed from array, then add the device back to array, we can see that device is added as active role instead of spare which we expected. Please see the below link for details: https://marc.info/?l=linux-raid&m=153736982015076&w=2 This is caused by that we prefer to use device's previous role which is recorded by saved_raid_disk, but we should respect the new number of conf->raid_disks since it could be changed after device is removed. Reported-by: Gioh Kim <[email protected]> Tested-by: Gioh Kim <[email protected]> Acked-by: Guoqing Jiang <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent ee37d73 commit d595567

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/md/md.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,10 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
17741774
} else
17751775
set_bit(In_sync, &rdev->flags);
17761776
rdev->raid_disk = role;
1777+
if (role >= mddev->raid_disks) {
1778+
rdev->saved_raid_disk = -1;
1779+
rdev->raid_disk = -1;
1780+
}
17771781
break;
17781782
}
17791783
if (sb->devflags & WriteMostly1)

0 commit comments

Comments
 (0)