Re: [PATCH v9 05/13] block: add dma-buf support for raw bdev
From: Anuj Gupta/Anuj Gupta
Date: Thu Oct 08 2026 - 08:36:56 EST
On 10/7/2026 7:12 AM, Pavel Begunkov wrote:
> +static int blkdev_init_dma_buf_io_ctx(struct file *file,
> + struct dma_buf_io_ctx *ctx)
> +{
> + struct block_device *bdev = file_bdev(file);
> + struct gendisk *disk = bdev->bd_disk;
> +
> + if (!(file->f_flags & O_DIRECT))
> + return -EINVAL;
> + if (!disk->fops->init_dma_buf_io_ctx)
> + return -EOPNOTSUPP;
dma-buf doesn't work with PI: bi_dmabuf_map aliases bi_io_vec, and
blk_integrity_iterate() walks it as bvecs to generate/verify the
checksum. rw-dmabuf liburing test hangs on a PI enabled NVMe. Something
like below is needed:
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e929f94b25c7..1b7f8cbbda8b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3150,6 +3150,12 @@ void blk_mq_submit_bio(struct bio *bio)
goto queue_exit;
}
+ if (unlikely(op_is_dmabuf(bio->bi_opf) &&
+ bdev_has_integrity_csum(bio->bi_bdev))) {
+ bio_endio_status(bio, BLK_STS_NOTSUPP);
+ goto queue_exit;
+ }
+
if ((bio->bi_opf & REQ_POLLED) && !blk_mq_can_poll(q)) {
bio_endio_status(bio, BLK_STS_NOTSUPP);
goto queue_exit;
diff --git a/block/fops.c b/block/fops.c
index e9da48ab73be..6c6700df943c 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -976,6 +976,8 @@ 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);
}