Skip to content

Commit dadf03c

Browse files
axboekdave
authored andcommitted
io_uring/cmd: rename struct uring_cache to io_uring_cmd_data
In preparation for making this more generically available for ->uring_cmd() usage that needs stable command data, rename it and move it to io_uring/cmd.h instead. Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent fca432e commit dadf03c

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

include/linux/io_uring/cmd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct io_uring_cmd {
1818
u8 pdu[32]; /* available inline for free use */
1919
};
2020

21+
struct io_uring_cmd_data {
22+
struct io_uring_sqe sqes[2];
23+
};
24+
2125
static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe)
2226
{
2327
return sqe->cmd;

io_uring/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
315315
ret |= io_alloc_cache_init(&ctx->rw_cache, IO_ALLOC_CACHE_MAX,
316316
sizeof(struct io_async_rw));
317317
ret |= io_alloc_cache_init(&ctx->uring_cache, IO_ALLOC_CACHE_MAX,
318-
sizeof(struct uring_cache));
318+
sizeof(struct io_uring_cmd_data));
319319
spin_lock_init(&ctx->msg_lock);
320320
ret |= io_alloc_cache_init(&ctx->msg_cache, IO_ALLOC_CACHE_MAX,
321321
sizeof(struct io_kiocb));

io_uring/opdef.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/fs.h>
88
#include <linux/file.h>
99
#include <linux/io_uring.h>
10+
#include <linux/io_uring/cmd.h>
1011

1112
#include "io_uring.h"
1213
#include "opdef.h"
@@ -414,7 +415,7 @@ const struct io_issue_def io_issue_defs[] = {
414415
.plug = 1,
415416
.iopoll = 1,
416417
.iopoll_queue = 1,
417-
.async_size = 2 * sizeof(struct io_uring_sqe),
418+
.async_size = sizeof(struct io_uring_cmd_data),
418419
.prep = io_uring_cmd_prep,
419420
.issue = io_uring_cmd,
420421
},

io_uring/uring_cmd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
#include "rsrc.h"
1717
#include "uring_cmd.h"
1818

19-
static struct uring_cache *io_uring_async_get(struct io_kiocb *req)
19+
static struct io_uring_cmd_data *io_uring_async_get(struct io_kiocb *req)
2020
{
2121
struct io_ring_ctx *ctx = req->ctx;
22-
struct uring_cache *cache;
22+
struct io_uring_cmd_data *cache;
2323

2424
cache = io_alloc_cache_get(&ctx->uring_cache);
2525
if (cache) {
@@ -35,7 +35,7 @@ static struct uring_cache *io_uring_async_get(struct io_kiocb *req)
3535
static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags)
3636
{
3737
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
38-
struct uring_cache *cache = req->async_data;
38+
struct io_uring_cmd_data *cache = req->async_data;
3939

4040
if (issue_flags & IO_URING_F_UNLOCKED)
4141
return;
@@ -183,7 +183,7 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req,
183183
const struct io_uring_sqe *sqe)
184184
{
185185
struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd);
186-
struct uring_cache *cache;
186+
struct io_uring_cmd_data *cache;
187187

188188
cache = io_uring_async_get(req);
189189
if (unlikely(!cache))
@@ -256,7 +256,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
256256

257257
ret = file->f_op->uring_cmd(ioucmd, issue_flags);
258258
if (ret == -EAGAIN) {
259-
struct uring_cache *cache = req->async_data;
259+
struct io_uring_cmd_data *cache = req->async_data;
260260

261261
if (ioucmd->sqe != (void *) cache)
262262
memcpy(cache, ioucmd->sqe, uring_sqe_size(req->ctx));

io_uring/uring_cmd.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
struct uring_cache {
4-
struct io_uring_sqe sqes[2];
5-
};
6-
73
int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags);
84
int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
95

0 commit comments

Comments
 (0)