Skip to content

Commit ef49027

Browse files
isilenceaxboe
authored andcommitted
io_uring/cmd: introduce io_uring_cmd_import_fixed_vec
io_uring_cmd_import_fixed_vec() is a cmd helper around vectored registered buffer import functions, which caches the memory under the hood. The lifetime of the vectore and hence the iterator is bound to the request. Furthermore, the user is not allowed to call it multiple times for a single request. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/97487a80dec3fb8cf8aeedf1f9026ef6d503fe4b.1742579999.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 3a4689a commit ef49027

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

include/linux/io_uring/cmd.h

+13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
4343
struct iov_iter *iter,
4444
struct io_uring_cmd *ioucmd,
4545
unsigned int issue_flags);
46+
int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
47+
const struct iovec __user *uvec,
48+
size_t uvec_segs,
49+
int ddir, struct iov_iter *iter,
50+
unsigned issue_flags);
4651

4752
/*
4853
* Completes the request, i.e. posts an io_uring CQE and deallocates @ioucmd
@@ -76,6 +81,14 @@ io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
7681
{
7782
return -EOPNOTSUPP;
7883
}
84+
static inline int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
85+
const struct iovec __user *uvec,
86+
size_t uvec_segs,
87+
int ddir, struct iov_iter *iter,
88+
unsigned issue_flags)
89+
{
90+
return -EOPNOTSUPP;
91+
}
7992
static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret,
8093
u64 ret2, unsigned issue_flags)
8194
{

io_uring/uring_cmd.c

+19
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,25 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
277277
}
278278
EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed);
279279

280+
int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
281+
const struct iovec __user *uvec,
282+
size_t uvec_segs,
283+
int ddir, struct iov_iter *iter,
284+
unsigned issue_flags)
285+
{
286+
struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);
287+
struct io_async_cmd *ac = req->async_data;
288+
int ret;
289+
290+
ret = io_prep_reg_iovec(req, &ac->vec, uvec, uvec_segs);
291+
if (ret)
292+
return ret;
293+
294+
return io_import_reg_vec(ddir, iter, req, &ac->vec, uvec_segs,
295+
issue_flags);
296+
}
297+
EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed_vec);
298+
280299
void io_uring_cmd_issue_blocking(struct io_uring_cmd *ioucmd)
281300
{
282301
struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);

io_uring/uring_cmd.h

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx,
1616
struct io_uring_task *tctx, bool cancel_all);
1717

1818
void io_cmd_cache_free(const void *entry);
19+
20+
int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd,
21+
const struct iovec __user *uvec,
22+
size_t uvec_segs,
23+
int ddir, struct iov_iter *iter,
24+
unsigned issue_flags);

0 commit comments

Comments
 (0)