From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org
Cc: linux-fsdevel@vger.kernel.org, Keith Busch <kbusch@kernel.org>,
David Wei <dw@davidwei.uk>,
Vishal Verma <vishal1.verma@intel.com>,
asml.silence@gmail.com
Subject: [RFC 09/12] io_uring/rsrc: add imu flags
Date: Fri, 27 Jun 2025 16:10:36 +0100 [thread overview]
Message-ID: <ff094ad30f783ad515e48474d66201e909070827.1751035820.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1751035820.git.asml.silence@gmail.com>
Replace is_kbuf with a flags field in io_mapped_ubuf. There will be new
flags shortly, and bit fields are often not as convenient to work with.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/rsrc.c | 12 ++++++------
io_uring/rsrc.h | 6 +++++-
io_uring/rw.c | 3 ++-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 21f4932ecafa..274274b80b96 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -850,7 +850,7 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
imu->folio_shift = PAGE_SHIFT;
imu->release = io_release_ubuf;
imu->priv = imu;
- imu->is_kbuf = false;
+ imu->flags = 0;
imu->dir = IO_IMU_DEST | IO_IMU_SOURCE;
if (coalesced)
imu->folio_shift = data.folio_shift;
@@ -999,7 +999,7 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq,
refcount_set(&imu->refs, 1);
imu->release = release;
imu->priv = rq;
- imu->is_kbuf = true;
+ imu->flags = IO_IMU_F_KBUF;
imu->dir = 1 << rq_data_dir(rq);
bvec = imu->bvec;
@@ -1034,7 +1034,7 @@ int io_buffer_unregister_bvec(struct io_uring_cmd *cmd, unsigned int index,
ret = -EINVAL;
goto unlock;
}
- if (!node->buf->is_kbuf) {
+ if (!(node->buf->flags & IO_IMU_F_KBUF)) {
ret = -EBUSY;
goto unlock;
}
@@ -1100,7 +1100,7 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
offset = buf_addr - imu->ubuf;
- if (imu->is_kbuf)
+ if (imu->flags & IO_IMU_F_KBUF)
return io_import_kbuf(ddir, iter, imu, len, offset);
/*
@@ -1509,7 +1509,7 @@ int io_import_reg_vec(int ddir, struct iov_iter *iter,
iovec_off = vec->nr - nr_iovs;
iov = vec->iovec + iovec_off;
- if (imu->is_kbuf) {
+ if (imu->flags & IO_IMU_F_KBUF) {
int ret = io_kern_bvec_size(iov, nr_iovs, imu, &nr_segs);
if (unlikely(ret))
@@ -1543,7 +1543,7 @@ int io_import_reg_vec(int ddir, struct iov_iter *iter,
req->flags |= REQ_F_NEED_CLEANUP;
}
- if (imu->is_kbuf)
+ if (imu->flags & IO_IMU_F_KBUF)
return io_vec_fill_kern_bvec(ddir, iter, imu, iov, nr_iovs, vec);
return io_vec_fill_bvec(ddir, iter, imu, iov, nr_iovs, vec);
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 0d2138f16322..15ad4a885ae5 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -28,6 +28,10 @@ enum {
IO_IMU_SOURCE = 1 << ITER_SOURCE,
};
+enum {
+ IO_IMU_F_KBUF = 1,
+};
+
struct io_mapped_ubuf {
u64 ubuf;
unsigned int len;
@@ -37,7 +41,7 @@ struct io_mapped_ubuf {
unsigned long acct_pages;
void (*release)(void *);
void *priv;
- bool is_kbuf;
+ u8 flags;
u8 dir;
struct bio_vec bvec[] __counted_by(nr_bvecs);
};
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 710d8cd53ebb..cfcd7d26d8dc 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -696,7 +696,8 @@ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
if ((kiocb->ki_flags & IOCB_NOWAIT) &&
!(kiocb->ki_filp->f_flags & O_NONBLOCK))
return -EAGAIN;
- if ((req->flags & REQ_F_BUF_NODE) && req->buf_node->buf->is_kbuf)
+ if ((req->flags & REQ_F_BUF_NODE) &&
+ (req->buf_node->buf->flags & IO_IMU_F_KBUF))
return -EFAULT;
ppos = io_kiocb_ppos(kiocb);
--
2.49.0
next prev parent reply other threads:[~2025-06-27 15:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 15:10 [RFC 00/12] io_uring dmabuf read/write support Pavel Begunkov
2025-06-27 15:10 ` [RFC 01/12] file: add callback returning dev for dma operations Pavel Begunkov
2025-06-27 15:10 ` [RFC 02/12] iov_iter: introduce iter type for pre-registered dma Pavel Begunkov
2025-06-27 15:10 ` [RFC 03/12] block: move around bio flagging helpers Pavel Begunkov
2025-06-27 15:10 ` [RFC 04/12] block: introduce dmavec bio type Pavel Begunkov
2025-06-27 15:10 ` [RFC 05/12] block: implement ->get_dma_device callback Pavel Begunkov
2025-06-27 15:10 ` [RFC 06/12] nvme-pci: add support for user passed dma vectors Pavel Begunkov
2025-06-27 15:10 ` [RFC 07/12] io_uring/rsrc: extended reg buffer registration Pavel Begunkov
2025-06-27 15:10 ` [RFC 08/12] io_uring: add basic dmabuf helpers Pavel Begunkov
2025-06-27 15:10 ` Pavel Begunkov [this message]
2025-06-27 15:10 ` [RFC 10/12] io_uring/rsrc: add dmabuf-backed buffer registeration Pavel Begunkov
2025-06-27 15:10 ` [RFC 11/12] io_uring/rsrc: implement dmabuf regbuf import Pavel Begunkov
2025-06-27 15:10 ` [RFC 12/12] io_uring/rw: enable dma registered buffers Pavel Begunkov
2025-07-03 14:23 ` [RFC 00/12] io_uring dmabuf read/write support Christoph Hellwig
2025-07-03 14:37 ` Christian König
2025-07-07 11:15 ` Pavel Begunkov
2025-07-07 14:48 ` Christoph Hellwig
2025-07-07 15:41 ` Pavel Begunkov
2025-07-08 9:45 ` Christoph Hellwig
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=ff094ad30f783ad515e48474d66201e909070827.1751035820.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=dw@davidwei.uk \
--cc=io-uring@vger.kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=vishal1.verma@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