* [PATCH v2] block: only fail dma-buf bios that need block layer PI
@ 2026-10-29 15:58 Kyle Bader
0 siblings, 0 replies; only message in thread
From: Kyle Bader @ 2026-10-29 15:58 UTC (permalink / raw)
To: Jens Axboe, Pavel Begunkov
Cc: Kyle Bader, Anuj Gupta, Kanchan Joshi, Christoph Hellwig,
Keith Busch, Martin K. Petersen, Tushar Gohad, linux-block,
io-uring, linux-nvme, linux-kernel
From: Kyle Bader <kbader@ibm.com>
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.
Link: https://lore.kernel.org/all/bbb87d6b-b7a3-487a-8be4-27f3f9ce4a1b@samsung.com/
Assisted-by: LLM
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Kyle Bader <kbader@ibm.com>
---
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/20261028181412.1919506-1-kbader@redhat.com/
block/blk-mq.c | 9 ++++++++-
block/fops.c | 2 --
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 7fff1305b..3fc9fdeb3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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;
}
diff --git a/block/fops.c b/block/fops.c
index 01bc8afe3..5c8024011 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -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
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-29 15:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-29 15:58 [PATCH v2] block: only fail dma-buf bios that need block layer PI Kyle Bader
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®