]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.32.19/md-raid10-fix-deadlock-with-unaligned-read-during-resync.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.19 / md-raid10-fix-deadlock-with-unaligned-read-during-resync.patch
CommitLineData
1762a8ed
GKH
1From 51e9ac77035a3dfcb6fc0a88a0d80b6f99b5edb1 Mon Sep 17 00:00:00 2001
2From: NeilBrown <neilb@suse.de>
3Date: Sat, 7 Aug 2010 21:17:00 +1000
4Subject: md/raid10: fix deadlock with unaligned read during resync
5
6From: NeilBrown <neilb@suse.de>
7
8commit 51e9ac77035a3dfcb6fc0a88a0d80b6f99b5edb1 upstream.
9
10If the 'bio_split' path in raid10-read is used while
11resync/recovery is happening it is possible to deadlock.
12Fix this be elevating ->nr_waiting for the duration of both
13parts of the split request.
14
15This fixes a bug that has been present since 2.6.22
16but has only started manifesting recently for unknown reasons.
17It is suitable for and -stable since then.
18
19Reported-by: Justin Bronder <jsbronder@gentoo.org>
20Tested-by: Justin Bronder <jsbronder@gentoo.org>
21Signed-off-by: NeilBrown <neilb@suse.de>
22Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
23
24---
25 drivers/md/raid10.c | 18 ++++++++++++++++++
26 1 file changed, 18 insertions(+)
27
28--- a/drivers/md/raid10.c
29+++ b/drivers/md/raid10.c
30@@ -824,11 +824,29 @@ static int make_request(struct request_q
31 */
32 bp = bio_split(bio,
33 chunk_sects - (bio->bi_sector & (chunk_sects - 1)) );
34+
35+ /* Each of these 'make_request' calls will call 'wait_barrier'.
36+ * If the first succeeds but the second blocks due to the resync
37+ * thread raising the barrier, we will deadlock because the
38+ * IO to the underlying device will be queued in generic_make_request
39+ * and will never complete, so will never reduce nr_pending.
40+ * So increment nr_waiting here so no new raise_barriers will
41+ * succeed, and so the second wait_barrier cannot block.
42+ */
43+ spin_lock_irq(&conf->resync_lock);
44+ conf->nr_waiting++;
45+ spin_unlock_irq(&conf->resync_lock);
46+
47 if (make_request(q, &bp->bio1))
48 generic_make_request(&bp->bio1);
49 if (make_request(q, &bp->bio2))
50 generic_make_request(&bp->bio2);
51
52+ spin_lock_irq(&conf->resync_lock);
53+ conf->nr_waiting--;
54+ wake_up(&conf->wait_barrier);
55+ spin_unlock_irq(&conf->resync_lock);
56+
57 bio_pair_release(bp);
58 return 0;
59 bad_map: