Commit f9a25f25 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman

md/raid1: avoid reusing a resync bio after error handling.

commit 0c9d5b12 upstream.

fix_sync_read_error() modifies a bio on a newly faulty
device by setting bi_end_io to end_sync_write.
This ensure that put_buf() will still call rdev_dec_pending()
as required, but makes sure that subsequent code in
fix_sync_read_error() doesn't try to read from the device.

Unfortunately this interacts badly with sync_request_write()
which assumes that any bio with bi_end_io set to non-NULL
other than end_sync_read is safe to write to.

As the device is now faulty it doesn't make sense to write.
As the bio was recently used for a read, it is "dirty"
and not suitable for immediate submission.
In particular, ->bi_next might be non-NULL, which will cause
generic_make_request() to complain.

Break this interaction by refusing to write to devices
which are marked as Faulty.
Reported-and-tested-by: default avatarMichael Wang <yun.wang@profitbricks.com>
Fixes: 2e52d449 ("md/raid1: add failfast handling for reads.")
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3848f89a
...@@ -2067,6 +2067,8 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio) ...@@ -2067,6 +2067,8 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
(i == r1_bio->read_disk || (i == r1_bio->read_disk ||
!test_bit(MD_RECOVERY_SYNC, &mddev->recovery)))) !test_bit(MD_RECOVERY_SYNC, &mddev->recovery))))
continue; continue;
if (test_bit(Faulty, &conf->mirrors[i].rdev->flags))
continue;
wbio->bi_rw = WRITE; wbio->bi_rw = WRITE;
wbio->bi_end_io = end_sync_write; wbio->bi_end_io = end_sync_write;
......
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