]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.12/dm-mpath-fix-stall-when-requeueing-io.patch
Remove duplicated commits
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.12 / dm-mpath-fix-stall-when-requeueing-io.patch
1 From knikanth@suse.de Mon Apr 19 11:23:07 2010
2 From: Nikanth Karthikesan <knikanth@suse.de>
3 Date: Fri, 26 Mar 2010 12:03:13 +0530
4 Subject: dm mpath: fix stall when requeueing io
5 To: stable@kernel.org
6 Cc: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>, Kiyoshi Ueda <k-ueda@ct.jp.nec.com>, Alasdair G Kergon <agk@redhat.com>
7 Message-ID: <201003261203.13503.knikanth@suse.de>
8
9 From: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
10
11 upstream commit 9eef87da2a8ea4920e0d913ff977cac064b68ee0 backported to
12 2.6.32.10 by Nikanth Karthikesan <knikanth@suse.de>
13
14 This patch fixes the problem that system may stall if target's ->map_rq
15 returns DM_MAPIO_REQUEUE in map_request().
16 E.g. stall happens on 1 CPU box when a dm-mpath device with queue_if_no_path
17 bounces between all-paths-down and paths-up on I/O load.
18
19 When target's ->map_rq returns DM_MAPIO_REQUEUE, map_request() requeues
20 the request and returns to dm_request_fn(). Then, dm_request_fn()
21 doesn't exit the I/O dispatching loop and continues processing
22 the requeued request again.
23 This map and requeue loop can be done with interrupt disabled,
24 so 1 CPU system can be stalled if this situation happens.
25
26 For example, commands below can stall my 1 CPU box within 1 minute or so:
27 # dmsetup table mp
28 mp: 0 2097152 multipath 1 queue_if_no_path 0 1 1 service-time 0 1 2 8:144 1 1
29 # while true; do dd if=/dev/mapper/mp of=/dev/null bs=1M count=100; done &
30 # while true; do \
31 > dmsetup message mp 0 "fail_path 8:144" \
32 > dmsetup suspend --noflush mp \
33 > dmsetup resume mp \
34 > dmsetup message mp 0 "reinstate_path 8:144" \
35 > done
36
37 To fix the problem above, this patch changes dm_request_fn() to exit
38 the I/O dispatching loop once if a request is requeued in map_request().
39
40 Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
41 Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
42 Signed-off-by: Alasdair G Kergon <agk@redhat.com>
43 Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
44 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
45
46 ---
47 drivers/md/dm.c | 21 +++++++++++++++++----
48 1 file changed, 17 insertions(+), 4 deletions(-)
49
50 --- a/drivers/md/dm.c
51 +++ b/drivers/md/dm.c
52 @@ -1487,10 +1487,15 @@ static int dm_prep_fn(struct request_que
53 return BLKPREP_OK;
54 }
55
56 -static void map_request(struct dm_target *ti, struct request *rq,
57 - struct mapped_device *md)
58 +/*
59 + * Returns:
60 + * 0 : the request has been processed (not requeued)
61 + * !0 : the request has been requeued
62 + */
63 +static int map_request(struct dm_target *ti, struct request *rq,
64 + struct mapped_device *md)
65 {
66 - int r;
67 + int r, requeued = 0;
68 struct request *clone = rq->special;
69 struct dm_rq_target_io *tio = clone->end_io_data;
70
71 @@ -1516,6 +1521,7 @@ static void map_request(struct dm_target
72 case DM_MAPIO_REQUEUE:
73 /* The target wants to requeue the I/O */
74 dm_requeue_unmapped_request(clone);
75 + requeued = 1;
76 break;
77 default:
78 if (r > 0) {
79 @@ -1527,6 +1533,8 @@ static void map_request(struct dm_target
80 dm_kill_unmapped_request(clone, r);
81 break;
82 }
83 +
84 + return requeued;
85 }
86
87 /*
88 @@ -1568,12 +1576,17 @@ static void dm_request_fn(struct request
89
90 blk_start_request(rq);
91 spin_unlock(q->queue_lock);
92 - map_request(ti, rq, md);
93 + if (map_request(ti, rq, md))
94 + goto requeued;
95 +
96 spin_lock_irq(q->queue_lock);
97 }
98
99 goto out;
100
101 +requeued:
102 + spin_lock_irq(q->queue_lock);
103 +
104 plug_and_out:
105 if (!elv_queue_empty(q))
106 /* Some requests still remain, retry later */