]> www.infradead.org Git - users/hch/block.git/commitdiff
block: open code blk_max_size_offset in blk_rq_get_max_sectors
authorChristoph Hellwig <hch@lst.de>
Tue, 28 Sep 2021 05:42:49 +0000 (07:42 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 28 Sep 2021 05:42:49 +0000 (07:42 +0200)
blk_rq_get_max_sectors always uses q->limits.chunk_sectors as the
chunk_sectors argument, and already checks for max_sectors through the
call to blk_queue_get_max_sectors.  That means much of
blk_max_size_offset is not needed and open coding it simplifies the code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk-merge.c

index 5b4f23014df8a9af80c0969b97d916140e958153..bf977f45219e49124c90823d71b080189242fb09 100644 (file)
@@ -563,17 +563,18 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
                                                  sector_t offset)
 {
        struct request_queue *q = rq->q;
+       unsigned int max_sectors;
 
        if (blk_rq_is_passthrough(rq))
                return q->limits.max_hw_sectors;
 
-       if (!q->limits.chunk_sectors ||
-           req_op(rq) == REQ_OP_DISCARD ||
-           req_op(rq) == REQ_OP_SECURE_ERASE)
-               return blk_queue_get_max_sectors(q, req_op(rq));
-
-       return min(blk_max_size_offset(q, offset, 0),
-                       blk_queue_get_max_sectors(q, req_op(rq)));
+       max_sectors = blk_queue_get_max_sectors(q, req_op(rq));
+       if (q->limits.chunk_sectors &&
+           req_op(rq) != REQ_OP_DISCARD &&
+           req_op(rq) != REQ_OP_SECURE_ERASE)
+               max_sectors = min(max_sectors,
+                       chunk_size_left(offset, q->limits.chunk_sectors));
+       return max_sectors;
 }
 
 static inline int ll_new_hw_segment(struct request *req, struct bio *bio,