1. 12 4月, 2021 10 次提交
  2. 09 4月, 2021 1 次提交
  3. 08 4月, 2021 1 次提交
  4. 03 4月, 2021 1 次提交
    • J
      io_uring: fix !CONFIG_BLOCK compilation failure · e82ad485
      Jens Axboe 提交于
      kernel test robot correctly pinpoints a compilation failure if
      CONFIG_BLOCK isn't set:
      
      fs/io_uring.c: In function '__io_complete_rw':
      >> fs/io_uring.c:2509:48: error: implicit declaration of function 'io_rw_should_reissue'; did you mean 'io_rw_reissue'? [-Werror=implicit-function-declaration]
          2509 |  if ((res == -EAGAIN || res == -EOPNOTSUPP) && io_rw_should_reissue(req)) {
               |                                                ^~~~~~~~~~~~~~~~~~~~
               |                                                io_rw_reissue
          cc1: some warnings being treated as errors
      
      Ensure that we have a stub declaration of io_rw_should_reissue() for
      !CONFIG_BLOCK.
      
      Fixes: 230d50d4 ("io_uring: move reissue into regular IO path")
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      e82ad485
  5. 02 4月, 2021 1 次提交
    • J
      io_uring: move reissue into regular IO path · 230d50d4
      Jens Axboe 提交于
      It's non-obvious how retry is done for block backed files, when it happens
      off the kiocb done path. It also makes it tricky to deal with the iov_iter
      handling.
      
      Just mark the req as needing a reissue, and handling it from the
      submission path instead. This makes it directly obvious that we're not
      re-importing the iovec from userspace past the submit point, and it means
      that we can just reuse our usual -EAGAIN retry path from the read/write
      handling.
      
      At some point in the future, we'll gain the ability to always reliably
      return -EAGAIN through the stack. A previous attempt on the block side
      didn't pan out and got reverted, hence the need to check for this
      information out-of-band right now.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      230d50d4
  6. 01 4月, 2021 3 次提交
  7. 31 3月, 2021 1 次提交
    • J
      io_uring: drop sqd lock before handling signals for SQPOLL · 82734c5b
      Jens Axboe 提交于
      Don't call into get_signal() with the sqd mutex held, it'll fail if we're
      freezing the task and we'll get complaints on locks still being held:
      
      ====================================
      WARNING: iou-sqp-8386/8387 still has locks held!
      5.12.0-rc4-syzkaller #0 Not tainted
      ------------------------------------
      1 lock held by iou-sqp-8386/8387:
       #0: ffff88801e1d2470 (&sqd->lock){+.+.}-{3:3}, at: io_sq_thread+0x24c/0x13a0 fs/io_uring.c:6731
      
       stack backtrace:
       CPU: 1 PID: 8387 Comm: iou-sqp-8386 Not tainted 5.12.0-rc4-syzkaller #0
       Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
       Call Trace:
        __dump_stack lib/dump_stack.c:79 [inline]
        dump_stack+0x141/0x1d7 lib/dump_stack.c:120
        try_to_freeze include/linux/freezer.h:66 [inline]
        get_signal+0x171a/0x2150 kernel/signal.c:2576
        io_sq_thread+0x8d2/0x13a0 fs/io_uring.c:6748
      
      Fold the get_signal() case in with the parking checks, as we need to drop
      the lock in both cases, and since we need to be checking for parking when
      juggling the lock anyway.
      
      Reported-by: syzbot+796d767eb376810256f5@syzkaller.appspotmail.com
      Fixes: dbe1bdbb ("io_uring: handle signals for IO threads like a normal thread")
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      82734c5b
  8. 29 3月, 2021 2 次提交
  9. 28 3月, 2021 6 次提交
  10. 26 3月, 2021 1 次提交
  11. 24 3月, 2021 1 次提交
    • P
      io_uring: do ctx sqd ejection in a clear context · a185f1db
      Pavel Begunkov 提交于
      WARNING: CPU: 1 PID: 27907 at fs/io_uring.c:7147 io_sq_thread_park+0xb5/0xd0 fs/io_uring.c:7147
      CPU: 1 PID: 27907 Comm: iou-sqp-27905 Not tainted 5.12.0-rc4-syzkaller #0
      RIP: 0010:io_sq_thread_park+0xb5/0xd0 fs/io_uring.c:7147
      Call Trace:
       io_ring_ctx_wait_and_kill+0x214/0x700 fs/io_uring.c:8619
       io_uring_release+0x3e/0x50 fs/io_uring.c:8646
       __fput+0x288/0x920 fs/file_table.c:280
       task_work_run+0xdd/0x1a0 kernel/task_work.c:140
       io_run_task_work fs/io_uring.c:2238 [inline]
       io_run_task_work fs/io_uring.c:2228 [inline]
       io_uring_try_cancel_requests+0x8ec/0xc60 fs/io_uring.c:8770
       io_uring_cancel_sqpoll+0x1cf/0x290 fs/io_uring.c:8974
       io_sqpoll_cancel_cb+0x87/0xb0 fs/io_uring.c:8907
       io_run_task_work_head+0x58/0xb0 fs/io_uring.c:1961
       io_sq_thread+0x3e2/0x18d0 fs/io_uring.c:6763
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
      
      May happen that last ctx ref is killed in io_uring_cancel_sqpoll(), so
      fput callback (i.e. io_uring_release()) is enqueued through task_work,
      and run by same cancellation. As it's deeply nested we can't do parking
      or taking sqd->lock there, because its state is unclear. So avoid
      ctx ejection from sqd list from io_ring_ctx_wait_and_kill() and do it
      in a clear context in io_ring_exit_work().
      
      Fixes: f6d54255 ("io_uring: halt SQO submission on ctx exit")
      Reported-by: syzbot+e3a3f84f5cecf61f0583@syzkaller.appspotmail.com
      Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
      Link: https://lore.kernel.org/r/e90df88b8ff2cabb14a7534601d35d62ab4cb8c7.1616496707.git.asml.silence@gmail.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      a185f1db
  12. 22 3月, 2021 4 次提交
  13. 21 3月, 2021 1 次提交
    • S
      io_uring: call req_set_fail_links() on short send[msg]()/recv[msg]() with MSG_WAITALL · 0031275d
      Stefan Metzmacher 提交于
      Without that it's not safe to use them in a linked combination with
      others.
      
      Now combinations like IORING_OP_SENDMSG followed by IORING_OP_SPLICE
      should be possible.
      
      We already handle short reads and writes for the following opcodes:
      
      - IORING_OP_READV
      - IORING_OP_READ_FIXED
      - IORING_OP_READ
      - IORING_OP_WRITEV
      - IORING_OP_WRITE_FIXED
      - IORING_OP_WRITE
      - IORING_OP_SPLICE
      - IORING_OP_TEE
      
      Now we have it for these as well:
      
      - IORING_OP_SENDMSG
      - IORING_OP_SEND
      - IORING_OP_RECVMSG
      - IORING_OP_RECV
      
      For IORING_OP_RECVMSG we also check for the MSG_TRUNC and MSG_CTRUNC
      flags in order to call req_set_fail_links().
      
      There might be applications arround depending on the behavior
      that even short send[msg]()/recv[msg]() retuns continue an
      IOSQE_IO_LINK chain.
      
      It's very unlikely that such applications pass in MSG_WAITALL,
      which is only defined in 'man 2 recvmsg', but not in 'man 2 sendmsg'.
      
      It's expected that the low level sock_sendmsg() call just ignores
      MSG_WAITALL, as MSG_ZEROCOPY is also ignored without explicitly set
      SO_ZEROCOPY.
      
      We also expect the caller to know about the implicit truncation to
      MAX_RW_COUNT, which we don't detect.
      
      cc: netdev@vger.kernel.org
      Link: https://lore.kernel.org/r/c4e1a4cc0d905314f4d5dc567e65a7b09621aab3.1615908477.git.metze@samba.orgSigned-off-by: NStefan Metzmacher <metze@samba.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      0031275d
  14. 18 3月, 2021 4 次提交
  15. 15 3月, 2021 3 次提交
    • P
      io_uring: fix sqpoll cancellation via task_work · b7f5a0bf
      Pavel Begunkov 提交于
      Running sqpoll cancellations via task_work_run() is a bad idea because
      it depends on other task works to be run, but those may be locked in
      currently running task_work_run() because of how it's (splicing the list
      in batches).
      
      Enqueue and run them through a separate callback head, namely
      struct io_sq_data::park_task_work. As a nice bonus we now precisely
      control where it's run, that's much safer than guessing where it can
      happen as it was before.
      Reported-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      b7f5a0bf
    • P
      io_uring: add generic callback_head helpers · 9b465711
      Pavel Begunkov 提交于
      We already have helpers to run/add callback_head but taking ctx and
      working with ctx->exit_task_work. Extract generic versions of them
      implemented in terms of struct callback_head, it will be used later.
      Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      9b465711
    • P
      io_uring: fix concurrent parking · 9e138a48
      Pavel Begunkov 提交于
      If io_sq_thread_park() of one task got rescheduled right after
      set_bit(), before it gets back to mutex_lock() there can happen
      park()/unpark() by another task with SQPOLL locking again and
      continuing running never seeing that first set_bit(SHOULD_PARK),
      so won't even try to put the mutex down for parking.
      
      It will get parked eventually when SQPOLL drops the lock for reschedule,
      but may be problematic and will get in the way of further fixes.
      
      Account number of tasks waiting for parking with a new atomic variable
      park_pending and adjust SHOULD_PARK accordingly. It doesn't entirely
      replaces SHOULD_PARK bit with this atomic var because it's convenient
      to have it as a bit in the state and will help to do optimisations
      later.
      Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      9e138a48