Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: move statx handling to its own file

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+82 -62
+2 -1
io_uring/Makefile
··· 4 4 5 5 obj-$(CONFIG_IO_URING) += io_uring.o xattr.o nop.o fs.o splice.o \ 6 6 sync.o advise.o filetable.o \ 7 - openclose.o uring_cmd.o epoll.o 7 + openclose.o uring_cmd.o epoll.o \ 8 + statx.o 8 9 obj-$(CONFIG_IO_WQ) += io-wq.o
+1 -61
io_uring/io_uring.c
··· 101 101 #include "openclose.h" 102 102 #include "uring_cmd.h" 103 103 #include "epoll.h" 104 + #include "statx.h" 104 105 105 106 #define IORING_MAX_ENTRIES 32768 106 107 #define IORING_MAX_CQ_ENTRIES (2 * IORING_MAX_ENTRIES) ··· 383 382 __u32 bgid; 384 383 __u16 nbufs; 385 384 __u16 bid; 386 - }; 387 - 388 - struct io_statx { 389 - struct file *file; 390 - int dfd; 391 - unsigned int mask; 392 - unsigned int flags; 393 - struct filename *filename; 394 - struct statx __user *buffer; 395 385 }; 396 386 397 387 struct io_shutdown { ··· 4023 4031 const struct io_uring_sqe *sqe) 4024 4032 { 4025 4033 return -EOPNOTSUPP; 4026 - } 4027 - 4028 - static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 4029 - { 4030 - struct io_statx *sx = io_kiocb_to_cmd(req); 4031 - const char __user *path; 4032 - 4033 - if (sqe->buf_index || sqe->splice_fd_in) 4034 - return -EINVAL; 4035 - if (req->flags & REQ_F_FIXED_FILE) 4036 - return -EBADF; 4037 - 4038 - sx->dfd = READ_ONCE(sqe->fd); 4039 - sx->mask = READ_ONCE(sqe->len); 4040 - path = u64_to_user_ptr(READ_ONCE(sqe->addr)); 4041 - sx->buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2)); 4042 - sx->flags = READ_ONCE(sqe->statx_flags); 4043 - 4044 - sx->filename = getname_flags(path, 4045 - getname_statx_lookup_flags(sx->flags), 4046 - NULL); 4047 - 4048 - if (IS_ERR(sx->filename)) { 4049 - int ret = PTR_ERR(sx->filename); 4050 - 4051 - sx->filename = NULL; 4052 - return ret; 4053 - } 4054 - 4055 - req->flags |= REQ_F_NEED_CLEANUP; 4056 - return 0; 4057 - } 4058 - 4059 - static int io_statx(struct io_kiocb *req, unsigned int issue_flags) 4060 - { 4061 - struct io_statx *sx = io_kiocb_to_cmd(req); 4062 - int ret; 4063 - 4064 - if (issue_flags & IO_URING_F_NONBLOCK) 4065 - return -EAGAIN; 4066 - 4067 - ret = do_statx(sx->dfd, sx->filename, sx->flags, sx->mask, sx->buffer); 4068 - io_req_set_res(req, ret, 0); 4069 - return IOU_OK; 4070 - } 4071 - 4072 - static void io_statx_cleanup(struct io_kiocb *req) 4073 - { 4074 - struct io_statx *sx = io_kiocb_to_cmd(req); 4075 - 4076 - if (sx->filename) 4077 - putname(sx->filename); 4078 4034 } 4079 4035 4080 4036 #if defined(CONFIG_NET)
+74
io_uring/statx.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <linux/kernel.h> 3 + #include <linux/errno.h> 4 + #include <linux/file.h> 5 + #include <linux/io_uring.h> 6 + 7 + #include <uapi/linux/io_uring.h> 8 + 9 + #include "../fs/internal.h" 10 + 11 + #include "io_uring_types.h" 12 + #include "io_uring.h" 13 + #include "statx.h" 14 + 15 + struct io_statx { 16 + struct file *file; 17 + int dfd; 18 + unsigned int mask; 19 + unsigned int flags; 20 + struct filename *filename; 21 + struct statx __user *buffer; 22 + }; 23 + 24 + int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 25 + { 26 + struct io_statx *sx = io_kiocb_to_cmd(req); 27 + const char __user *path; 28 + 29 + if (sqe->buf_index || sqe->splice_fd_in) 30 + return -EINVAL; 31 + if (req->flags & REQ_F_FIXED_FILE) 32 + return -EBADF; 33 + 34 + sx->dfd = READ_ONCE(sqe->fd); 35 + sx->mask = READ_ONCE(sqe->len); 36 + path = u64_to_user_ptr(READ_ONCE(sqe->addr)); 37 + sx->buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2)); 38 + sx->flags = READ_ONCE(sqe->statx_flags); 39 + 40 + sx->filename = getname_flags(path, 41 + getname_statx_lookup_flags(sx->flags), 42 + NULL); 43 + 44 + if (IS_ERR(sx->filename)) { 45 + int ret = PTR_ERR(sx->filename); 46 + 47 + sx->filename = NULL; 48 + return ret; 49 + } 50 + 51 + req->flags |= REQ_F_NEED_CLEANUP; 52 + return 0; 53 + } 54 + 55 + int io_statx(struct io_kiocb *req, unsigned int issue_flags) 56 + { 57 + struct io_statx *sx = io_kiocb_to_cmd(req); 58 + int ret; 59 + 60 + if (issue_flags & IO_URING_F_NONBLOCK) 61 + return -EAGAIN; 62 + 63 + ret = do_statx(sx->dfd, sx->filename, sx->flags, sx->mask, sx->buffer); 64 + io_req_set_res(req, ret, 0); 65 + return IOU_OK; 66 + } 67 + 68 + void io_statx_cleanup(struct io_kiocb *req) 69 + { 70 + struct io_statx *sx = io_kiocb_to_cmd(req); 71 + 72 + if (sx->filename) 73 + putname(sx->filename); 74 + }
+5
io_uring/statx.h
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); 4 + int io_statx(struct io_kiocb *req, unsigned int issue_flags); 5 + void io_statx_cleanup(struct io_kiocb *req);