From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Mike Snitzer <snitzer@redhat.com>,
linux-block@vger.kernel.org, dm-devel@redhat.com
Subject: [PATCH 5/6] block: fold blk_max_size_offset into get_max_io_size
Date: Wed, 13 Oct 2021 19:12:14 +0200 [thread overview]
Message-ID: <20211013171215.1177671-6-hch@lst.de> (raw)
In-Reply-To: <20211013171215.1177671-1-hch@lst.de>
Fold blk_max_size_offset into the only remaining user.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-merge.c | 15 ++++++++++-----
include/linux/blkdev.h | 19 -------------------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 3e9dde152fdcd..87ea3e7b8ad28 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -177,14 +177,19 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
static inline unsigned get_max_io_size(struct request_queue *q,
struct bio *bio)
{
- unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
- unsigned max_sectors = sectors;
unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
- unsigned start_offset = bio->bi_iter.bi_sector & (pbs - 1);
+ sector_t sector = bio->bi_iter.bi_sector;
+ unsigned start_offset = sector & (pbs - 1);
+ unsigned sectors = q->limits.max_sectors;
+ unsigned max_sectors;
+
+ if (q->limits.chunk_sectors) {
+ sectors = min(sectors, blk_chunk_sectors_left(sector,
+ q->limits.chunk_sectors));
+ }
- max_sectors += start_offset;
- max_sectors &= ~(pbs - 1);
+ max_sectors = (sectors + start_offset) & ~(pbs - 1);
if (max_sectors > start_offset)
return max_sectors - start_offset;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c6ecd996c2d46..7e6b68969cec0 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -634,25 +634,6 @@ static inline unsigned int blk_chunk_sectors_left(sector_t offset,
return chunk_sectors - (offset & (chunk_sectors - 1));
}
-/*
- * Return maximum size of a request at given offset. Only valid for
- * file system requests.
- */
-static inline unsigned int blk_max_size_offset(struct request_queue *q,
- sector_t offset,
- unsigned int chunk_sectors)
-{
- if (!chunk_sectors) {
- if (q->limits.chunk_sectors)
- chunk_sectors = q->limits.chunk_sectors;
- else
- return q->limits.max_sectors;
- }
-
- return min(q->limits.max_sectors,
- blk_chunk_sectors_left(offset, chunk_sectors));
-}
-
/*
* Access functions for manipulating queue properties
*/
--
2.30.2
next prev parent reply other threads:[~2021-10-13 17:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 17:12 simplify I/O size calculation helpers v2 Christoph Hellwig
2021-10-13 17:12 ` [PATCH 1/6] block: factor out a chunk_size_left helper Christoph Hellwig
2021-10-13 17:12 ` [PATCH 2/6] dm: open code blk_max_size_offset in max_io_len Christoph Hellwig
2021-10-13 17:12 ` [PATCH 3/6] block: only call blk_queue_get_max_sectors once in blk_rq_get_max_sectors Christoph Hellwig
2021-10-13 17:12 ` [PATCH 4/6] block: open code blk_max_size_offset " Christoph Hellwig
2021-10-13 17:12 ` Christoph Hellwig [this message]
2021-10-13 17:12 ` [PATCH 6/6] block: pass the start sector to get_max_io_size Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2022-06-14 9:09 clean up the chunk_sizehandling helpers a little Christoph Hellwig
2022-06-14 9:09 ` [PATCH 5/6] block: fold blk_max_size_offset into get_max_io_size Christoph Hellwig
2022-06-14 16:51 ` Bart Van Assche
2022-06-15 10:48 ` Pankaj Raghav
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=20211013171215.1177671-6-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=snitzer@redhat.com \
/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