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: convert file system request types to use io_cmd_type

This converts statx, rename, unlink, mkdir, symlink, and hardlink to
use io_cmd_type.

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

+57 -45
+57 -45
io_uring/io_uring.c
··· 983 983 struct io_epoll epoll; 984 984 struct io_splice splice; 985 985 struct io_provide_buf pbuf; 986 - struct io_statx statx; 987 - struct io_rename rename; 988 - struct io_unlink unlink; 989 - struct io_mkdir mkdir; 990 - struct io_symlink symlink; 991 - struct io_hardlink hardlink; 992 986 struct io_msg msg; 993 987 struct io_xattr xattr; 994 988 struct io_uring_cmd uring_cmd; ··· 4361 4367 static int io_renameat_prep(struct io_kiocb *req, 4362 4368 const struct io_uring_sqe *sqe) 4363 4369 { 4364 - struct io_rename *ren = &req->rename; 4370 + struct io_rename *ren = io_kiocb_to_cmd(req); 4365 4371 const char __user *oldf, *newf; 4366 4372 4367 4373 if (sqe->buf_index || sqe->splice_fd_in) ··· 4391 4397 4392 4398 static int io_renameat(struct io_kiocb *req, unsigned int issue_flags) 4393 4399 { 4394 - struct io_rename *ren = &req->rename; 4400 + struct io_rename *ren = io_kiocb_to_cmd(req); 4395 4401 int ret; 4396 4402 4397 4403 if (issue_flags & IO_URING_F_NONBLOCK) ··· 4648 4654 static int io_unlinkat_prep(struct io_kiocb *req, 4649 4655 const struct io_uring_sqe *sqe) 4650 4656 { 4651 - struct io_unlink *un = &req->unlink; 4657 + struct io_unlink *un = io_kiocb_to_cmd(req); 4652 4658 const char __user *fname; 4653 4659 4654 4660 if (sqe->off || sqe->len || sqe->buf_index || sqe->splice_fd_in) ··· 4673 4679 4674 4680 static int io_unlinkat(struct io_kiocb *req, unsigned int issue_flags) 4675 4681 { 4676 - struct io_unlink *un = &req->unlink; 4682 + struct io_unlink *un = io_kiocb_to_cmd(req); 4677 4683 int ret; 4678 4684 4679 4685 if (issue_flags & IO_URING_F_NONBLOCK) ··· 4692 4698 static int io_mkdirat_prep(struct io_kiocb *req, 4693 4699 const struct io_uring_sqe *sqe) 4694 4700 { 4695 - struct io_mkdir *mkd = &req->mkdir; 4701 + struct io_mkdir *mkd = io_kiocb_to_cmd(req); 4696 4702 const char __user *fname; 4697 4703 4698 4704 if (sqe->off || sqe->rw_flags || sqe->buf_index || sqe->splice_fd_in) ··· 4714 4720 4715 4721 static int io_mkdirat(struct io_kiocb *req, unsigned int issue_flags) 4716 4722 { 4717 - struct io_mkdir *mkd = &req->mkdir; 4723 + struct io_mkdir *mkd = io_kiocb_to_cmd(req); 4718 4724 int ret; 4719 4725 4720 4726 if (issue_flags & IO_URING_F_NONBLOCK) ··· 4730 4736 static int io_symlinkat_prep(struct io_kiocb *req, 4731 4737 const struct io_uring_sqe *sqe) 4732 4738 { 4733 - struct io_symlink *sl = &req->symlink; 4739 + struct io_symlink *sl = io_kiocb_to_cmd(req); 4734 4740 const char __user *oldpath, *newpath; 4735 4741 4736 4742 if (sqe->len || sqe->rw_flags || sqe->buf_index || sqe->splice_fd_in) ··· 4758 4764 4759 4765 static int io_symlinkat(struct io_kiocb *req, unsigned int issue_flags) 4760 4766 { 4761 - struct io_symlink *sl = &req->symlink; 4767 + struct io_symlink *sl = io_kiocb_to_cmd(req); 4762 4768 int ret; 4763 4769 4764 4770 if (issue_flags & IO_URING_F_NONBLOCK) ··· 4774 4780 static int io_linkat_prep(struct io_kiocb *req, 4775 4781 const struct io_uring_sqe *sqe) 4776 4782 { 4777 - struct io_hardlink *lnk = &req->hardlink; 4783 + struct io_hardlink *lnk = io_kiocb_to_cmd(req); 4778 4784 const char __user *oldf, *newf; 4779 4785 4780 4786 if (sqe->rw_flags || sqe->buf_index || sqe->splice_fd_in) ··· 4804 4810 4805 4811 static int io_linkat(struct io_kiocb *req, unsigned int issue_flags) 4806 4812 { 4807 - struct io_hardlink *lnk = &req->hardlink; 4813 + struct io_hardlink *lnk = io_kiocb_to_cmd(req); 4808 4814 int ret; 4809 4815 4810 4816 if (issue_flags & IO_URING_F_NONBLOCK) ··· 5690 5696 5691 5697 static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 5692 5698 { 5699 + struct io_statx *sx = io_kiocb_to_cmd(req); 5693 5700 const char __user *path; 5694 5701 5695 5702 if (sqe->buf_index || sqe->splice_fd_in) ··· 5698 5703 if (req->flags & REQ_F_FIXED_FILE) 5699 5704 return -EBADF; 5700 5705 5701 - req->statx.dfd = READ_ONCE(sqe->fd); 5702 - req->statx.mask = READ_ONCE(sqe->len); 5706 + sx->dfd = READ_ONCE(sqe->fd); 5707 + sx->mask = READ_ONCE(sqe->len); 5703 5708 path = u64_to_user_ptr(READ_ONCE(sqe->addr)); 5704 - req->statx.buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2)); 5705 - req->statx.flags = READ_ONCE(sqe->statx_flags); 5709 + sx->buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2)); 5710 + sx->flags = READ_ONCE(sqe->statx_flags); 5706 5711 5707 - req->statx.filename = getname_flags(path, 5708 - getname_statx_lookup_flags(req->statx.flags), 5709 - NULL); 5712 + sx->filename = getname_flags(path, 5713 + getname_statx_lookup_flags(sx->flags), 5714 + NULL); 5710 5715 5711 - if (IS_ERR(req->statx.filename)) { 5712 - int ret = PTR_ERR(req->statx.filename); 5716 + if (IS_ERR(sx->filename)) { 5717 + int ret = PTR_ERR(sx->filename); 5713 5718 5714 - req->statx.filename = NULL; 5719 + sx->filename = NULL; 5715 5720 return ret; 5716 5721 } 5717 5722 ··· 5721 5726 5722 5727 static int io_statx(struct io_kiocb *req, unsigned int issue_flags) 5723 5728 { 5724 - struct io_statx *ctx = &req->statx; 5729 + struct io_statx *sx = io_kiocb_to_cmd(req); 5725 5730 int ret; 5726 5731 5727 5732 if (issue_flags & IO_URING_F_NONBLOCK) 5728 5733 return -EAGAIN; 5729 5734 5730 - ret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask, 5731 - ctx->buffer); 5735 + ret = do_statx(sx->dfd, sx->filename, sx->flags, sx->mask, sx->buffer); 5732 5736 io_req_complete(req, ret); 5733 5737 return 0; 5734 5738 } ··· 7988 7994 putname(open->filename); 7989 7995 break; 7990 7996 } 7991 - case IORING_OP_RENAMEAT: 7992 - putname(req->rename.oldpath); 7993 - putname(req->rename.newpath); 7997 + case IORING_OP_RENAMEAT: { 7998 + struct io_rename *ren = io_kiocb_to_cmd(req); 7999 + 8000 + putname(ren->oldpath); 8001 + putname(ren->newpath); 7994 8002 break; 7995 - case IORING_OP_UNLINKAT: 7996 - putname(req->unlink.filename); 8003 + } 8004 + case IORING_OP_UNLINKAT: { 8005 + struct io_unlink *ul = io_kiocb_to_cmd(req); 8006 + 8007 + putname(ul->filename); 7997 8008 break; 7998 - case IORING_OP_MKDIRAT: 7999 - putname(req->mkdir.filename); 8009 + } 8010 + case IORING_OP_MKDIRAT: { 8011 + struct io_mkdir *md = io_kiocb_to_cmd(req); 8012 + 8013 + putname(md->filename); 8000 8014 break; 8001 - case IORING_OP_SYMLINKAT: 8002 - putname(req->symlink.oldpath); 8003 - putname(req->symlink.newpath); 8015 + } 8016 + case IORING_OP_SYMLINKAT: { 8017 + struct io_symlink *sl = io_kiocb_to_cmd(req); 8018 + 8019 + putname(sl->oldpath); 8020 + putname(sl->newpath); 8004 8021 break; 8005 - case IORING_OP_LINKAT: 8006 - putname(req->hardlink.oldpath); 8007 - putname(req->hardlink.newpath); 8022 + } 8023 + case IORING_OP_LINKAT: { 8024 + struct io_hardlink *hl = io_kiocb_to_cmd(req); 8025 + 8026 + putname(hl->oldpath); 8027 + putname(hl->newpath); 8008 8028 break; 8009 - case IORING_OP_STATX: 8010 - if (req->statx.filename) 8011 - putname(req->statx.filename); 8029 + } 8030 + case IORING_OP_STATX: { 8031 + struct io_statx *sx = io_kiocb_to_cmd(req); 8032 + 8033 + if (sx->filename) 8034 + putname(sx->filename); 8012 8035 break; 8036 + } 8013 8037 case IORING_OP_SETXATTR: 8014 8038 case IORING_OP_FSETXATTR: 8015 8039 case IORING_OP_GETXATTR: