From: Mikulas Patocka <[email-masked]>

Accept empty barriers in dm-io.

dm-io will process empty write barrier requests just like the other
read/write requests.

Signed-off-by: Mikulas Patocka <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>

---
 drivers/md/dm-io.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6.31-rc8/drivers/md/dm-io.c
===================================================================
--- linux-2.6.31-rc8.orig/drivers/md/dm-io.c
+++ linux-2.6.31-rc8/drivers/md/dm-io.c
@@ -286,7 +286,11 @@ static void do_region(int rw, unsigned r
 	unsigned num_bvecs;
 	sector_t remaining = where->count;
 
-	while (remaining) {
+	/*
+	 * where->count may be zero if rw holds a write barrier and we
+	 * need to send a zero-sized barrier.
+	 */
+	do {
 		/*
 		 * Allocate a suitably sized-bio: we add an extra
 		 * bvec for bio_get/set_region() and decrement bi_max_vecs
@@ -323,7 +327,7 @@ static void do_region(int rw, unsigned r
 
 		atomic_inc(&io->count);
 		submit_bio(rw, bio);
-	}
+	} while (remaining);
 }
 
 static void dispatch_io(int rw, unsigned int num_regions,
@@ -342,7 +346,7 @@ static void dispatch_io(int rw, unsigned
 	 */
 	for (i = 0; i < num_regions; i++) {
 		*dp = old_pages;
-		if (where[i].count)
+		if (where[i].count || (rw & (1 << BIO_RW_BARRIER)))
 			do_region(rw, i, where + i, dp, io);
 	}