From: NeilBrown <neilb@suse.de>
Git-commit: b357f04a67c2aeee828b240863cd3f21d6cb3179
Subject: md/raid10: make sure we don't miss an unplug
Patch-mainline: 3.6
References: bnc#768084

A plug automatically gets unplugged on every 'schedule', so if
bio_clone_mddev needs to wait for something, we lose our plug but
think we still have it.  So we might not wake the thread when we
should.  So move the 'check_plugged' closer to the place where we
actually need the plug to be active.

Signed-off-by: Neil Brown <neilb@suse.de>

---
 drivers/md/raid10.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-3.0-SLE11-SP2-BTMU.orig/drivers/md/raid10.c
+++ linux-3.0-SLE11-SP2-BTMU/drivers/md/raid10.c
@@ -908,7 +908,7 @@ static int make_request(mddev_t *mddev,
 	const unsigned long do_fua = (bio->bi_rw & REQ_FUA);
 	unsigned long flags;
 	mdk_rdev_t *blocked_rdev;
-	int plugged;
+	int plugged = 1;
 	int sectors;
 
 	if (unlikely(bio->bi_rw & REQ_FLUSH)) {
@@ -1057,7 +1057,6 @@ static int make_request(mddev_t *mddev,
 	 * inc refcount on their rdev.  Record them by setting
 	 * bios[x] to bio
 	 */
-	plugged = mddev_check_plugged(mddev);
 
 	raid10_find_phys(conf, r10_bio);
  retry_write:
@@ -1122,6 +1121,7 @@ static int make_request(mddev_t *mddev,
 			mbio->bi_rw |= REQ_FAILFAST_DEV;
 		mbio->bi_private = r10_bio;
 
+		plugged = mddev_check_plugged(mddev);
 		atomic_inc(&r10_bio->remaining);
 		spin_lock_irqsave(&conf->device_lock, flags);
 		trace_block_bio_remap(bdev_get_queue(mbio->bi_bdev),
