From: Kyle Bader <kbader@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, Pavel Begunkov <asml.silence@gmail.com>
Cc: Kyle Bader <kbader@ibm.com>, Anuj Gupta <anuj20.g@samsung.com>,
Kanchan Joshi <joshi.k@samsung.com>,
Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Tushar Gohad <tushar.gohad@intel.com>,
linux-block@vger.kernel.org, io-uring@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] block: only fail dma-buf bios that need block layer PI
Date: Thu, 29 Oct 2026 15:58:21 +0000 [thread overview]
Message-ID: <20261029155821.2983229-1-kbader@redhat.com> (raw)
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
reply other threads:[~2026-10-29 15:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029155821.2983229-1-kbader@redhat.com \
--to=kbader@redhat.com \
--cc=anuj20.g@samsung.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=io-uring@vger.kernel.org \
--cc=joshi.k@samsung.com \
--cc=kbader@ibm.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=tushar.gohad@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®