diff options
author | Yu Kuai <yukuai3@huawei.com> | 2024-02-29 12:57:04 +0300 |
---|---|---|
committer | Song Liu <song@kernel.org> | 2024-03-01 09:49:45 +0300 |
commit | 3a0f007b6979db6b5e0022d9edf4b61002be3e10 (patch) | |
tree | 569df8e35443f4d9a766f4d5fff9e8fa61a80321 /drivers/md/md.h | |
parent | dfd2bf436709b2bccb78c2dda550dde93700efa7 (diff) | |
download | linux-3a0f007b6979db6b5e0022d9edf4b61002be3e10.tar.xz |
md: add a new helper rdev_has_badblock()
The current api is_badblock() must pass in 'first_bad' and
'bad_sectors', however, many caller just want to know if there are
badblocks or not, and these caller must define two local variable that
will never be used.
Add a new helper rdev_has_badblock() that will only return if there are
badblocks or not, remove unnecessary local variables and replace
is_badblock() with the new helper in many places.
There are no functional changes, and the new helper will also be used
later to refactor read_balance().
Co-developed-by: Paul Luse <paul.e.luse@linux.intel.com>
Signed-off-by: Paul Luse <paul.e.luse@linux.intel.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240229095714.926789-2-yukuai1@huaweicloud.com
Diffstat (limited to 'drivers/md/md.h')
-rw-r--r-- | drivers/md/md.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/md/md.h b/drivers/md/md.h index 8d881cc59799..a49ab04ab707 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -222,6 +222,16 @@ static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors, } return 0; } + +static inline int rdev_has_badblock(struct md_rdev *rdev, sector_t s, + int sectors) +{ + sector_t first_bad; + int bad_sectors; + + return is_badblock(rdev, s, sectors, &first_bad, &bad_sectors); +} + extern int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors, int is_new); extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors, |