From: Stefan Metzmacher <[email protected]>
To: [email protected], [email protected]
Cc: Stefan Metzmacher <[email protected]>
Subject: [RFC PATCH 5/8] io_uring: only access generic struct io_uring_sqe elements in io_uring.c
Date: Fri, 12 Aug 2022 10:34:29 +0200 [thread overview]
Message-ID: <cc6807c4bdd438218cc6e2240b970799dd15a834.1660291547.git.metze@samba.org> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Stefan Metzmacher <[email protected]>
---
io_uring/io_uring.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 60426265ee9f..f82173bde393 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -39,6 +39,7 @@
* Copyright (C) 2018-2019 Jens Axboe
* Copyright (c) 2018-2019 Christoph Hellwig
*/
+#define IO_URING_SQE_HIDE_LEGACY 1
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
@@ -1837,10 +1838,10 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
u8 opcode;
/* req is partially pre-initialised, see io_preinit_req() */
- req->opcode = opcode = READ_ONCE(sqe->opcode);
+ req->opcode = opcode = READ_ONCE(sqe->hdr.opcode);
/* same numerical values with corresponding REQ_F_*, safe to copy */
- req->flags = sqe_flags = READ_ONCE(sqe->flags);
- req->cqe.user_data = READ_ONCE(sqe->user_data);
+ req->flags = sqe_flags = READ_ONCE(sqe->hdr.flags);
+ req->cqe.user_data = READ_ONCE(sqe->common.user_data);
req->file = NULL;
req->rsrc_node = NULL;
req->task = current;
@@ -1857,7 +1858,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
if (sqe_flags & IOSQE_BUFFER_SELECT) {
if (!def->buffer_select)
return -EOPNOTSUPP;
- req->buf_index = READ_ONCE(sqe->buf_group);
+ req->buf_index = READ_ONCE(sqe->common.buf_info);
}
if (sqe_flags & IOSQE_CQE_SKIP_SUCCESS)
ctx->drain_disabled = true;
@@ -1881,7 +1882,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
}
}
- if (!def->ioprio && sqe->ioprio)
+ if (!def->ioprio && sqe->hdr.ioprio)
return -EINVAL;
if (!def->iopoll && (ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
@@ -1889,7 +1890,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
if (def->needs_file) {
struct io_submit_state *state = &ctx->submit_state;
- req->cqe.fd = READ_ONCE(sqe->fd);
+ req->cqe.fd = READ_ONCE(sqe->hdr.fd);
/*
* Plug now if we have more than 2 IO left after this, and the
@@ -1902,7 +1903,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
}
}
- personality = READ_ONCE(sqe->personality);
+ personality = READ_ONCE(sqe->common.personality);
if (personality) {
int ret;
@@ -3909,11 +3910,11 @@ static int __init io_uring_init(void)
__BUILD_BUG_VERIFY_ALIAS(struct io_uring_sqe, eoffset, sizeof(etype), ename, aname)
#define BUILD_BUG_SQE_LEGACY(eoffset, etype, lname) \
- __BUILD_BUG_VERIFY_OFFSET_SIZE(struct io_uring_sqe, eoffset, sizeof(etype), lname)
+ __BUILD_BUG_VERIFY_OFFSET_SIZE(struct io_uring_sqe, eoffset, sizeof(etype), legacy.lname)
#define BUILD_BUG_SQE_LEGACY_SIZE(eoffset, esize, lname) \
- __BUILD_BUG_VERIFY_OFFSET_SIZE(struct io_uring_sqe, eoffset, esize, lname)
+ __BUILD_BUG_VERIFY_OFFSET_SIZE(struct io_uring_sqe, eoffset, esize, legacy.lname)
#define BUILD_BUG_SQE_LEGACY_ALIAS(eoffset, etype, ename, lname) \
- __BUILD_BUG_VERIFY_ALIAS(struct io_uring_sqe, eoffset, sizeof(etype), ename, lname)
+ __BUILD_BUG_VERIFY_ALIAS(struct io_uring_sqe, eoffset, sizeof(etype), ename, legacy.lname)
BUILD_BUG_ON(sizeof(struct io_uring_sqe_hdr) != 8);
BUILD_BUG_SQE_HDR_ELEM(0, __u8, opcode);
--
2.34.1
next prev parent reply other threads:[~2022-08-12 8:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 8:34 [RFC PATCH 0/8] cleanup struct io_uring_sqe layout Stefan Metzmacher
2022-08-12 8:34 ` [RFC PATCH 1/8] io_uring: move the current struct io_uring_sqe members to legacy sub struct Stefan Metzmacher
2022-08-12 8:34 ` [RFC PATCH 2/8] io_uring: add a generic structure for struct io_uring_sqe Stefan Metzmacher
2022-08-12 8:34 ` [RFC PATCH 3/8] io_uring: check legacy layout of struct io_uring_sqe with BUILD_BUG_SQE_LEGACY* Stefan Metzmacher
2022-08-12 8:34 ` [RFC PATCH 4/8] io_uring: only make use generic struct io_uring_sqe elements for tracing Stefan Metzmacher
2022-08-12 8:34 ` Stefan Metzmacher [this message]
2022-08-12 8:34 ` [RFC PATCH 6/8] io_uring: add BUILD_BUG_SQE_HDR_COMMON() macro Stefan Metzmacher
2022-08-12 8:34 ` [RFC PATCH 7/8] io_uring: introduce struct io_uring_sqe_rw for all io_prep_rw() using opcodes Stefan Metzmacher
2022-08-12 8:34 ` [RFC PATCH 8/8] io_uring: introduce struct io_uring_sqe_{fsync,sfr,fallocate} Stefan Metzmacher
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=cc6807c4bdd438218cc6e2240b970799dd15a834.1660291547.git.metze@samba.org \
[email protected] \
[email protected] \
[email protected] \
/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