From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: Tejun Heo <tj@kernel.org>, Coly Li <colyli@suse.de>, Song Liu <song@kernel.org>, dm-devel@redhat.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-s390@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 6/9] blk-mq: use ->bi_bdev for I/O accounting Date: Tue, 1 Dec 2020 17:54:21 +0100 [thread overview] Message-ID: <20201201165424.2030647-7-hch@lst.de> (raw) In-Reply-To: <20201201165424.2030647-1-hch@lst.de> Remove the reverse map from a sector to a partition for I/O accounting by simply using ->bi_bdev. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-core.c | 6 +++++- block/blk.h | 2 -- block/genhd.c | 48 ------------------------------------------------ 3 files changed, 5 insertions(+), 51 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d53cc887e1b8ea..ad041e903b0a8f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1296,7 +1296,11 @@ void blk_account_io_start(struct request *rq) if (!blk_do_io_stat(rq)) return; - rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); + /* passthrough requests can hold bios that do not have ->bi_bdev set */ + if (rq->bio && rq->bio->bi_bdev) + rq->part = rq->bio->bi_bdev; + else + rq->part = rq->rq_disk->part0; part_stat_lock(); update_io_ticks(rq->part, jiffies, false); diff --git a/block/blk.h b/block/blk.h index 64dc8e5a3f44cb..f93a6af04adbd1 100644 --- a/block/blk.h +++ b/block/blk.h @@ -346,8 +346,6 @@ void blk_queue_free_zone_bitmaps(struct request_queue *q); static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {} #endif -struct block_device *disk_map_sector_rcu(struct gendisk *disk, sector_t sector); - int blk_alloc_devt(struct block_device *part, dev_t *devt); void blk_free_devt(dev_t devt); char *disk_name(struct gendisk *hd, int partno, char *buf); diff --git a/block/genhd.c b/block/genhd.c index 57c709a9f90267..3b9cd766d95228 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -280,54 +280,6 @@ void disk_part_iter_exit(struct disk_part_iter *piter) } EXPORT_SYMBOL_GPL(disk_part_iter_exit); -static inline int sector_in_part(struct block_device *part, sector_t sector) -{ - return part->bd_start_sect <= sector && - sector < part->bd_start_sect + bdev_nr_sectors(part); -} - -/** - * disk_map_sector_rcu - map sector to partition - * @disk: gendisk of interest - * @sector: sector to map - * - * Find out which partition @sector maps to on @disk. This is - * primarily used for stats accounting. - * - * CONTEXT: - * RCU read locked. - * - * RETURNS: - * Found partition on success, part0 is returned if no partition matches - * or the matched partition is being deleted. - */ -struct block_device *disk_map_sector_rcu(struct gendisk *disk, sector_t sector) -{ - struct disk_part_tbl *ptbl; - struct block_device *part; - int i; - - rcu_read_lock(); - ptbl = rcu_dereference(disk->part_tbl); - - part = rcu_dereference(ptbl->last_lookup); - if (part && sector_in_part(part, sector)) - goto out_unlock; - - for (i = 1; i < ptbl->len; i++) { - part = rcu_dereference(ptbl->part[i]); - if (part && sector_in_part(part, sector)) { - rcu_assign_pointer(ptbl->last_lookup, part); - goto out_unlock; - } - } - - part = disk->part0; -out_unlock: - rcu_read_unlock(); - return part; -} - /** * disk_has_partitions * @disk: gendisk of interest -- 2.29.2
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: linux-s390@vger.kernel.org, linux-bcache@vger.kernel.org, Coly Li <colyli@suse.de>, linux-raid@vger.kernel.org, Song Liu <song@kernel.org>, dm-devel@redhat.com, linux-block@vger.kernel.org, Tejun Heo <tj@kernel.org> Subject: [dm-devel] [PATCH 6/9] blk-mq: use ->bi_bdev for I/O accounting Date: Tue, 1 Dec 2020 17:54:21 +0100 [thread overview] Message-ID: <20201201165424.2030647-7-hch@lst.de> (raw) In-Reply-To: <20201201165424.2030647-1-hch@lst.de> Remove the reverse map from a sector to a partition for I/O accounting by simply using ->bi_bdev. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-core.c | 6 +++++- block/blk.h | 2 -- block/genhd.c | 48 ------------------------------------------------ 3 files changed, 5 insertions(+), 51 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d53cc887e1b8ea..ad041e903b0a8f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1296,7 +1296,11 @@ void blk_account_io_start(struct request *rq) if (!blk_do_io_stat(rq)) return; - rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); + /* passthrough requests can hold bios that do not have ->bi_bdev set */ + if (rq->bio && rq->bio->bi_bdev) + rq->part = rq->bio->bi_bdev; + else + rq->part = rq->rq_disk->part0; part_stat_lock(); update_io_ticks(rq->part, jiffies, false); diff --git a/block/blk.h b/block/blk.h index 64dc8e5a3f44cb..f93a6af04adbd1 100644 --- a/block/blk.h +++ b/block/blk.h @@ -346,8 +346,6 @@ void blk_queue_free_zone_bitmaps(struct request_queue *q); static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {} #endif -struct block_device *disk_map_sector_rcu(struct gendisk *disk, sector_t sector); - int blk_alloc_devt(struct block_device *part, dev_t *devt); void blk_free_devt(dev_t devt); char *disk_name(struct gendisk *hd, int partno, char *buf); diff --git a/block/genhd.c b/block/genhd.c index 57c709a9f90267..3b9cd766d95228 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -280,54 +280,6 @@ void disk_part_iter_exit(struct disk_part_iter *piter) } EXPORT_SYMBOL_GPL(disk_part_iter_exit); -static inline int sector_in_part(struct block_device *part, sector_t sector) -{ - return part->bd_start_sect <= sector && - sector < part->bd_start_sect + bdev_nr_sectors(part); -} - -/** - * disk_map_sector_rcu - map sector to partition - * @disk: gendisk of interest - * @sector: sector to map - * - * Find out which partition @sector maps to on @disk. This is - * primarily used for stats accounting. - * - * CONTEXT: - * RCU read locked. - * - * RETURNS: - * Found partition on success, part0 is returned if no partition matches - * or the matched partition is being deleted. - */ -struct block_device *disk_map_sector_rcu(struct gendisk *disk, sector_t sector) -{ - struct disk_part_tbl *ptbl; - struct block_device *part; - int i; - - rcu_read_lock(); - ptbl = rcu_dereference(disk->part_tbl); - - part = rcu_dereference(ptbl->last_lookup); - if (part && sector_in_part(part, sector)) - goto out_unlock; - - for (i = 1; i < ptbl->len; i++) { - part = rcu_dereference(ptbl->part[i]); - if (part && sector_in_part(part, sector)) { - rcu_assign_pointer(ptbl->last_lookup, part); - goto out_unlock; - } - } - - part = disk->part0; -out_unlock: - rcu_read_unlock(); - return part; -} - /** * disk_has_partitions * @disk: gendisk of interest -- 2.29.2 -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2020-12-01 16:56 UTC|newest] Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-01 16:54 store a pointer to the block_device in struct bio (again) Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-01 16:54 ` [PATCH 1/9] brd: remove the end of device check in brd_do_bvec Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 22:39 ` Tejun Heo 2020-12-02 22:39 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` [PATCH 2/9] dcssblk: " Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 22:39 ` Tejun Heo 2020-12-02 22:39 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` [PATCH 3/9] block: store a block_device pointer in struct bio Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 22:54 ` Tejun Heo 2020-12-02 22:54 ` [dm-devel] " Tejun Heo 2020-12-03 6:39 ` Ming Lei 2020-12-03 6:39 ` [dm-devel] " Ming Lei 2020-12-03 7:10 ` Ming Lei 2020-12-03 7:10 ` [dm-devel] " Ming Lei 2020-12-03 8:29 ` Christoph Hellwig 2020-12-03 8:29 ` [dm-devel] " Christoph Hellwig 2020-12-03 9:32 ` Ming Lei 2020-12-03 9:32 ` [dm-devel] " Ming Lei 2020-12-03 20:53 ` Keith Busch 2020-12-03 20:53 ` [dm-devel] " Keith Busch 2020-12-01 16:54 ` [PATCH 4/9] block: simplify submit_bio_checks a bit Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 22:55 ` Tejun Heo 2020-12-02 22:55 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` [PATCH 5/9] block: use ->bi_bdev for bio based I/O accounting Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 23:05 ` Tejun Heo 2020-12-02 23:05 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` Christoph Hellwig [this message] 2020-12-01 16:54 ` [dm-devel] [PATCH 6/9] blk-mq: use ->bi_bdev for " Christoph Hellwig 2020-12-02 23:06 ` Tejun Heo 2020-12-02 23:06 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` [PATCH 7/9] block: add a disk_uevent helper Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 23:08 ` Tejun Heo 2020-12-02 23:08 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` [PATCH 8/9] block: remove DISK_PITER_REVERSE Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 23:15 ` Tejun Heo 2020-12-02 23:15 ` [dm-devel] " Tejun Heo 2020-12-01 16:54 ` [PATCH 9/9] block: use an xarray for disk->part_tbl Christoph Hellwig 2020-12-01 16:54 ` [dm-devel] " Christoph Hellwig 2020-12-02 23:22 ` Tejun Heo 2020-12-02 23:22 ` [dm-devel] " Tejun Heo 2020-12-02 22:35 ` store a pointer to the block_device in struct bio (again) Tejun Heo 2020-12-02 22:35 ` [dm-devel] " Tejun Heo 2020-12-02 22:37 ` Tejun Heo 2020-12-02 22:37 ` [dm-devel] " Tejun Heo 2020-12-04 16:43 ` Jens Axboe 2020-12-04 16:43 ` [dm-devel] " Jens Axboe 2020-12-07 18:56 ` Qian Cai 2020-12-07 18:56 ` [dm-devel] " Qian Cai 2020-12-07 19:01 ` Christoph Hellwig 2020-12-07 19:01 ` [dm-devel] " Christoph Hellwig 2020-12-07 20:20 ` Jens Axboe 2020-12-07 20:20 ` [dm-devel] " Jens Axboe 2020-12-08 11:04 ` Christoph Hellwig 2020-12-08 11:04 ` [dm-devel] " Christoph Hellwig 2020-12-08 13:08 ` Qian Cai 2020-12-08 13:08 ` [dm-devel] " Qian Cai 2020-12-08 13:38 ` Daniel Wagner 2020-12-08 13:38 ` [dm-devel] " Daniel Wagner 2020-12-08 14:15 ` Jens Axboe 2020-12-08 14:15 ` [dm-devel] " Jens Axboe
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=20201201165424.2030647-7-hch@lst.de \ --to=hch@lst.de \ --cc=axboe@kernel.dk \ --cc=colyli@suse.de \ --cc=dm-devel@redhat.com \ --cc=linux-bcache@vger.kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-raid@vger.kernel.org \ --cc=linux-s390@vger.kernel.org \ --cc=song@kernel.org \ --cc=tj@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.