hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9VTE3 CVE: NA
--------------------------------
Add blk_queue_get_max_sectors_wrapper() function to get atomic write max sectors.
Signed-off-by: Long Li leo.lilong@huawei.com --- block/blk-core.c | 2 +- include/linux/blkdev.h | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c index a1ebbf96d19a..68dddd64382e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1391,7 +1391,7 @@ EXPORT_SYMBOL(submit_bio); static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q, struct request *rq) { - unsigned int max_sectors = blk_queue_get_max_sectors(q, req_op(rq)); + unsigned int max_sectors = blk_queue_get_max_sectors_wrapper(rq);
if (blk_rq_sectors(rq) > max_sectors) { /* diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 4ddfa95f266a..39523a82fb81 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1107,6 +1107,15 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, return q->limits.max_sectors; }
+static inline unsigned int blk_queue_get_max_sectors_wrapper(struct request *rq) +{ + + struct request_queue *q = rq->q; + int op = req_op(rq); + + return blk_queue_get_max_sectors(q, op); +} + /* * Return maximum size of a request at given offset. Only valid for * file system requests. @@ -1141,10 +1150,10 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq, 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 blk_queue_get_max_sectors_wrapper(rq);
return min(blk_max_size_offset(q, offset, 0), - blk_queue_get_max_sectors(q, req_op(rq))); + blk_queue_get_max_sectors_wrapper(rq)); }
static inline unsigned int blk_rq_count_bios(struct request *rq)