From: Mengmeng Zhao <[email protected]> Move the dma-buf integrity check out of blk_mq_submit_bio() into bio_dmabuf_should_reject(), so that such checks have one place to grow.
No functional change. Signed-off-by: Mengmeng Zhao <[email protected]> Signed-off-by: Li Wang <[email protected]> --- block/blk-mq.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 5ae22d556540..887d5cc5bb5e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3099,6 +3099,20 @@ static bool bio_unaligned(const struct bio *bio, struct request_queue *q) return false; } +/* + * A dma-buf bio carries a driver-private map instead of pages, so the block + * layer cannot generate or verify integrity metadata for it. Only reject when + * it would have to do that itself, not if the submitter attached its own + * payload or if generation or verification is turned off for the device. + */ +static bool bio_dmabuf_should_reject(struct bio *bio) +{ + if (!op_is_dmabuf(bio->bi_opf)) + return false; + return bdev_has_integrity_csum(bio->bi_bdev) && + (bio_integrity_action(bio) & BI_ACT_CHECK); +} + /** * blk_mq_submit_bio - Create and send a request to block device. * @bio: Bio pointer. @@ -3160,15 +3174,7 @@ void blk_mq_submit_bio(struct bio *bio) goto queue_exit; } - /* - * The block layer cannot generate or verify PI for a dma-buf bio, as - * that walks the data pages. Only fail the bio if it needs that, not - * if the submitter attached its own integrity payload or if PI - * generation or verification is turned off for the device. - */ - if (unlikely(op_is_dmabuf(bio->bi_opf) && - bdev_has_integrity_csum(bio->bi_bdev) && - (bio_integrity_action(bio) & BI_ACT_CHECK))) { + if (unlikely(bio_dmabuf_should_reject(bio))) { bio_endio_status(bio, BLK_STS_NOTSUPP); goto queue_exit; } -- 2.43.0
