drop slub-fix-possible-NULL-pointer-dereference.patch
[linux-2.6.22.y-op-patches.git] / queue-2.6.22.y / md-fix-an-occasional-deadlock-in-raid5.patch
blob41399efab2ca9ac7eace16207942bca1fa6fb85e
1 Patch-mainline: 2.6.25
2 References: 357088
3 Git-commit: 6ed3003c19a96fe18edf8179c4be6fe14abbebbc
4 From: NeilBrown <neilb@suse.de>
5 Date: Wed, 6 Feb 2008 01:40:00 -0800
6 Subject: [PATCH] md: fix an occasional deadlock in raid5
8 raid5's 'make_request' function calls generic_make_request on underlying
9 devices and if we run out of stripe heads, it could end up waiting for one of
10 those requests to complete. This is bad as recursive calls to
11 generic_make_request go on a queue and are not even attempted until
12 make_request completes.
14 So: don't make any generic_make_request calls in raid5 make_request until all
15 waiting has been done. We do this by simply setting STRIPE_HANDLE instead of
16 calling handle_stripe().
18 If we need more stripe_heads, raid5d will get called to process the pending
19 stripe_heads which will call generic_make_request from a
21 This change by itself causes a performance hit. So add a change so that
22 raid5_activate_delayed is only called at unplug time, never in raid5. This
23 seems to bring back the performance numbers. Calling it in raid5d was
24 sometimes too soon...
26 Neil said:
28 How about we queue it for 2.6.25-rc1 and then about when -rc2 comes out,
29 we queue it for 2.6.24.y?
31 Acked-by: Dan Williams <dan.j.williams@intel.com>
32 Signed-off-by: Neil Brown <neilb@suse.de>
33 Tested-by: dean gaudet <dean@arctic.org>
34 Cc: <stable@kernel.org>
35 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
36 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
37 Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
39 ---
40 drivers/md/raid5.c | 14 +++++---------
41 1 file changed, 5 insertions(+), 9 deletions(-)
43 --- linux-2.6.22-SL103_BRANCH.orig/drivers/md/raid5.c
44 +++ linux-2.6.22-SL103_BRANCH/drivers/md/raid5.c
45 @@ -2525,7 +2525,8 @@ static void raid5_activate_delayed(raid5
46 atomic_inc(&conf->preread_active_stripes);
47 list_add_tail(&sh->lru, &conf->handle_list);
49 - }
50 + } else
51 + blk_plug_device(conf->mddev->queue);
54 static void activate_bit_delay(raid5_conf_t *conf)
55 @@ -2949,7 +2950,8 @@ static int make_request(request_queue_t
56 goto retry;
58 finish_wait(&conf->wait_for_overlap, &w);
59 - handle_stripe(sh, NULL);
60 + set_bit(STRIPE_HANDLE, &sh->state);
61 + clear_bit(STRIPE_DELAYED, &sh->state);
62 release_stripe(sh);
63 } else {
64 /* cannot get stripe for read-ahead, just give-up */
65 @@ -3267,7 +3269,7 @@ static int retry_aligned_read(raid5_con
66 * During the scan, completed stripes are saved for us by the interrupt
67 * handler, so that they will not have to wait for our next wakeup.
69 -static void raid5d (mddev_t *mddev)
70 +static void raid5d(mddev_t *mddev)
72 struct stripe_head *sh;
73 raid5_conf_t *conf = mddev_to_conf(mddev);
74 @@ -3292,12 +3294,6 @@ static void raid5d (mddev_t *mddev)
75 activate_bit_delay(conf);
78 - if (list_empty(&conf->handle_list) &&
79 - atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD &&
80 - !blk_queue_plugged(mddev->queue) &&
81 - !list_empty(&conf->delayed_list))
82 - raid5_activate_delayed(conf);
84 while ((bio = remove_bio_from_retry(conf))) {
85 int ok;
86 spin_unlock_irq(&conf->device_lock);