Skip to content

Commit 4abfce1

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: add a new helper rdev_blocked()
The helper will be used in later patches for raid1/raid10/raid5, the difference is that Faulty rdev with unacknowledged bad block will not be considered blocked. 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 1e79892 commit 4abfce1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/md/md.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,30 @@ static inline void mddev_trace_remap(struct mddev *mddev, struct bio *bio,
10021002
trace_block_bio_remap(bio, disk_devt(mddev->gendisk), sector);
10031003
}
10041004

1005+
static inline bool rdev_blocked(struct md_rdev *rdev)
1006+
{
1007+
/*
1008+
* Blocked will be set by error handler and cleared by daemon after
1009+
* updating superblock, meanwhile write IO should be blocked to prevent
1010+
* reading old data after power failure.
1011+
*/
1012+
if (test_bit(Blocked, &rdev->flags))
1013+
return true;
1014+
1015+
/*
1016+
* Faulty device should not be accessed anymore, there is no need to
1017+
* wait for bad block to be acknowledged.
1018+
*/
1019+
if (test_bit(Faulty, &rdev->flags))
1020+
return false;
1021+
1022+
/* rdev is blocked by badblocks. */
1023+
if (test_bit(BlockedBadBlocks, &rdev->flags))
1024+
return true;
1025+
1026+
return false;
1027+
}
1028+
10051029
#define mddev_add_trace_msg(mddev, fmt, args...) \
10061030
do { \
10071031
if (!mddev_is_dm(mddev)) \

0 commit comments

Comments
 (0)