Skip to content

Commit 6cbce28

Browse files
author
Mike Snitzer
committed
dm: add local variables to clone_endio and __map_bio
Avoid redundant dereferences in both functions. Signed-off-by: Mike Snitzer <[email protected]>
1 parent fe221db commit 6cbce28

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/md/dm.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -976,11 +976,12 @@ static bool swap_bios_limit(struct dm_target *ti, struct bio *bio)
976976
static void clone_endio(struct bio *bio)
977977
{
978978
blk_status_t error = bio->bi_status;
979+
struct request_queue *q = bio->bi_bdev->bd_disk->queue;
979980
struct dm_target_io *tio = clone_to_tio(bio);
981+
struct dm_target *ti = tio->ti;
982+
dm_endio_fn endio = ti->type->end_io;
980983
struct dm_io *io = tio->io;
981-
struct mapped_device *md = tio->io->md;
982-
dm_endio_fn endio = tio->ti->type->end_io;
983-
struct request_queue *q = bio->bi_bdev->bd_disk->queue;
984+
struct mapped_device *md = io->md;
984985

985986
if (unlikely(error == BLK_STS_TARGET)) {
986987
if (bio_op(bio) == REQ_OP_DISCARD &&
@@ -995,7 +996,7 @@ static void clone_endio(struct bio *bio)
995996
dm_zone_endio(io, bio);
996997

997998
if (endio) {
998-
int r = endio(tio->ti, bio, &error);
999+
int r = endio(ti, bio, &error);
9991000
switch (r) {
10001001
case DM_ENDIO_REQUEUE:
10011002
/*
@@ -1019,10 +1020,8 @@ static void clone_endio(struct bio *bio)
10191020
}
10201021
}
10211022

1022-
if (unlikely(swap_bios_limit(tio->ti, bio))) {
1023-
struct mapped_device *md = io->md;
1023+
if (unlikely(swap_bios_limit(ti, bio)))
10241024
up(&md->swap_bios_semaphore);
1025-
}
10261025

10271026
free_tio(bio);
10281027
dm_io_dec_pending(io, error);
@@ -1263,9 +1262,10 @@ static noinline void __set_swap_bios_limit(struct mapped_device *md, int latch)
12631262
static void __map_bio(struct bio *clone)
12641263
{
12651264
struct dm_target_io *tio = clone_to_tio(clone);
1266-
int r;
1267-
struct dm_io *io = tio->io;
12681265
struct dm_target *ti = tio->ti;
1266+
struct dm_io *io = tio->io;
1267+
struct mapped_device *md = io->md;
1268+
int r;
12691269

12701270
clone->bi_end_io = clone_endio;
12711271

@@ -1276,7 +1276,6 @@ static void __map_bio(struct bio *clone)
12761276
tio->old_sector = clone->bi_iter.bi_sector;
12771277

12781278
if (unlikely(swap_bios_limit(ti, clone))) {
1279-
struct mapped_device *md = io->md;
12801279
int latch = get_swap_bios();
12811280
if (unlikely(latch != md->swap_bios))
12821281
__set_swap_bios_limit(md, latch);
@@ -1288,7 +1287,7 @@ static void __map_bio(struct bio *clone)
12881287
* on zoned target. In this case, dm_zone_map_bio() calls the target
12891288
* map operation.
12901289
*/
1291-
if (unlikely(dm_emulate_zone_append(io->md)))
1290+
if (unlikely(dm_emulate_zone_append(md)))
12921291
r = dm_zone_map_bio(tio);
12931292
else
12941293
r = ti->type->map(ti, clone);
@@ -1304,14 +1303,14 @@ static void __map_bio(struct bio *clone)
13041303
* the bio has been remapped so dispatch it, but defer
13051304
* dm_start_io_acct() until after possible bio_split().
13061305
*/
1307-
__dm_submit_bio_remap(clone, disk_devt(io->md->disk),
1306+
__dm_submit_bio_remap(clone, disk_devt(md->disk),
13081307
tio->old_sector);
13091308
dm_io_set_flag(io, DM_IO_START_ACCT);
13101309
break;
13111310
case DM_MAPIO_KILL:
13121311
case DM_MAPIO_REQUEUE:
13131312
if (unlikely(swap_bios_limit(ti, clone)))
1314-
up(&io->md->swap_bios_semaphore);
1313+
up(&md->swap_bios_semaphore);
13151314
free_tio(clone);
13161315
if (r == DM_MAPIO_KILL)
13171316
dm_io_dec_pending(io, BLK_STS_IOERR);

0 commit comments

Comments
 (0)