---
 drivers/md/dm.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Index: linux/drivers/md/dm.c
===================================================================
--- linux.orig/drivers/md/dm.c
+++ linux/drivers/md/dm.c
@@ -987,12 +987,13 @@ int dm_set_target_max_io_len(struct dm_t
 }
 EXPORT_SYMBOL_GPL(dm_set_target_max_io_len);
 
-static void __map_bio(struct dm_target *ti, struct dm_target_io *tio)
+static void __map_bio(struct dm_target_io *tio)
 {
 	int r;
 	sector_t sector;
 	struct mapped_device *md;
 	struct bio *clone = &tio->clone;
+	struct dm_target *ti = tio->ti;
 
 	clone->bi_end_io = clone_endio;
 	clone->bi_private = tio;
@@ -1102,7 +1103,8 @@ static void clone_bio(struct dm_target_i
 }
 
 static struct dm_target_io *alloc_tio(struct clone_info *ci,
-				      struct dm_target *ti, int nr_iovecs)
+				      struct dm_target *ti, int nr_iovecs,
+				      unsigned target_request_nr)
 {
 	struct dm_target_io *tio;
 	struct bio *clone;
@@ -1113,7 +1115,7 @@ static struct dm_target_io *alloc_tio(st
 	tio->io = ci->io;
 	tio->ti = ti;
 	memset(&tio->info, 0, sizeof(tio->info));
-	tio->target_request_nr = 0;
+	tio->target_request_nr = target_request_nr;
 
 	return tio;
 }
@@ -1121,11 +1123,9 @@ static struct dm_target_io *alloc_tio(st
 static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
 				   unsigned request_nr, sector_t len)
 {
-	struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs);
+	struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs, request_nr);
 	struct bio *clone = &tio->clone;
 
-	tio->target_request_nr = request_nr;
-
 	/*
 	 * Discard requests require the bio's inline iovecs be initialized.
 	 * ci->bio->bi_max_vecs is BIO_INLINE_VECS anyway, for both flush
@@ -1135,7 +1135,7 @@ static void __issue_target_request(struc
 	if (len)
 		bio_setup_sector(clone, ci->sector, len);
 
-	__map_bio(ti, tio);
+	__map_bio(tio);
 }
 
 static void __issue_target_requests(struct clone_info *ci, struct dm_target *ti,
@@ -1167,10 +1167,10 @@ static void __clone_and_map_simple(struc
 	struct bio *bio = ci->bio;
 	struct dm_target_io *tio;
 
-	tio = alloc_tio(ci, ti, bio->bi_max_vecs);
+	tio = alloc_tio(ci, ti, bio->bi_max_vecs, 0);
 	clone_bio(tio, bio, ci->sector, ci->idx, bio->bi_vcnt - ci->idx,
 		  ci->sector_count);
-	__map_bio(ti, tio);
+	__map_bio(tio);
 	ci->sector_count = 0;
 }
 
@@ -1284,9 +1284,9 @@ static int __clone_and_map(struct clone_
 			len += bv_len;
 		}
 
-		tio = alloc_tio(ci, ti, bio->bi_max_vecs);
+		tio = alloc_tio(ci, ti, bio->bi_max_vecs, 0);
 		clone_bio(tio, bio, ci->sector, ci->idx, i - ci->idx, len);
-		__map_bio(ti, tio);
+		__map_bio(tio);
 
 		ci->sector += len;
 		ci->sector_count -= len;
@@ -1311,11 +1311,11 @@ static int __clone_and_map(struct clone_
 
 			len = min(remaining, max);
 
-			tio = alloc_tio(ci, ti, 1);
+			tio = alloc_tio(ci, ti, 1, 0);
 			split_bvec(tio, bio, ci->sector, ci->idx,
 				   bv->bv_offset + offset, len);
 
-			__map_bio(ti, tio);
+			__map_bio(tio);
 
 			ci->sector += len;
 			ci->sector_count -= len;