From 5cf7286560ac39367f99319694dda889047208ca Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader@canonical.com>
Date: Tue, 17 May 2011 17:45:00 +0200
Subject: [PATCH] UBUNTU: iscsitarget: Convert to new plugging method

The block device plugging used to be per-queue and implicitly
done when requests where added to an empty queue. Now callers
have to plug and unplug per-task.

This fixes a FTBS with 2.6.39 kernel code.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 debian.master/config/config.common.ubuntu |    2 +-
 ubuntu/iscsitarget/block-io.c             |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu
index cc4c4fe..12ddcdd 100644
--- a/debian.master/config/config.common.ubuntu
+++ b/debian.master/config/config.common.ubuntu
@@ -4096,7 +4096,7 @@ CONFIG_SCSI_IN2000=m
 CONFIG_SCSI_INIA100=m
 CONFIG_SCSI_INITIO=m
 CONFIG_SCSI_IPS=m
-# CONFIG_SCSI_ISCSITARGET is not set
+CONFIG_SCSI_ISCSITARGET=m
 CONFIG_SCSI_ISCSI_ATTRS=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
 # CONFIG_SCSI_IZIP_SLOW_CTR is not set
diff --git a/ubuntu/iscsitarget/block-io.c b/ubuntu/iscsitarget/block-io.c
index 3e7de38..e3c9e19 100644
--- a/ubuntu/iscsitarget/block-io.c
+++ b/ubuntu/iscsitarget/block-io.c
@@ -56,6 +56,7 @@ blockio_make_request(struct iet_volume *volume, struct tio *tio, int rw)
 	struct request_queue *bdev_q = bdev_get_queue(bio_data->bdev);
 	struct tio_work *tio_work;
 	struct bio *tio_bio = NULL, *bio = NULL, *biotail = NULL;
+	struct blk_plug plug;
 
 	u32 offset = tio->offset;
 	u32 size = tio->size;
@@ -78,6 +79,8 @@ blockio_make_request(struct iet_volume *volume, struct tio *tio, int rw)
 	atomic_set(&tio_work->bios_remaining, 0);
 	init_completion(&tio_work->tio_complete);
 
+	blk_start_plug(&plug);
+
 	/* Main processing loop, allocate and fill all bios */
 	while (tio_index < tio->pg_cnt) {
 		bio = bio_alloc(GFP_KERNEL, min(max_pages, BIO_MAX_PAGES));
@@ -127,8 +130,7 @@ blockio_make_request(struct iet_volume *volume, struct tio *tio, int rw)
 		submit_bio(rw, bio);
 	}
 
-	if (bdev_q && bdev_q->unplug_fn)
-		bdev_q->unplug_fn(bdev_q);
+	blk_finish_plug(&plug);
 
 	wait_for_completion(&tio_work->tio_complete);
 
-- 
1.7.0.4

