Commit 1cd972e0 authored by Yufen Yu's avatar Yufen Yu Committed by Greg Kroah-Hartman

md/raid1: end bio when the device faulty

[ Upstream commit eeba6809 ]

When write bio return error, it would be added to conf->retry_list
and wait for raid1d thread to retry write and acknowledge badblocks.

In narrow_write_error(), the error bio will be split in the unit of
badblock shift (such as one sector) and raid1d thread issues them
one by one. Until all of the splited bio has finished, raid1d thread
can go on processing other things, which is time consuming.

But, there is a scene for error handling that is not necessary.
When the device has been set faulty, flush_bio_list() may end
bios in pending_bio_list with error status. Since these bios
has not been issued to the device actually, error handlding to
retry write and acknowledge badblocks make no sense.

Even without that scene, when the device is faulty, badblocks info
can not be written out to the device. Thus, we also no need to
handle the error IO.
Signed-off-by: default avatarYufen Yu <yuyufen@huawei.com>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 7d75275f
...@@ -434,19 +434,21 @@ static void raid1_end_write_request(struct bio *bio) ...@@ -434,19 +434,21 @@ static void raid1_end_write_request(struct bio *bio)
/* We never try FailFast to WriteMostly devices */ /* We never try FailFast to WriteMostly devices */
!test_bit(WriteMostly, &rdev->flags)) { !test_bit(WriteMostly, &rdev->flags)) {
md_error(r1_bio->mddev, rdev); md_error(r1_bio->mddev, rdev);
if (!test_bit(Faulty, &rdev->flags)) }
/* This is the only remaining device,
* We need to retry the write without /*
* FailFast * When the device is faulty, it is not necessary to
*/ * handle write error.
set_bit(R1BIO_WriteError, &r1_bio->state); * For failfast, this is the only remaining device,
else { * We need to retry the write without FailFast.
/* Finished with this branch */ */
r1_bio->bios[mirror] = NULL; if (!test_bit(Faulty, &rdev->flags))
to_put = bio;
}
} else
set_bit(R1BIO_WriteError, &r1_bio->state); set_bit(R1BIO_WriteError, &r1_bio->state);
else {
/* Finished with this branch */
r1_bio->bios[mirror] = NULL;
to_put = bio;
}
} else { } else {
/* /*
* Set R1BIO_Uptodate in our master bio, so that we * Set R1BIO_Uptodate in our master bio, so that we
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment