Merge tag 'for-5.11/io_uring-2020-12-14' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 20:44:05 +0000 (12:44 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 20:44:05 +0000 (12:44 -0800)
Pull io_uring updates from Jens Axboe:
 "Fairly light set of changes this time around, and mostly some bits
  that were pushed out to 5.11 instead of 5.10, fixes/cleanups, and a
  few features. In particular:

   - Cleanups around iovec import (David Laight, Pavel)

   - Add timeout support for io_uring_enter(2), which enables us to
     clean up liburing and avoid a timeout sqe submission in the
     completion path.

     The big win here is that it allows setups that split SQ and CQ
     handling into separate threads to avoid locking, as the CQ side
     will no longer submit when timeouts are needed when waiting for
     events (Hao Xu)

   - Add support for socket shutdown, and renameat/unlinkat.

   - SQPOLL cleanups and improvements (Xiaoguang Wang)

   - Allow SQPOLL setups for CAP_SYS_NICE, and enable regular
     (non-fixed) files to be used.

   - Cancelation improvements (Pavel)

   - Fixed file reference improvements (Pavel)

   - IOPOLL related race fixes (Pavel)

   - Lots of other little fixes and cleanups (mostly Pavel)"

* tag 'for-5.11/io_uring-2020-12-14' of git://git.kernel.dk/linux-block: (43 commits)
  io_uring: fix io_cqring_events()'s noflush
  io_uring: fix racy IOPOLL flush overflow
  io_uring: fix racy IOPOLL completions
  io_uring: always let io_iopoll_complete() complete polled io
  io_uring: add timeout update
  io_uring: restructure io_timeout_cancel()
  io_uring: fix files cancellation
  io_uring: use bottom half safe lock for fixed file data
  io_uring: fix miscounting ios_left
  io_uring: change submit file state invariant
  io_uring: check kthread stopped flag when sq thread is unparked
  io_uring: share fixed_file_refs b/w multiple rsrcs
  io_uring: replace inflight_wait with tctx->wait
  io_uring: don't take fs for recvmsg/sendmsg
  io_uring: only wake up sq thread while current task is in io worker context
  io_uring: don't acquire uring_lock twice
  io_uring: initialize 'timeout' properly in io_sq_thread()
  io_uring: refactor io_sq_thread() handling
  io_uring: always batch cancel in *cancel_files()
  io_uring: pass files into kill timeouts/poll
  ...

1  2 
fs/io_uring.c
include/linux/syscalls.h
net/socket.c

diff --cc fs/io_uring.c
@@@ -3590,6 -3665,135 +3664,135 @@@ out_free
        return ret;
  }
  
 -      sock = sock_from_file(req->file, &ret);
+ static int io_renameat_prep(struct io_kiocb *req,
+                           const struct io_uring_sqe *sqe)
+ {
+       struct io_rename *ren = &req->rename;
+       const char __user *oldf, *newf;
+       if (unlikely(req->flags & REQ_F_FIXED_FILE))
+               return -EBADF;
+       ren->old_dfd = READ_ONCE(sqe->fd);
+       oldf = u64_to_user_ptr(READ_ONCE(sqe->addr));
+       newf = u64_to_user_ptr(READ_ONCE(sqe->addr2));
+       ren->new_dfd = READ_ONCE(sqe->len);
+       ren->flags = READ_ONCE(sqe->rename_flags);
+       ren->oldpath = getname(oldf);
+       if (IS_ERR(ren->oldpath))
+               return PTR_ERR(ren->oldpath);
+       ren->newpath = getname(newf);
+       if (IS_ERR(ren->newpath)) {
+               putname(ren->oldpath);
+               return PTR_ERR(ren->newpath);
+       }
+       req->flags |= REQ_F_NEED_CLEANUP;
+       return 0;
+ }
+ static int io_renameat(struct io_kiocb *req, bool force_nonblock)
+ {
+       struct io_rename *ren = &req->rename;
+       int ret;
+       if (force_nonblock)
+               return -EAGAIN;
+       ret = do_renameat2(ren->old_dfd, ren->oldpath, ren->new_dfd,
+                               ren->newpath, ren->flags);
+       req->flags &= ~REQ_F_NEED_CLEANUP;
+       if (ret < 0)
+               req_set_fail_links(req);
+       io_req_complete(req, ret);
+       return 0;
+ }
+ static int io_unlinkat_prep(struct io_kiocb *req,
+                           const struct io_uring_sqe *sqe)
+ {
+       struct io_unlink *un = &req->unlink;
+       const char __user *fname;
+       if (unlikely(req->flags & REQ_F_FIXED_FILE))
+               return -EBADF;
+       un->dfd = READ_ONCE(sqe->fd);
+       un->flags = READ_ONCE(sqe->unlink_flags);
+       if (un->flags & ~AT_REMOVEDIR)
+               return -EINVAL;
+       fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
+       un->filename = getname(fname);
+       if (IS_ERR(un->filename))
+               return PTR_ERR(un->filename);
+       req->flags |= REQ_F_NEED_CLEANUP;
+       return 0;
+ }
+ static int io_unlinkat(struct io_kiocb *req, bool force_nonblock)
+ {
+       struct io_unlink *un = &req->unlink;
+       int ret;
+       if (force_nonblock)
+               return -EAGAIN;
+       if (un->flags & AT_REMOVEDIR)
+               ret = do_rmdir(un->dfd, un->filename);
+       else
+               ret = do_unlinkat(un->dfd, un->filename);
+       req->flags &= ~REQ_F_NEED_CLEANUP;
+       if (ret < 0)
+               req_set_fail_links(req);
+       io_req_complete(req, ret);
+       return 0;
+ }
+ static int io_shutdown_prep(struct io_kiocb *req,
+                           const struct io_uring_sqe *sqe)
+ {
+ #if defined(CONFIG_NET)
+       if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
+               return -EINVAL;
+       if (sqe->ioprio || sqe->off || sqe->addr || sqe->rw_flags ||
+           sqe->buf_index)
+               return -EINVAL;
+       req->shutdown.how = READ_ONCE(sqe->len);
+       return 0;
+ #else
+       return -EOPNOTSUPP;
+ #endif
+ }
+ static int io_shutdown(struct io_kiocb *req, bool force_nonblock)
+ {
+ #if defined(CONFIG_NET)
+       struct socket *sock;
+       int ret;
+       if (force_nonblock)
+               return -EAGAIN;
 -              return ret;
++      sock = sock_from_file(req->file);
+       if (unlikely(!sock))
++              return -ENOTSOCK;
+       ret = __sys_shutdown_sock(sock, req->shutdown.how);
+       io_req_complete(req, ret);
+       return 0;
+ #else
+       return -EOPNOTSUPP;
+ #endif
+ }
  static int __io_splice_prep(struct io_kiocb *req,
                            const struct io_uring_sqe *sqe)
  {
Simple merge
diff --cc net/socket.c
Simple merge