Skip to content

Commit 9d20653

Browse files
author
Mike Snitzer
committed
dm: simplify bio-based IO accounting further
Now that io splitting is recorded prior to, or during, ->map IO accounting can happen immediately rather than defer until after bio splitting in dm_split_and_process_bio(). Remove the DM_IO_START_ACCT flag and also remove dm_io's map_task member because there is no longer any need to wait for splitting to occur before accounting. Also move dm_io struct's 'flags' member to consolidate struct holes. Signed-off-by: Mike Snitzer <[email protected]>
1 parent ec21163 commit 9d20653

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

drivers/md/dm-core.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,12 @@ static inline bool dm_tio_is_normal(struct dm_target_io *tio)
255255
#define DM_IO_MAGIC 19577
256256
struct dm_io {
257257
unsigned short magic;
258-
258+
blk_short_t flags;
259259
spinlock_t lock;
260260
unsigned long start_time;
261261
void *data;
262262
struct dm_io *next;
263-
struct task_struct *map_task;
264263
struct dm_stats_aux stats_aux;
265-
266-
blk_short_t flags;
267264
blk_status_t status;
268265
atomic_t io_count;
269266
struct mapped_device *md;
@@ -281,7 +278,6 @@ struct dm_io {
281278
* dm_io flags
282279
*/
283280
enum {
284-
DM_IO_START_ACCT,
285281
DM_IO_ACCOUNTED,
286282
DM_IO_WAS_SPLIT
287283
};

drivers/md/dm.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
596596
this_cpu_inc(*md->pending_io);
597597
io->orig_bio = bio;
598598
io->md = md;
599-
io->map_task = current;
600599
spin_lock_init(&io->lock);
601600
io->start_time = jiffies;
602601
io->flags = 0;
@@ -1241,13 +1240,6 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors)
12411240
}
12421241
EXPORT_SYMBOL_GPL(dm_accept_partial_bio);
12431242

1244-
static inline void __dm_submit_bio_remap(struct bio *clone,
1245-
dev_t dev, sector_t old_sector)
1246-
{
1247-
trace_block_bio_remap(clone, dev, old_sector);
1248-
submit_bio_noacct(clone);
1249-
}
1250-
12511243
/*
12521244
* @clone: clone bio that DM core passed to target's .map function
12531245
* @tgt_clone: clone of @clone bio that target needs submitted
@@ -1262,8 +1254,6 @@ void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone)
12621254
struct dm_target_io *tio = clone_to_tio(clone);
12631255
struct dm_io *io = tio->io;
12641256

1265-
WARN_ON_ONCE(!tio->ti->accounts_remapped_io);
1266-
12671257
/* establish bio that will get submitted */
12681258
if (!tgt_clone)
12691259
tgt_clone = clone;
@@ -1272,15 +1262,11 @@ void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone)
12721262
* Account io->origin_bio to DM dev on behalf of target
12731263
* that took ownership of IO with DM_MAPIO_SUBMITTED.
12741264
*/
1275-
if (io->map_task == current) {
1276-
/* Still in target's map function */
1277-
dm_io_set_flag(io, DM_IO_START_ACCT);
1278-
} else {
1279-
dm_start_io_acct(io, clone);
1280-
}
1265+
dm_start_io_acct(io, clone);
12811266

1282-
__dm_submit_bio_remap(tgt_clone, disk_devt(io->md->disk),
1267+
trace_block_bio_remap(tgt_clone, disk_devt(io->md->disk),
12831268
tio->old_sector);
1269+
submit_bio_noacct(tgt_clone);
12841270
}
12851271
EXPORT_SYMBOL_GPL(dm_submit_bio_remap);
12861272

@@ -1340,16 +1326,10 @@ static void __map_bio(struct bio *clone)
13401326
case DM_MAPIO_SUBMITTED:
13411327
/* target has assumed ownership of this io */
13421328
if (!ti->accounts_remapped_io)
1343-
dm_io_set_flag(io, DM_IO_START_ACCT);
1329+
dm_start_io_acct(io, clone);
13441330
break;
13451331
case DM_MAPIO_REMAPPED:
1346-
/*
1347-
* the bio has been remapped so dispatch it, but defer
1348-
* dm_start_io_acct() until after possible bio_split().
1349-
*/
1350-
__dm_submit_bio_remap(clone, disk_devt(md->disk),
1351-
tio->old_sector);
1352-
dm_io_set_flag(io, DM_IO_START_ACCT);
1332+
dm_submit_bio_remap(clone, NULL);
13531333
break;
13541334
case DM_MAPIO_KILL:
13551335
case DM_MAPIO_REQUEUE:
@@ -1667,7 +1647,6 @@ static void dm_split_and_process_bio(struct mapped_device *md,
16671647
}
16681648

16691649
error = __split_and_process_bio(&ci);
1670-
io->map_task = NULL;
16711650
if (error || !ci.sector_count)
16721651
goto out;
16731652
/*
@@ -1679,9 +1658,6 @@ static void dm_split_and_process_bio(struct mapped_device *md,
16791658
bio_inc_remaining(bio);
16801659
submit_bio_noacct(bio);
16811660
out:
1682-
if (dm_io_flagged(io, DM_IO_START_ACCT))
1683-
dm_start_io_acct(io, NULL);
1684-
16851661
/*
16861662
* Drop the extra reference count for non-POLLED bio, and hold one
16871663
* reference for POLLED bio, which will be released in dm_poll_bio

0 commit comments

Comments
 (0)