]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.11.2/md-raid1-avoid-reusing-a-resync-bio-after-error-handling.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.11.2 / md-raid1-avoid-reusing-a-resync-bio-after-error-handling.patch
CommitLineData
5032628c
GKH
1From 0c9d5b127f695818c2c5a3868c1f28ca2969e905 Mon Sep 17 00:00:00 2001
2From: NeilBrown <neilb@suse.com>
3Date: Thu, 6 Apr 2017 12:06:37 +1000
4Subject: md/raid1: avoid reusing a resync bio after error handling.
5
6From: NeilBrown <neilb@suse.com>
7
8commit 0c9d5b127f695818c2c5a3868c1f28ca2969e905 upstream.
9
10fix_sync_read_error() modifies a bio on a newly faulty
11device by setting bi_end_io to end_sync_write.
12This ensure that put_buf() will still call rdev_dec_pending()
13as required, but makes sure that subsequent code in
14fix_sync_read_error() doesn't try to read from the device.
15
16Unfortunately this interacts badly with sync_request_write()
17which assumes that any bio with bi_end_io set to non-NULL
18other than end_sync_read is safe to write to.
19
20As the device is now faulty it doesn't make sense to write.
21As the bio was recently used for a read, it is "dirty"
22and not suitable for immediate submission.
23In particular, ->bi_next might be non-NULL, which will cause
24generic_make_request() to complain.
25
26Break this interaction by refusing to write to devices
27which are marked as Faulty.
28
29Reported-and-tested-by: Michael Wang <yun.wang@profitbricks.com>
30Fixes: 2e52d449bcec ("md/raid1: add failfast handling for reads.")
31Signed-off-by: NeilBrown <neilb@suse.com>
32Signed-off-by: Shaohua Li <shli@fb.com>
33Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35---
36 drivers/md/raid1.c | 2 ++
37 1 file changed, 2 insertions(+)
38
39--- a/drivers/md/raid1.c
40+++ b/drivers/md/raid1.c
41@@ -2222,6 +2222,8 @@ static void sync_request_write(struct md
42 (i == r1_bio->read_disk ||
43 !test_bit(MD_RECOVERY_SYNC, &mddev->recovery))))
44 continue;
45+ if (test_bit(Faulty, &conf->mirrors[i].rdev->flags))
46+ continue;
47
48 bio_set_op_attrs(wbio, REQ_OP_WRITE, 0);
49 if (test_bit(FailFast, &conf->mirrors[i].rdev->flags))