Commit:     6ed3003c19a96fe18edf8179c4be6fe14abbebbc
Parent:     73c34431c7119d0bc7d3436abfad75fe47b2c51f
Author:     NeilBrown <[EMAIL PROTECTED]>
AuthorDate: Wed Feb 6 01:40:00 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Feb 6 10:41:19 2008 -0800

    md: fix an occasional deadlock in raid5
    raid5's 'make_request' function calls generic_make_request on underlying
    devices and if we run out of stripe heads, it could end up waiting for one 
    those requests to complete.  This is bad as recursive calls to
    generic_make_request go on a queue and are not even attempted until
    make_request completes.
    So: don't make any generic_make_request calls in raid5 make_request until 
    waiting has been done.  We do this by simply setting STRIPE_HANDLE instead 
    calling handle_stripe().
    If we need more stripe_heads, raid5d will get called to process the pending
    stripe_heads which will call generic_make_request from a
    This change by itself causes a performance hit.  So add a change so that
    raid5_activate_delayed is only called at unplug time, never in raid5.  This
    seems to bring back the performance numbers.  Calling it in raid5d was
    sometimes too soon...
    Neil said:
      How about we queue it for 2.6.25-rc1 and then about when -rc2 comes out,
      we queue it for 2.6.24.y?
    Acked-by: Dan Williams <[EMAIL PROTECTED]>
    Signed-off-by: Neil Brown <[EMAIL PROTECTED]>
    Tested-by: dean gaudet <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 drivers/md/raid5.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 63bfb07..2d6f1a5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3159,7 +3159,8 @@ static void raid5_activate_delayed(raid5_conf_t *conf)
                        list_add_tail(&sh->lru, &conf->handle_list);
-       }
+       } else
+               blk_plug_device(conf->mddev->queue);
 static void activate_bit_delay(raid5_conf_t *conf)
@@ -3549,7 +3550,8 @@ static int make_request(struct request_queue *q, struct 
bio * bi)
                                goto retry;
                        finish_wait(&conf->wait_for_overlap, &w);
-                       handle_stripe(sh, NULL);
+                       set_bit(STRIPE_HANDLE, &sh->state);
+                       clear_bit(STRIPE_DELAYED, &sh->state);
                } else {
                        /* cannot get stripe for read-ahead, just give-up */
@@ -3892,7 +3894,7 @@ static int  retry_aligned_read(raid5_conf_t *conf, struct 
bio *raid_bio)
  * During the scan, completed stripes are saved for us by the interrupt
  * handler, so that they will not have to wait for our next wakeup.
-static void raid5d (mddev_t *mddev)
+static void raid5d(mddev_t *mddev)
        struct stripe_head *sh;
        raid5_conf_t *conf = mddev_to_conf(mddev);
@@ -3917,12 +3919,6 @@ static void raid5d (mddev_t *mddev)
-               if (list_empty(&conf->handle_list) &&
-                   atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD &&
-                   !blk_queue_plugged(mddev->queue) &&
-                   !list_empty(&conf->delayed_list))
-                       raid5_activate_delayed(conf);
                while ((bio = remove_bio_from_retry(conf))) {
                        int ok;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to