]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - 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
1 From 0c9d5b127f695818c2c5a3868c1f28ca2969e905 Mon Sep 17 00:00:00 2001
2 From: NeilBrown <neilb@suse.com>
3 Date: Thu, 6 Apr 2017 12:06:37 +1000
4 Subject: md/raid1: avoid reusing a resync bio after error handling.
5
6 From: NeilBrown <neilb@suse.com>
7
8 commit 0c9d5b127f695818c2c5a3868c1f28ca2969e905 upstream.
9
10 fix_sync_read_error() modifies a bio on a newly faulty
11 device by setting bi_end_io to end_sync_write.
12 This ensure that put_buf() will still call rdev_dec_pending()
13 as required, but makes sure that subsequent code in
14 fix_sync_read_error() doesn't try to read from the device.
15
16 Unfortunately this interacts badly with sync_request_write()
17 which assumes that any bio with bi_end_io set to non-NULL
18 other than end_sync_read is safe to write to.
19
20 As the device is now faulty it doesn't make sense to write.
21 As the bio was recently used for a read, it is "dirty"
22 and not suitable for immediate submission.
23 In particular, ->bi_next might be non-NULL, which will cause
24 generic_make_request() to complain.
25
26 Break this interaction by refusing to write to devices
27 which are marked as Faulty.
28
29 Reported-and-tested-by: Michael Wang <yun.wang@profitbricks.com>
30 Fixes: 2e52d449bcec ("md/raid1: add failfast handling for reads.")
31 Signed-off-by: NeilBrown <neilb@suse.com>
32 Signed-off-by: Shaohua Li <shli@fb.com>
33 Signed-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))