mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
md: add rdev_record_write_error() helper
The WriteErrorSeen + WantReplacement + MD_RECOVERY_NEEDED sequence is duplicated across raid1, raid10 and raid5. Factor it into a small inline helper for readability. No functional change. Signed-off-by: Li Youhong <liyouhong@kylinos.cn> Link: https://patch.msgid.link/20260827075620.3599227-2-dayou5941@163.com Signed-off-by: Yu Kuai <yukuai@fygo.io>
This commit is contained in:
parent
370ca0760b
commit
0a7465dcb4
|
|
@ -989,6 +989,13 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void rdev_record_write_error(struct md_rdev *rdev)
|
||||
{
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery);
|
||||
}
|
||||
|
||||
static inline int mddev_is_clustered(struct mddev *mddev)
|
||||
{
|
||||
return mddev->cluster_info && mddev->bitmap_info.nodes > 1;
|
||||
|
|
|
|||
|
|
@ -483,10 +483,7 @@ static void raid1_end_write_request(struct bio *bio)
|
|||
* 'one mirror IO has finished' event handler:
|
||||
*/
|
||||
if (bio->bi_status && !ignore_error) {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED, &
|
||||
conf->mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
|
||||
if (test_bit(FailFast, &rdev->flags) &&
|
||||
(bio->bi_opf & MD_FAILFAST) &&
|
||||
|
|
@ -2067,10 +2064,7 @@ static void end_sync_write(struct bio *bio)
|
|||
|
||||
if (bio->bi_status) {
|
||||
abort_sync_write(mddev, r1_bio);
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED, &
|
||||
mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
set_bit(R1BIO_WriteError, &r1_bio->state);
|
||||
} else if (rdev_has_badblock(rdev, r1_bio->sector, r1_bio->sectors) &&
|
||||
!rdev_has_badblock(conf->mirrors[r1_bio->read_disk].rdev,
|
||||
|
|
@ -2088,11 +2082,7 @@ static int r1_sync_page_io(struct md_rdev *rdev, sector_t sector,
|
|||
/* success */
|
||||
return 1;
|
||||
if (rw == REQ_OP_WRITE) {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement,
|
||||
&rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED, &
|
||||
rdev->mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
}
|
||||
/* need to record an error - either for the block or the device */
|
||||
rdev_set_badblocks(rdev, sector, sectors, 0);
|
||||
|
|
|
|||
|
|
@ -496,10 +496,7 @@ static void raid10_end_write_request(struct bio *bio)
|
|||
*/
|
||||
md_error(rdev->mddev, rdev);
|
||||
else {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED,
|
||||
&rdev->mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
|
||||
dec_rdev = 0;
|
||||
if (test_bit(FailFast, &rdev->flags) &&
|
||||
|
|
@ -2300,10 +2297,7 @@ static void end_sync_write(struct bio *bio)
|
|||
if (repl)
|
||||
md_error(mddev, rdev);
|
||||
else {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED,
|
||||
&rdev->mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
set_bit(R10BIO_WriteError, &r10_bio->state);
|
||||
}
|
||||
} else if (rdev_has_badblock(rdev, r10_bio->devs[slot].addr,
|
||||
|
|
@ -2501,11 +2495,7 @@ static void fix_recovery_read_error(struct r10bio *r10_bio)
|
|||
pages[idx],
|
||||
REQ_OP_WRITE, false);
|
||||
if (!ok) {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement,
|
||||
&rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED,
|
||||
&rdev->mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
|
|
@ -2586,10 +2576,7 @@ static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
|
|||
/* success */
|
||||
return 1;
|
||||
if (op == REQ_OP_WRITE) {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED,
|
||||
&rdev->mddev->recovery);
|
||||
rdev_record_write_error(rdev);
|
||||
}
|
||||
/* need to record an error - either for the block or the device */
|
||||
rdev_set_badblocks(rdev, sector, sectors, 0);
|
||||
|
|
|
|||
|
|
@ -2889,11 +2889,8 @@ static void raid5_end_write_request(struct bio *bi)
|
|||
set_bit(R5_MadeGoodRepl, &sh->dev[i].flags);
|
||||
} else {
|
||||
if (bi->bi_status) {
|
||||
set_bit(WriteErrorSeen, &rdev->flags);
|
||||
rdev_record_write_error(rdev);
|
||||
set_bit(R5_WriteError, &sh->dev[i].flags);
|
||||
if (!test_and_set_bit(WantReplacement, &rdev->flags))
|
||||
set_bit(MD_RECOVERY_NEEDED,
|
||||
&rdev->mddev->recovery);
|
||||
} else if (rdev_has_badblock(rdev, sh->sector,
|
||||
RAID5_STRIPE_SECTORS(conf))) {
|
||||
set_bit(R5_MadeGood, &sh->dev[i].flags);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user