Commit ddbd658f authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm: move target request nr to dm_target_io

This patch moves target_request_nr from map_info to dm_target_io and
makes it accessible with dm_bio_get_target_request_nr.

This patch is a preparation for the next patch that removes map_info.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 42bc954f
...@@ -1682,7 +1682,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio, ...@@ -1682,7 +1682,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
chunk_t chunk; chunk_t chunk;
if (bio->bi_rw & REQ_FLUSH) { if (bio->bi_rw & REQ_FLUSH) {
if (!map_context->target_request_nr) if (!dm_bio_get_target_request_nr(bio))
bio->bi_bdev = s->origin->bdev; bio->bi_bdev = s->origin->bdev;
else else
bio->bi_bdev = s->cow->bdev; bio->bi_bdev = s->cow->bdev;
......
...@@ -279,13 +279,13 @@ static int stripe_map(struct dm_target *ti, struct bio *bio, ...@@ -279,13 +279,13 @@ static int stripe_map(struct dm_target *ti, struct bio *bio,
unsigned target_request_nr; unsigned target_request_nr;
if (bio->bi_rw & REQ_FLUSH) { if (bio->bi_rw & REQ_FLUSH) {
target_request_nr = map_context->target_request_nr; target_request_nr = dm_bio_get_target_request_nr(bio);
BUG_ON(target_request_nr >= sc->stripes); BUG_ON(target_request_nr >= sc->stripes);
bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev; bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev;
return DM_MAPIO_REMAPPED; return DM_MAPIO_REMAPPED;
} }
if (unlikely(bio->bi_rw & REQ_DISCARD)) { if (unlikely(bio->bi_rw & REQ_DISCARD)) {
target_request_nr = map_context->target_request_nr; target_request_nr = dm_bio_get_target_request_nr(bio);
BUG_ON(target_request_nr >= sc->stripes); BUG_ON(target_request_nr >= sc->stripes);
return stripe_map_discard(sc, bio, target_request_nr); return stripe_map_discard(sc, bio, target_request_nr);
} }
......
...@@ -1099,6 +1099,7 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, ...@@ -1099,6 +1099,7 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci,
tio->io = ci->io; tio->io = ci->io;
tio->ti = ti; tio->ti = ti;
memset(&tio->info, 0, sizeof(tio->info)); memset(&tio->info, 0, sizeof(tio->info));
tio->target_request_nr = 0;
return tio; return tio;
} }
...@@ -1109,7 +1110,7 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, ...@@ -1109,7 +1110,7 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
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);
struct bio *clone = &tio->clone; struct bio *clone = &tio->clone;
tio->info.target_request_nr = request_nr; tio->target_request_nr = request_nr;
/* /*
* Discard requests require the bio's inline iovecs be initialized. * Discard requests require the bio's inline iovecs be initialized.
......
...@@ -23,7 +23,6 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; ...@@ -23,7 +23,6 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
union map_info { union map_info {
void *ptr; void *ptr;
unsigned long long ll; unsigned long long ll;
unsigned target_request_nr;
}; };
/* /*
...@@ -193,20 +192,21 @@ struct dm_target { ...@@ -193,20 +192,21 @@ struct dm_target {
* A number of zero-length barrier requests that will be submitted * A number of zero-length barrier requests that will be submitted
* to the target for the purpose of flushing cache. * to the target for the purpose of flushing cache.
* *
* The request number will be placed in union map_info->target_request_nr. * The request number can be accessed with dm_bio_get_target_request_nr.
* It is a responsibility of the target driver to remap these requests * It is a responsibility of the target driver to remap these requests
* to the real underlying devices. * to the real underlying devices.
*/ */
unsigned num_flush_requests; unsigned num_flush_requests;
/* /*
* The number of discard requests that will be submitted to the * The number of discard requests that will be submitted to the target.
* target. map_info->request_nr is used just like num_flush_requests. * The request number can be accessed with dm_bio_get_target_request_nr.
*/ */
unsigned num_discard_requests; unsigned num_discard_requests;
/* /*
* The number of WRITE SAME requests that will be submitted to the target. * The number of WRITE SAME requests that will be submitted to the target.
* The request number can be accessed with dm_bio_get_target_request_nr.
*/ */
unsigned num_write_same_requests; unsigned num_write_same_requests;
...@@ -263,6 +263,7 @@ struct dm_target_io { ...@@ -263,6 +263,7 @@ struct dm_target_io {
struct dm_io *io; struct dm_io *io;
struct dm_target *ti; struct dm_target *ti;
union map_info info; union map_info info;
unsigned target_request_nr;
struct bio clone; struct bio clone;
}; };
...@@ -276,6 +277,11 @@ static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size) ...@@ -276,6 +277,11 @@ static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size)
return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone)); return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone));
} }
static inline unsigned dm_bio_get_target_request_nr(const struct bio *bio)
{
return container_of(bio, struct dm_target_io, clone)->target_request_nr;
}
int dm_register_target(struct target_type *t); int dm_register_target(struct target_type *t);
void dm_unregister_target(struct target_type *t); void dm_unregister_target(struct target_type *t);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment