dm: add dm_submit_bio_remap interface
authorMike Snitzer <snitzer@redhat.com>
Wed, 9 Feb 2022 21:04:40 +0000 (16:04 -0500)
committerMike Snitzer <snitzer@redhat.com>
Wed, 16 Feb 2022 20:47:40 +0000 (15:47 -0500)
commitcee26f1d96fa2cb3a71bc787c1b1803a8ecc188e
treeddfa2460270792d290957c1d3322fb3669ac75cf
parent919ffcdabb307113be95917fbee10933f939acd1
dm: add dm_submit_bio_remap interface

Where possible, switch from early bio-based IO accounting (at the time
DM clones each incoming bio) to late IO accounting just before each
remapped bio is issued to underlying device via submit_bio_noacct().

Allows more precise bio-based IO accounting for DM targets that use
their own workqueues to perform additional processing of each bio in
conjunction with their DM_MAPIO_SUBMITTED return from their map
function. When a target is updated to use dm_submit_bio_remap() they
must also set ti->accounts_remapped_io to true.

Use xchg() in start_io_acct(), as suggested by Mikulas, to ensure each
IO is only started once.  The xchg race only happens if
__send_duplicate_bios() sends multiple bios -- that case is reflected
via tio->is_duplicate_bio.  Given the niche nature of this race, it is
best to avoid any xchg performance penalty for normal IO.

Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-core.h
drivers/md/dm.c
include/linux/device-mapper.h
include/uapi/linux/dm-ioctl.h