[PATCH v2 4/5] block: map dma-buf iterators in blk_rq_map_user_iov()
Anuj Gupta
anuj1072538 at gmail.com
Thu Oct 22 07:44:55 PDT 2026
From: Anuj Gupta <anuj20.g at samsung.com>
A dma-buf iterator can't fall back to a bounce copy, so map it directly
with blk_rq_map_user_bvec(), which already handles it through
bio_iov_iter_set(). Fail with -EINVAL where a copy would otherwise be
needed, and update the blk_rq_map_user_bvec() comment to match.
Signed-off-by: Anuj Gupta <anuj20.g at samsung.com>
---
block/blk-map.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/block/blk-map.c b/block/blk-map.c
index 9cb9605d1f62..d1e096fdb03d 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -459,7 +459,7 @@ int blk_rq_append_bio(struct request *rq, struct bio *bio)
}
EXPORT_SYMBOL(blk_rq_append_bio);
-/* Prepare bio for passthrough IO given ITER_BVEC iter */
+/* Prepare a bio for passthrough I/O from a directly mapped iterator. */
static int blk_rq_map_user_bvec(struct request *rq, const struct iov_iter *iter)
{
unsigned int max_bytes = rq->q->limits.max_hw_sectors << SECTOR_SHIFT;
@@ -506,6 +506,19 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
struct iov_iter i;
int ret = -EINVAL;
+ if (iov_iter_is_dmabuf_map(iter)) {
+ if (map_data || (iov_iter_alignment(iter) & align))
+ return -EINVAL;
+ ret = blk_rq_map_user_bvec(rq, iter);
+ /*
+ * -EREMOTEIO asks the caller to fall back to a bounce copy,
+ * which a dma-buf can't do.
+ */
+ if (ret == -EREMOTEIO)
+ ret = -EINVAL;
+ return ret;
+ }
+
if (map_data)
copy = true;
else if (iov_iter_alignment(iter) & align)
--
2.43.0
More information about the Linux-nvme
mailing list