summaryrefslogtreecommitdiff
path: root/block/blk-merge.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-07-27 12:22:59 -0400
committerJens Axboe <axboe@kernel.dk>2022-08-02 21:08:53 -0600
commitb6dc6198ebe855d70e6f68d279c4015fe5d73e7b (patch)
treefb7ffa213e252d25d720ff4bfa7f8ef076cefa9a /block/blk-merge.c
parenta85b36375b05f70301f15cafb9030cae7c789f76 (diff)
block: move bio_allowed_max_sectors to blk-merge.c
Move this helper into the only file where it is used. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20220727162300.3089193-6-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r--block/blk-merge.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index ce73b3b6c2a7..c2bf8723f30c 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -95,6 +95,16 @@ static inline bool req_gap_front_merge(struct request *req, struct bio *bio)
return bio_will_gap(req->q, NULL, bio, req->bio);
}
+/*
+ * The max size one bio can handle is UINT_MAX becasue bvec_iter.bi_size
+ * is defined as 'unsigned int', meantime it has to be aligned to with the
+ * logical block size, which is the minimum accepted unit by hardware.
+ */
+static unsigned int bio_allowed_max_sectors(struct request_queue *q)
+{
+ return round_down(UINT_MAX, queue_logical_block_size(q)) >> 9;
+}
+
static struct bio *bio_split_discard(struct bio *bio, struct request_queue *q,
unsigned *nsegs, struct bio_set *bs)
{