aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-snap.c2
-rw-r--r--drivers/md/dm-stripe.c4
-rw-r--r--drivers/md/dm.c3
-rw-r--r--include/linux/device-mapper.h14
4 files changed, 15 insertions, 8 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 5e88bc437be0..b7e179cdc5af 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1682,7 +1682,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
1682 chunk_t chunk; 1682 chunk_t chunk;
1683 1683
1684 if (bio->bi_rw & REQ_FLUSH) { 1684 if (bio->bi_rw & REQ_FLUSH) {
1685 if (!map_context->target_request_nr) 1685 if (!dm_bio_get_target_request_nr(bio))
1686 bio->bi_bdev = s->origin->bdev; 1686 bio->bi_bdev = s->origin->bdev;
1687 else 1687 else
1688 bio->bi_bdev = s->cow->bdev; 1688 bio->bi_bdev = s->cow->bdev;
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index e2f876539743..4e7ba82146c0 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -279,13 +279,13 @@ static int stripe_map(struct dm_target *ti, struct bio *bio,
279 unsigned target_request_nr; 279 unsigned target_request_nr;
280 280
281 if (bio->bi_rw & REQ_FLUSH) { 281 if (bio->bi_rw & REQ_FLUSH) {
282 target_request_nr = map_context->target_request_nr; 282 target_request_nr = dm_bio_get_target_request_nr(bio);
283 BUG_ON(target_request_nr >= sc->stripes); 283 BUG_ON(target_request_nr >= sc->stripes);
284 bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev; 284 bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev;
285 return DM_MAPIO_REMAPPED; 285 return DM_MAPIO_REMAPPED;
286 } 286 }
287 if (unlikely(bio->bi_rw & REQ_DISCARD)) { 287 if (unlikely(bio->bi_rw & REQ_DISCARD)) {
288 target_request_nr = map_context->target_request_nr; 288 target_request_nr = dm_bio_get_target_request_nr(bio);
289 BUG_ON(target_request_nr >= sc->stripes); 289 BUG_ON(target_request_nr >= sc->stripes);
290 return stripe_map_discard(sc, bio, target_request_nr); 290 return stripe_map_discard(sc, bio, target_request_nr);
291 } 291 }
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 2765cf2ba0ff..5ee580b4f330 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1099,6 +1099,7 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci,
1099 tio->io = ci->io; 1099 tio->io = ci->io;
1100 tio->ti = ti; 1100 tio->ti = ti;
1101 memset(&tio->info, 0, sizeof(tio->info)); 1101 memset(&tio->info, 0, sizeof(tio->info));
1102 tio->target_request_nr = 0;
1102 1103
1103 return tio; 1104 return tio;
1104} 1105}
@@ -1109,7 +1110,7 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
1109 struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs); 1110 struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs);
1110 struct bio *clone = &tio->clone; 1111 struct bio *clone = &tio->clone;
1111 1112
1112 tio->info.target_request_nr = request_nr; 1113 tio->target_request_nr = request_nr;
1113 1114
1114 /* 1115 /*
1115 * Discard requests require the bio's inline iovecs be initialized. 1116 * Discard requests require the bio's inline iovecs be initialized.
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 6f0e73b4a80d..eb96ef6fd8b7 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -23,7 +23,6 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
23union map_info { 23union map_info {
24 void *ptr; 24 void *ptr;
25 unsigned long long ll; 25 unsigned long long ll;
26 unsigned target_request_nr;
27}; 26};
28 27
29/* 28/*
@@ -193,20 +192,21 @@ struct dm_target {
193 * A number of zero-length barrier requests that will be submitted 192 * A number of zero-length barrier requests that will be submitted
194 * to the target for the purpose of flushing cache. 193 * to the target for the purpose of flushing cache.
195 * 194 *
196 * The request number will be placed in union map_info->target_request_nr. 195 * The request number can be accessed with dm_bio_get_target_request_nr.
197 * It is a responsibility of the target driver to remap these requests 196 * It is a responsibility of the target driver to remap these requests
198 * to the real underlying devices. 197 * to the real underlying devices.
199 */ 198 */
200 unsigned num_flush_requests; 199 unsigned num_flush_requests;
201 200
202 /* 201 /*
203 * The number of discard requests that will be submitted to the 202 * The number of discard requests that will be submitted to the target.
204 * target. map_info->request_nr is used just like num_flush_requests. 203 * The request number can be accessed with dm_bio_get_target_request_nr.
205 */ 204 */
206 unsigned num_discard_requests; 205 unsigned num_discard_requests;
207 206
208 /* 207 /*
209 * The number of WRITE SAME requests that will be submitted to the target. 208 * The number of WRITE SAME requests that will be submitted to the target.
209 * The request number can be accessed with dm_bio_get_target_request_nr.
210 */ 210 */
211 unsigned num_write_same_requests; 211 unsigned num_write_same_requests;
212 212
@@ -263,6 +263,7 @@ struct dm_target_io {
263 struct dm_io *io; 263 struct dm_io *io;
264 struct dm_target *ti; 264 struct dm_target *ti;
265 union map_info info; 265 union map_info info;
266 unsigned target_request_nr;
266 struct bio clone; 267 struct bio clone;
267}; 268};
268 269
@@ -276,6 +277,11 @@ static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size)
276 return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone)); 277 return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone));
277} 278}
278 279
280static inline unsigned dm_bio_get_target_request_nr(const struct bio *bio)
281{
282 return container_of(bio, struct dm_target_io, clone)->target_request_nr;
283}
284
279int dm_register_target(struct target_type *t); 285int dm_register_target(struct target_type *t);
280void dm_unregister_target(struct target_type *t); 286void dm_unregister_target(struct target_type *t);
281 287