Skip to content

Commit 2996733

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: don't record new badblocks for faulty rdev
Faulty will be checked before issuing IO to the rdev, however, rdev can be faulty at any time, hence it's possible that rdev_set_badblocks() will be called for faulty rdev. In this case, mddev->sb_flags will be set and some other path can be blocked by updating super block. Since faulty rdev will not be accesed anymore, there is no need to record new babblocks for faulty rdev and forcing updating super block. Noted this is not a bugfix, just prevent updating superblock in some corner cases, and will help to slice a bug related to external metadata[1], testing also shows that devices are removed faster in the case IO error. [1] https://lore.kernel.org/all/[email protected]/ Signed-off-by: Yu Kuai <[email protected]> Tested-by: Mariusz Tkaczyk <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent 50e8274 commit 2996733

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/md/md.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9791,6 +9791,17 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
97919791
{
97929792
struct mddev *mddev = rdev->mddev;
97939793
int rv;
9794+
9795+
/*
9796+
* Recording new badblocks for faulty rdev will force unnecessary
9797+
* super block updating. This is fragile for external management because
9798+
* userspace daemon may trying to remove this device and deadlock may
9799+
* occur. This will be probably solved in the mdadm, but it is safer to
9800+
* avoid it.
9801+
*/
9802+
if (test_bit(Faulty, &rdev->flags))
9803+
return 1;
9804+
97949805
if (is_new)
97959806
s += rdev->new_data_offset;
97969807
else

0 commit comments

Comments
 (0)