Skip to content

Commit ddbd658

Browse files
Mikulas Patockakergon
authored andcommitted
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: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
1 parent 42bc954 commit ddbd658

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

drivers/md/dm-snap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
16821682
chunk_t chunk;
16831683

16841684
if (bio->bi_rw & REQ_FLUSH) {
1685-
if (!map_context->target_request_nr)
1685+
if (!dm_bio_get_target_request_nr(bio))
16861686
bio->bi_bdev = s->origin->bdev;
16871687
else
16881688
bio->bi_bdev = s->cow->bdev;

drivers/md/dm-stripe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ static int stripe_map(struct dm_target *ti, struct bio *bio,
279279
unsigned target_request_nr;
280280

281281
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);
283283
BUG_ON(target_request_nr >= sc->stripes);
284284
bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev;
285285
return DM_MAPIO_REMAPPED;
286286
}
287287
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);
289289
BUG_ON(target_request_nr >= sc->stripes);
290290
return stripe_map_discard(sc, bio, target_request_nr);
291291
}

drivers/md/dm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci,
10991099
tio->io = ci->io;
11001100
tio->ti = ti;
11011101
memset(&tio->info, 0, sizeof(tio->info));
1102+
tio->target_request_nr = 0;
11021103

11031104
return tio;
11041105
}
@@ -1109,7 +1110,7 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
11091110
struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs);
11101111
struct bio *clone = &tio->clone;
11111112

1112-
tio->info.target_request_nr = request_nr;
1113+
tio->target_request_nr = request_nr;
11131114

11141115
/*
11151116
* Discard requests require the bio's inline iovecs be initialized.

include/linux/device-mapper.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
2323
union map_info {
2424
void *ptr;
2525
unsigned long long ll;
26-
unsigned target_request_nr;
2726
};
2827

2928
/*
@@ -193,20 +192,21 @@ struct dm_target {
193192
* A number of zero-length barrier requests that will be submitted
194193
* to the target for the purpose of flushing cache.
195194
*
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.
197196
* It is a responsibility of the target driver to remap these requests
198197
* to the real underlying devices.
199198
*/
200199
unsigned num_flush_requests;
201200

202201
/*
203-
* The number of discard requests that will be submitted to the
204-
* target. map_info->request_nr is used just like num_flush_requests.
202+
* The number of discard requests that will be submitted to the target.
203+
* The request number can be accessed with dm_bio_get_target_request_nr.
205204
*/
206205
unsigned num_discard_requests;
207206

208207
/*
209208
* 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.
210210
*/
211211
unsigned num_write_same_requests;
212212

@@ -263,6 +263,7 @@ struct dm_target_io {
263263
struct dm_io *io;
264264
struct dm_target *ti;
265265
union map_info info;
266+
unsigned target_request_nr;
266267
struct bio clone;
267268
};
268269

@@ -276,6 +277,11 @@ static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size)
276277
return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone));
277278
}
278279

280+
static 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+
279285
int dm_register_target(struct target_type *t);
280286
void dm_unregister_target(struct target_type *t);
281287

0 commit comments

Comments
 (0)