summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2024-11-15 03:49:02 +0000
committerJens Axboe <axboe@kernel.dk>2024-11-15 09:55:54 -0700
commit56cec28dc4da396d6032c59ae9614c5a6ae7d7a8 (patch)
treebdcb1c4e0c3f1fbc957291695eb4844ac1814fe8 /io_uring
parentb9d69371e8fa90fa3ab100f4fcb4815b13b3673a (diff)
switch io_msg_ring() to CLASS(fd)
Use CLASS(fd) to get the file for sync message ring requests, rather than open-code the file retrieval dance. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/r/20241115034902.GP3387508@ZenIV [axboe: make a more coherent commit message] Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/msg_ring.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
index e63af34004b7..333c220d322a 100644
--- a/io_uring/msg_ring.c
+++ b/io_uring/msg_ring.c
@@ -333,7 +333,6 @@ done:
int io_uring_sync_msg_ring(struct io_uring_sqe *sqe)
{
struct io_msg io_msg = { };
- struct fd f;
int ret;
ret = __io_msg_ring_prep(&io_msg, sqe);
@@ -347,16 +346,13 @@ int io_uring_sync_msg_ring(struct io_uring_sqe *sqe)
if (io_msg.cmd != IORING_MSG_DATA)
return -EINVAL;
- ret = -EBADF;
- f = fdget(sqe->fd);
- if (fd_file(f)) {
- ret = -EBADFD;
- if (io_is_uring_fops(fd_file(f)))
- ret = __io_msg_ring_data(fd_file(f)->private_data,
- &io_msg, IO_URING_F_UNLOCKED);
- fdput(f);
- }
- return ret;
+ CLASS(fd, f)(sqe->fd);
+ if (fd_empty(f))
+ return -EBADF;
+ if (!io_is_uring_fops(fd_file(f)))
+ return -EBADFD;
+ return __io_msg_ring_data(fd_file(f)->private_data,
+ &io_msg, IO_URING_F_UNLOCKED);
}
void io_msg_cache_free(const void *entry)