From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Cc: linux-block@vger.kernel.org
Subject: [PATCH v2 10/14] block: add bio_start_io_acct_remapped for the benefit of DM
Date: Fri, 11 Feb 2022 16:40:53 -0500 [thread overview]
Message-ID: <20220211214057.40612-11-snitzer@redhat.com> (raw)
In-Reply-To: <20220211214057.40612-1-snitzer@redhat.com>
DM needs the ability to account a clone bio's IO to the original
block_device. So add @orig_bdev argument to bio_start_io_acct_time.
Rename bio_start_io_acct_time to bio_start_io_acct_remapped.
Also, follow bio_end_io_acct and bio_end_io_acct_remapped pattern by
moving bio_start_io_acct to blkdev.h and have it call
bio_start_io_acct_remapped.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
block/blk-core.c | 24 ++++++++----------------
drivers/md/dm.c | 3 ++-
include/linux/blkdev.h | 16 ++++++++++++++--
3 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index be8812f5489d..8f23be96c737 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1077,29 +1077,21 @@ static unsigned long __part_start_io_acct(struct block_device *part,
}
/**
- * bio_start_io_acct_time - start I/O accounting for bio based drivers
+ * bio_start_io_acct_remapped - start I/O accounting for bio based drivers
* @bio: bio to start account for
* @start_time: start time that should be passed back to bio_end_io_acct().
- */
-void bio_start_io_acct_time(struct bio *bio, unsigned long start_time)
-{
- __part_start_io_acct(bio->bi_bdev, bio_sectors(bio),
- bio_op(bio), start_time);
-}
-EXPORT_SYMBOL_GPL(bio_start_io_acct_time);
-
-/**
- * bio_start_io_acct - start I/O accounting for bio based drivers
- * @bio: bio to start account for
+ * @orig_bdev: block device that I/O must be accounted to.
*
* Returns the start time that should be passed back to bio_end_io_acct().
*/
-unsigned long bio_start_io_acct(struct bio *bio)
+unsigned long bio_start_io_acct_remapped(struct bio *bio,
+ unsigned long start_time,
+ struct block_device *orig_bdev)
{
- return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio),
- bio_op(bio), jiffies);
+ return __part_start_io_acct(orig_bdev, bio_sectors(bio),
+ bio_op(bio), start_time);
}
-EXPORT_SYMBOL_GPL(bio_start_io_acct);
+EXPORT_SYMBOL_GPL(bio_start_io_acct_remapped);
unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
unsigned int op)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 72686329f91e..c0177552b471 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -489,7 +489,8 @@ static void start_io_acct(struct dm_io *io)
{
struct bio *bio = io->orig_bio;
- bio_start_io_acct_time(bio, io->start_time);
+ bio_start_io_acct_remapped(bio, io->start_time,
+ io->orig_bio->bi_bdev);
if (unlikely(dm_stats_used(&io->md->stats)))
dm_stats_account_io(&io->md->stats, bio_data_dir(bio),
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 3bfc75a2a450..31d055d4a17e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1512,11 +1512,23 @@ unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
void disk_end_io_acct(struct gendisk *disk, unsigned int op,
unsigned long start_time);
-void bio_start_io_acct_time(struct bio *bio, unsigned long start_time);
-unsigned long bio_start_io_acct(struct bio *bio);
+unsigned long bio_start_io_acct_remapped(struct bio *bio,
+ unsigned long start_time,
+ struct block_device *orig_bdev);
void bio_end_io_acct_remapped(struct bio *bio, unsigned long start_time,
struct block_device *orig_bdev);
+/**
+ * bio_start_io_acct - start I/O accounting for bio based drivers
+ * @bio: bio to start account for
+ *
+ * Returns the start time that should be passed back to bio_end_io_acct().
+ */
+static inline unsigned long bio_start_io_acct(struct bio *bio)
+{
+ return bio_start_io_acct_remapped(bio, jiffies, bio->bi_bdev);
+}
+
/**
* bio_end_io_acct - end I/O accounting for bio based drivers
* @bio: bio to end account for
--
2.15.0
next prev parent reply other threads:[~2022-02-11 21:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 21:40 [PATCH v2 00/14] dm: improve bio-based IO accounting Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 01/14] dm: rename split functions Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 02/14] dm: fold __clone_and_map_data_bio into __split_and_process_bio Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 03/14] dm: refactor dm_split_and_process_bio a bit Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 04/14] dm: reduce code duplication in __map_bio Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 05/14] dm: remove impossible BUG_ON in __send_empty_flush Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 06/14] dm: remove unused mapped_device argument from free_tio Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 07/14] dm: remove code only needed before submit_bio recursion Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 08/14] dm: record old_sector in dm_target_io before calling map function Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 09/14] dm: move kicking of suspend queue to dm_io_dec_pending Mike Snitzer
2022-02-11 21:40 ` Mike Snitzer [this message]
2022-02-14 14:02 ` [PATCH v2 10/14] block: add bio_start_io_acct_remapped for the benefit of DM Christoph Hellwig
2022-02-15 2:40 ` Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 11/14] dm: add dm_submit_bio_remap interface Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 12/14] dm crypt: use dm_submit_bio_remap Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 13/14] dm delay: " Mike Snitzer
2022-02-11 21:40 ` [PATCH v2 14/14] dm: move duplicate code in callers of alloc_tio into alloc_tio Mike Snitzer
2022-02-14 14:04 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220211214057.40612-11-snitzer@redhat.com \
--to=snitzer@redhat.com \
--cc=dm-devel@redhat.com \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).