block: only fail dma-buf bios that need block layer PI
Subsystems (3)
PATCH v2 1/1 block: only fail dma-buf bios that need block layer PI
From: Kyle Bader <[email protected]>
All dma-buf (P2P) I/O to a device with integrity data is rejected today, at registration and in blk_mq_submit_bio(). Only a bio for which the block layer generates or verifies PI needs that. The block layer then walks the bio_vecs, and a dma-buf bio has none.
Reject only those bios, and remove the check at registration. Then a submitter that attaches its own PI, for example with IORING_RW_ATTR_FLAG_PI, can do dma-buf I/O to such a device.
---
v2: a shorter commit message (Christoph), and Anuj's Reviewed-by. The code is the same as in v1, so the tests of v1 still apply.
v1: https://lore.kernel.org/all/[email protected]/
block/blk-mq.c | 9 ++++++++- block/fops.c | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-)
block/blk-mq.c +8 -1
@@ -3138,8 +3138,15 @@ 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))) { +bdev_has_integrity_csum (bio->bi_bdev) && + (bio_integrity_action (bio) &BI_ACT_CHECK ))) {bio_endio_status (bio,BLK_STS_NOTSUPP ); goto queue_exit; }
block/fops.c +0 -2
@@ -947,8 +947,6 @@ static int blkdev_init_dma_buf_io_ctx(struct file *file,return -EINVAL ;if (!disk->fops->init_dma_buf_io_ctx)return -EOPNOTSUPP ; -if (bdev_has_integrity_csum (bdev)) -return -EOPNOTSUPP ;return disk->fops->init_dma_buf_io_ctx (bdev, ctx); }
base-commit: 45b716456dd99488a0cef58482120dc0474aa696
Signature · 1 line
2.56.0
Quoted 10 lines · Kyle Bader
From: Kyle Bader <[email protected]>
All dma-buf (P2P) I/O to a device with integrity data is rejected today, at registration and in
blk_mq_submit_bio(). Only a bio for which the block layer generates or verifies PI needs that. The block layer then walks thebio_vecs, and a dma-buf bio has none.Reject only those bios, and remove the check at registration. Then a submitter that attaches its own PI, for example with
IORING_RW_ATTR_FLAG_PI, can do dma-buf I/O to such a device.
Looks good,
It's also enticing to shove it under the existing bio_integrity_action() check, but it can be done later.
Quoted 50 lines
Assisted-by LLMReviewed-by Anuj Gupta <[email protected]>Signed-off-by Kyle Bader <[email protected]>---
v2: a shorter commit message (Christoph), and Anuj's Reviewed-by. The code is the same as in v1, so the tests of v1 still apply.v1: https://lore.kernel.org/all/[email protected]/
block/blk-mq.c | 9 ++++++++- block/fops.c | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-)block/blk-mq.c +8
-1@@ -3138,8 +3138,15 @@ 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))) { +bdev_has_integrity_csum (bio->bi_bdev) && + (bio_integrity_action (bio) &BI_ACT_CHECK ))) {bio_endio_status (bio,BLK_STS_NOTSUPP ); goto queue_exit; }block/fops.c +0
-2@@ -947,8 +947,6 @@ static int blkdev_init_dma_buf_io_ctx(struct file *file,return -EINVAL ;if (!disk->fops->init_dma_buf_io_ctx)return -EOPNOTSUPP ; -if (bdev_has_integrity_csum (bdev)) -return -EOPNOTSUPP ;return disk->fops->init_dma_buf_io_ctx (bdev, ctx); }base-commit:
45b716456dd99488a0cef58482120dc0474aa696
Signature · 1 line
Pavel Begunkov
Looks good:
Quoted 10 lines · Kyle Bader
All dma-buf (P2P) I/O to a device with integrity data is rejected today, at registration and in
blk_mq_submit_bio(). Only a bio for which the block layer generates or verifies PI needs that. The block layer then walks thebio_vecs, and a dma-buf bio has none.Reject only those bios, and remove the check at registration. Then a submitter that attaches its own PI, for example with
IORING_RW_ATTR_FLAG_PI, can do dma-buf I/O to such a device.[...]
Applied, thanks!
[1/1] block: only fail dma-buf bios that need block layer PI
commit: d734b6433b2fd248bc25a2ea1fa60c34b40ba15c
Best regards,
Signature · 1 line
Jens Axboe