diff mbox series

[5/6] block: fold blk_max_size_offset into get_max_io_size

Message ID 20220614090934.570632-6-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/6] block: factor out a chunk_size_left helper | expand

Commit Message

Christoph Hellwig June 14, 2022, 9:09 a.m. UTC
Now that blk_max_size_offset has a single caller left, fold it into that
and clean up the naming convention for the local variables there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-merge.c      |  9 +++++++--
 include/linux/blkdev.h | 19 -------------------
 2 files changed, 7 insertions(+), 21 deletions(-)

Comments

Bart Van Assche June 14, 2022, 4:51 p.m. UTC | #1
On 6/14/22 02:09, Christoph Hellwig wrote:
> Now that blk_max_size_offset has a single caller left, fold it into that
> and clean up the naming convention for the local variables there.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Pankaj Raghav June 15, 2022, 10:48 a.m. UTC | #2
On Tue, Jun 14, 2022 at 11:09:33AM +0200, Christoph Hellwig wrote:
> Now that blk_max_size_offset has a single caller left, fold it into that
> and clean up the naming convention for the local variables there.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-merge.c      |  9 +++++++--
>  include/linux/blkdev.h | 19 -------------------
>  2 files changed, 7 insertions(+), 21 deletions(-)

Looks good,
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
diff mbox series

Patch

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 4da981efddeed..0f5f42ebd0bb0 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -166,9 +166,14 @@  static inline unsigned get_max_io_size(struct request_queue *q,
 {
 	unsigned pbs = queue_physical_block_size(q) >> SECTOR_SHIFT;
 	unsigned lbs = queue_logical_block_size(q) >> SECTOR_SHIFT;
-	unsigned max_sectors, start, end;
+	unsigned max_sectors = queue_max_sectors(q), start, end;
+
+	if (q->limits.chunk_sectors) {
+		max_sectors = min(max_sectors,
+			blk_chunk_sectors_left(bio->bi_iter.bi_sector,
+					       q->limits.chunk_sectors));
+	}
 
-	max_sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector, 0);
 	start = bio->bi_iter.bi_sector & (pbs - 1);
 	end = (start + max_sectors) & ~(pbs - 1);
 	if (end > start)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e66ad451274ec..05e60ee269d91 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -944,25 +944,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
  */