1. 11 6月, 2020 3 次提交
  2. 10 6月, 2020 1 次提交
    • J
      io_uring: allow O_NONBLOCK async retry · c5b85625
      Jens Axboe 提交于
      We can assume that O_NONBLOCK is always honored, even if we don't
      have a ->read/write_iter() for the file type. Also unify the read/write
      checking for allowing async punt, having the write side factoring in the
      REQ_F_NOWAIT flag as well.
      
      Cc: stable@vger.kernel.org
      Fixes: 490e8967 ("io_uring: only force async punt if poll based retry can't handle it")
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      c5b85625
  3. 09 6月, 2020 4 次提交
  4. 08 6月, 2020 2 次提交
  5. 05 6月, 2020 5 次提交
  6. 03 6月, 2020 1 次提交
    • J
      io_uring: disallow close of ring itself · fd2206e4
      Jens Axboe 提交于
      A previous commit enabled this functionality, which also enabled O_PATH
      to work correctly with io_uring. But we can't safely close the ring
      itself, as the file handle isn't reference counted inside
      io_uring_enter(). Instead of jumping through hoops to enable ring
      closure, add a "soft" ->needs_file option, ->needs_file_no_error. This
      enables O_PATH file descriptors to work, but still catches the case of
      trying to close the ring itself.
      Reported-by: NJann Horn <jannh@google.com>
      Fixes: 904fbcb1 ("io_uring: remove 'fd is io_uring' from close path")
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      fd2206e4
  7. 30 5月, 2020 3 次提交
  8. 27 5月, 2020 7 次提交
  9. 20 5月, 2020 4 次提交
    • X
      io_uring: don't submit sqes when ctx->refs is dying · 6b668c9b
      Xiaoguang Wang 提交于
      When IORING_SETUP_SQPOLL is enabled, io_ring_ctx_wait_and_kill() will wait
      for sq thread to idle by busy loop:
      
          while (ctx->sqo_thread && !wq_has_sleeper(&ctx->sqo_wait))
              cond_resched();
      
      Above loop isn't very CPU friendly, it may introduce a short cpu burst on
      the current cpu.
      
      If ctx->refs is dying, we forbid sq_thread from submitting any further
      SQEs. Instead they just get discarded when we exit.
      Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      6b668c9b
    • X
      io_uring: reset -EBUSY error when io sq thread is waken up · d4ae271d
      Xiaoguang Wang 提交于
      In io_sq_thread(), currently if we get an -EBUSY error and go to sleep,
      we will won't clear it again, which will result in io_sq_thread() will
      never have a chance to submit sqes again. Below test program test.c
      can reveal this bug:
      
      int main(int argc, char *argv[])
      {
              struct io_uring ring;
              int i, fd, ret;
              struct io_uring_sqe *sqe;
              struct io_uring_cqe *cqe;
              struct iovec *iovecs;
              void *buf;
              struct io_uring_params p;
      
              if (argc < 2) {
                      printf("%s: file\n", argv[0]);
                      return 1;
              }
      
              memset(&p, 0, sizeof(p));
              p.flags = IORING_SETUP_SQPOLL;
              ret = io_uring_queue_init_params(4, &ring, &p);
              if (ret < 0) {
                      fprintf(stderr, "queue_init: %s\n", strerror(-ret));
                      return 1;
              }
      
              fd = open(argv[1], O_RDONLY | O_DIRECT);
              if (fd < 0) {
                      perror("open");
                      return 1;
              }
      
              iovecs = calloc(10, sizeof(struct iovec));
              for (i = 0; i < 10; i++) {
                      if (posix_memalign(&buf, 4096, 4096))
                              return 1;
                      iovecs[i].iov_base = buf;
                      iovecs[i].iov_len = 4096;
              }
      
              ret = io_uring_register_files(&ring, &fd, 1);
              if (ret < 0) {
                      fprintf(stderr, "%s: register %d\n", __FUNCTION__, ret);
                      return ret;
              }
      
              for (i = 0; i < 10; i++) {
                      sqe = io_uring_get_sqe(&ring);
                      if (!sqe)
                              break;
      
                      io_uring_prep_readv(sqe, 0, &iovecs[i], 1, 0);
                      sqe->flags |= IOSQE_FIXED_FILE;
      
                      ret = io_uring_submit(&ring);
                      sleep(1);
                      printf("submit %d\n", i);
              }
      
              for (i = 0; i < 10; i++) {
                      io_uring_wait_cqe(&ring, &cqe);
                      printf("receive: %d\n", i);
                      if (cqe->res != 4096) {
                              fprintf(stderr, "ret=%d, wanted 4096\n", cqe->res);
                              ret = 1;
                      }
                      io_uring_cqe_seen(&ring, cqe);
              }
      
              close(fd);
              io_uring_queue_exit(&ring);
              return 0;
      }
      sudo ./test testfile
      above command will hang on the tenth request, to fix this bug, when io
      sq_thread is waken up, we reset the variable 'ret' to be zero.
      Suggested-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      d4ae271d
    • J
      io_uring: don't add non-IO requests to iopoll pending list · b532576e
      Jens Axboe 提交于
      We normally disable any commands that aren't specifically poll commands
      for a ring that is setup for polling, but we do allow buffer provide and
      remove commands to support buffer selection for polled IO. Once a
      request is issued, we add it to the poll list to poll for completion. But
      we should not do that for non-IO commands, as those request complete
      inline immediately and aren't pollable. If we do, we can leave requests
      on the iopoll list after they are freed.
      
      Fixes: ddf0322d ("io_uring: add IORING_OP_PROVIDE_BUFFERS")
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      b532576e
    • B
      io_uring: don't use kiocb.private to store buf_index · 4f4eeba8
      Bijan Mottahedeh 提交于
      kiocb.private is used in iomap_dio_rw() so store buf_index separately.
      Signed-off-by: NBijan Mottahedeh <bijan.mottahedeh@oracle.com>
      
      Move 'buf_index' to a hole in io_kiocb.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      4f4eeba8
  10. 19 5月, 2020 1 次提交
    • J
      io_uring: cancel work if task_work_add() fails · e3aabf95
      Jens Axboe 提交于
      We currently move it to the io_wqe_manager for execution, but we cannot
      safely do so as we may lack some of the state to execute it out of
      context. As we cancel work anyway when the ring/task exits, just mark
      this request as canceled and io_async_task_func() will do the right
      thing.
      
      Fixes: aa96bf8a ("io_uring: use io-wq manager as backup task if task is exiting")
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      e3aabf95
  11. 18 5月, 2020 7 次提交
  12. 17 5月, 2020 2 次提交