[RFC PATCH 4/6] io_uring: add helper for fixed-buffer uring-cmd
Kanchan Joshi
joshi.k at samsung.com
Thu Aug 5 05:55:37 PDT 2021
Refactor the existing code and factor out helper that can be used
for passthrough with fixed-buffer. This is a prep patch.
Signed-off-by: Kanchan Joshi <joshi.k at samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g at samsung.com>
---
fs/io_uring.c | 21 +++++++++++++++------
include/linux/io_uring.h | 7 +++++++
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3361056313a7..1f2263a78c8e 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2792,12 +2792,10 @@ static void kiocb_done(struct kiocb *kiocb, ssize_t ret,
}
}
}
-
-static int __io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *iter,
- struct io_mapped_ubuf *imu)
+static int __io_import_fixed(u64 buf_addr, size_t len, int rw,
+ struct iov_iter *iter, struct io_mapped_ubuf *imu)
{
- size_t len = req->rw.len;
- u64 buf_end, buf_addr = req->rw.addr;
+ u64 buf_end;
size_t offset;
if (unlikely(check_add_overflow(buf_addr, (u64)len, &buf_end)))
@@ -2864,8 +2862,19 @@ static int io_import_fixed(struct io_kiocb *req, int rw, struct iov_iter *iter)
imu = READ_ONCE(ctx->user_bufs[index]);
req->imu = imu;
}
- return __io_import_fixed(req, rw, iter, imu);
+ return __io_import_fixed(req->rw.addr, req->rw.len, rw, iter, imu);
+}
+
+int io_uring_cmd_import_fixed(void *ubuf, unsigned long len,
+ int rw, struct iov_iter *iter, void *ioucmd)
+{
+ u64 buf_addr = (u64)ubuf;
+ struct io_kiocb *req = container_of(ioucmd, struct io_kiocb, uring_cmd);
+ struct io_mapped_ubuf *imu = req->imu;
+
+ return __io_import_fixed(buf_addr, len, rw, iter, imu);
}
+EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed);
static void io_ring_submit_unlock(struct io_ring_ctx *ctx, bool needs_lock)
{
diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h
index 235d1603f97e..0bd8f611edb8 100644
--- a/include/linux/io_uring.h
+++ b/include/linux/io_uring.h
@@ -20,6 +20,8 @@ struct io_uring_cmd {
};
#if defined(CONFIG_IO_URING)
+int io_uring_cmd_import_fixed(void *ubuf, unsigned long len,
+ int rw, struct iov_iter *iter, void *ioucmd);
void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret);
void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
void (*driver_cb)(struct io_uring_cmd *));
@@ -49,6 +51,11 @@ static inline void io_uring_cmd_complete_in_task(struct io_uring_cmd *ioucmd,
void (*driver_cb)(struct io_uring_cmd *))
{
}
+int io_uring_cmd_import_fixed(void *ubuf, unsigned long len,
+ int rw, struct iov_iter *iter, void *ioucmd)
+{
+ return -1;
+}
static inline struct sock *io_uring_get_socket(struct file *file)
{
return NULL;
--
2.25.1
More information about the Linux-nvme
mailing list