Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yukuai3@huawei.com>
Tested-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Link: https://lore.kernel.org/r/20241031033114.3845582-2-yukuai1@huaweicloud.com
Signed-off-by: Song Liu <song@kernel.org>

authored by

Yu Kuai and committed by
Song Liu
4abfce19 1e79892e

+24
+24
drivers/md/md.h
··· 1002 1002 trace_block_bio_remap(bio, disk_devt(mddev->gendisk), sector); 1003 1003 } 1004 1004 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 + 1005 1029 #define mddev_add_trace_msg(mddev, fmt, args...) \ 1006 1030 do { \ 1007 1031 if (!mddev_is_dm(mddev)) \