提交 bebf3d97 编写于 作者: L Li Nan 提交者: Jialin Zhang

md: fix unexpected changes of return value in rdev_set_badblocks

hulk inclusion
category: bugfix
bugzilla: 188569, https://gitee.com/openeuler/kernel/issues/I6XBZQ
CVE: NA

--------------------------------

If we set any badblocks fail, we will remove this rdev(set it to Faulty
or set recovery_disabled). Previous patch "md/raid10: fix io hung in
md_wait_for_blocked_rdev()" check badblocks->changed instead of return
value in rdev_set_badblocks(), but return value of this func also changed
accordingly, which is not what we expected.

Keep the return value consistent with before.
Signed-off-by: NLi Nan <linan122@huawei.com>
Reviewed-by: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
上级 c23e1cd1
...@@ -9577,12 +9577,13 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors, ...@@ -9577,12 +9577,13 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
int is_new) int is_new)
{ {
struct mddev *mddev = rdev->mddev; struct mddev *mddev = rdev->mddev;
int rv;
if (is_new) if (is_new)
s += rdev->new_data_offset; s += rdev->new_data_offset;
else else
s += rdev->data_offset; s += rdev->data_offset;
badblocks_set(&rdev->badblocks, s, sectors, 0); rv = badblocks_set(&rdev->badblocks, s, sectors, 0);
if (rdev->badblocks.changed) { if (rdev->badblocks.changed) {
/* Make sure they get written out promptly */ /* Make sure they get written out promptly */
if (test_bit(ExternalBbl, &rdev->flags)) if (test_bit(ExternalBbl, &rdev->flags))
...@@ -9591,9 +9592,8 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors, ...@@ -9591,9 +9592,8 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
set_mask_bits(&mddev->sb_flags, 0, set_mask_bits(&mddev->sb_flags, 0,
BIT(MD_SB_CHANGE_CLEAN) | BIT(MD_SB_CHANGE_PENDING)); BIT(MD_SB_CHANGE_CLEAN) | BIT(MD_SB_CHANGE_PENDING));
md_wakeup_thread(rdev->mddev->thread); md_wakeup_thread(rdev->mddev->thread);
return 1; }
} else return !rv;
return 0;
} }
EXPORT_SYMBOL_GPL(rdev_set_badblocks); EXPORT_SYMBOL_GPL(rdev_set_badblocks);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册