1. 16 5月, 2022 2 次提交
  2. 15 4月, 2022 2 次提交
  3. 23 3月, 2022 2 次提交
  4. 16 3月, 2022 1 次提交
  5. 04 3月, 2022 1 次提交
  6. 27 1月, 2022 1 次提交
  7. 06 1月, 2022 1 次提交
  8. 17 12月, 2021 3 次提交
  9. 29 11月, 2021 1 次提交
  10. 21 10月, 2021 1 次提交
  11. 20 10月, 2021 1 次提交
  12. 19 10月, 2021 3 次提交
    • J
      nvme: wire up completion batching for the IRQ path · 4f502245
      Jens Axboe 提交于
      Trivial to do now, just need our own io_comp_batch on the stack and pass
      that in to the usual command completion handling.
      
      I pondered making this dependent on how many entries we had to process,
      but even for a single entry there's no discernable difference in
      performance or latency. Running a sync workload over io_uring:
      
      t/io_uring -b512 -d1 -s1 -c1 -p0 -F1 -B1 -n2 /dev/nvme1n1 /dev/nvme2n1
      
      yields the below performance before the patch:
      
      IOPS=254820, BW=124MiB/s, IOS/call=1/1, inflight=(1 1)
      IOPS=251174, BW=122MiB/s, IOS/call=1/1, inflight=(1 1)
      IOPS=250806, BW=122MiB/s, IOS/call=1/1, inflight=(1 1)
      
      and the following after:
      
      IOPS=255972, BW=124MiB/s, IOS/call=1/1, inflight=(1 1)
      IOPS=251920, BW=123MiB/s, IOS/call=1/1, inflight=(1 1)
      IOPS=251794, BW=122MiB/s, IOS/call=1/1, inflight=(1 1)
      
      which definitely isn't slower, about the same if you factor in a bit of
      variance. For peak performance workloads, benchmarking shows a 2%
      improvement.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      4f502245
    • J
      nvme: add support for batched completion of polled IO · c234a653
      Jens Axboe 提交于
      Take advantage of struct io_comp_batch, if passed in to the nvme poll
      handler. If it's set, rather than complete each request individually
      inline, store them in the io_comp_batch list. We only do so for requests
      that will complete successfully, anything else will be completed inline as
      before.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      c234a653
    • J
      block: add a struct io_comp_batch argument to fops->iopoll() · 5a72e899
      Jens Axboe 提交于
      struct io_comp_batch contains a list head and a completion handler, which
      will allow completions to more effciently completed batches of IO.
      
      For now, no functional changes in this patch, we just define the
      io_comp_batch structure and add the argument to the file_operations iopoll
      handler.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      5a72e899
  13. 18 10月, 2021 1 次提交
  14. 07 10月, 2021 1 次提交
  15. 28 9月, 2021 1 次提交
  16. 16 8月, 2021 6 次提交
  17. 15 8月, 2021 1 次提交
  18. 21 7月, 2021 1 次提交
    • Z
      nvme-pci: don't WARN_ON in nvme_reset_work if ctrl.state is not RESETTING · 7764656b
      Zhihao Cheng 提交于
      Followling process:
      nvme_probe
        nvme_reset_ctrl
          nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)
          queue_work(nvme_reset_wq, &ctrl->reset_work)
      
      -------------->	nvme_remove
      		  nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING)
      worker_thread
        process_one_work
          nvme_reset_work
          WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING)
      
      , which will trigger WARN_ON in nvme_reset_work():
      [  127.534298] WARNING: CPU: 0 PID: 139 at drivers/nvme/host/pci.c:2594
      [  127.536161] CPU: 0 PID: 139 Comm: kworker/u8:7 Not tainted 5.13.0
      [  127.552518] Call Trace:
      [  127.552840]  ? kvm_sched_clock_read+0x25/0x40
      [  127.553936]  ? native_send_call_func_single_ipi+0x1c/0x30
      [  127.555117]  ? send_call_function_single_ipi+0x9b/0x130
      [  127.556263]  ? __smp_call_single_queue+0x48/0x60
      [  127.557278]  ? ttwu_queue_wakelist+0xfa/0x1c0
      [  127.558231]  ? try_to_wake_up+0x265/0x9d0
      [  127.559120]  ? ext4_end_io_rsv_work+0x160/0x290
      [  127.560118]  process_one_work+0x28c/0x640
      [  127.561002]  worker_thread+0x39a/0x700
      [  127.561833]  ? rescuer_thread+0x580/0x580
      [  127.562714]  kthread+0x18c/0x1e0
      [  127.563444]  ? set_kthread_struct+0x70/0x70
      [  127.564347]  ret_from_fork+0x1f/0x30
      
      The preceding problem can be easily reproduced by executing following
      script (based on blktests suite):
      test() {
        pdev="$(_get_pci_dev_from_blkdev)"
        sysfs="/sys/bus/pci/devices/${pdev}"
        for ((i = 0; i < 10; i++)); do
          echo 1 > "$sysfs/remove"
          echo 1 > /sys/bus/pci/rescan
        done
      }
      
      Since the device ctrl could be updated as an non-RESETTING state by
      repeating probe/remove in userspace (which is a normal situation), we
      can replace stack dumping WARN_ON with a warnning message.
      
      Fixes: 82b057ca ("nvme-pci: fix multiple ctrl removal schedulin")
      Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
      7764656b
  19. 13 7月, 2021 2 次提交
    • C
      nvme-pci: do not call nvme_dev_remove_admin from nvme_remove · 251ef6f7
      Casey Chen 提交于
      nvme_dev_remove_admin could free dev->admin_q and the admin_tagset
      while they are being accessed by nvme_dev_disable(), which can be called
      by nvme_reset_work via nvme_remove_dead_ctrl.
      
      Commit cb4bfda6 ("nvme-pci: fix hot removal during error handling")
      intended to avoid requests being stuck on a removed controller by killing
      the admin queue. But the later fix c8e9e9b7 ("nvme-pci: unquiesce
      admin queue on shutdown"), together with nvme_dev_disable(dev, true)
      right before nvme_dev_remove_admin() could help dispatch requests and
      fail them early, so we don't need nvme_dev_remove_admin() any more.
      
      Fixes: cb4bfda6 ("nvme-pci: fix hot removal during error handling")
      Signed-off-by: NCasey Chen <cachen@purestorage.com>
      Reviewed-by: NKeith Busch <kbusch@kernel.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      251ef6f7
    • C
      nvme-pci: fix multiple races in nvme_setup_io_queues · e4b9852a
      Casey Chen 提交于
      Below two paths could overlap each other if we power off a drive quickly
      after powering it on. There are multiple races in nvme_setup_io_queues()
      because of shutdown_lock missing and improper use of NVMEQ_ENABLED bit.
      
      nvme_reset_work()                                nvme_remove()
        nvme_setup_io_queues()                           nvme_dev_disable()
        ...                                              ...
      A1  clear NVMEQ_ENABLED bit for admin queue          lock
          retry:                                       B1  nvme_suspend_io_queues()
      A2    pci_free_irq() admin queue                 B2  nvme_suspend_queue() admin queue
      A3    pci_free_irq_vectors()                         nvme_pci_disable()
      A4    nvme_setup_irqs();                         B3    pci_free_irq_vectors()
            ...                                            unlock
      A5    queue_request_irq() for admin queue
            set NVMEQ_ENABLED bit
            ...
            nvme_create_io_queues()
      A6      result = queue_request_irq();
              set NVMEQ_ENABLED bit
            ...
            fail to allocate enough IO queues:
      A7      nvme_suspend_io_queues()
              goto retry
      
      If B3 runs in between A1 and A2, it will crash if irqaction haven't
      been freed by A2. B2 is supposed to free admin queue IRQ but it simply
      can't fulfill the job as A1 has cleared NVMEQ_ENABLED bit.
      
      Fix: combine A1 A2 so IRQ get freed as soon as the NVMEQ_ENABLED bit
      gets cleared.
      
      After solved #1, A2 could race with B3 if A2 is freeing IRQ while B3
      is checking irqaction. A3 also could race with B2 if B2 is freeing
      IRQ while A3 is checking irqaction.
      
      Fix: A2 and A3 take lock for mutual exclusion.
      
      A3 could race with B3 since they could run free_msi_irqs() in parallel.
      
      Fix: A3 takes lock for mutual exclusion.
      
      A4 could fail to allocate all needed IRQ vectors if A3 and A4 are
      interrupted by B3.
      
      Fix: A4 takes lock for mutual exclusion.
      
      If A5/A6 happened after B2/B1, B3 will crash since irqaction is not NULL.
      They are just allocated by A5/A6.
      
      Fix: Lock queue_request_irq() and setting of NVMEQ_ENABLED bit.
      
      A7 could get chance to pci_free_irq() for certain IO queue while B3 is
      checking irqaction.
      
      Fix: A7 takes lock.
      
      nvme_dev->online_queues need to be protected by shutdown_lock. Since it
      is not atomic, both paths could modify it using its own copy.
      Co-developed-by: NYuanyuan Zhong <yzhong@purestorage.com>
      Signed-off-by: NCasey Chen <cachen@purestorage.com>
      Reviewed-by: NKeith Busch <kbusch@kernel.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      e4b9852a
  20. 17 6月, 2021 4 次提交
  21. 16 6月, 2021 1 次提交
  22. 03 6月, 2021 1 次提交
  23. 04 5月, 2021 1 次提交
    • T
      nvme-pci: fix controller reset hang when racing with nvme_timeout · d4060d2b
      Tao Chiu 提交于
      reset_work() in nvme-pci may hang forever in the following scenario:
      1) A reset caused by a command timeout occurs due to a controller being
         temporarily irresponsive.
      2) nvme_reset_work() restarts admin queue at nvme_alloc_admin_tags(). At
         the same time, a user-submitted admin command is queued and waiting
         for completion. Then, reset_work() changes its state to CONNECTING,
         and submits an identify command.
      3) However, the controller does still not respond to any command,
         causing a timeout being fired at the user-submitted command.
         Unfortunately, nvme_timeout() does not see the completion on cq, and
         any timeout that takes place under CONNECTING state causes a
         controller shutdown.
      4) Normally, the identify command in reset_work() would be canceled with
         SC_HOST_ABORTED by nvme_dev_disable(), then reset_work can tear down
         the controller accordingly. But the controller happens to return
         online and respond the identify command before nvme_dev_disable()
         should have been reaped it off.
      5) reset_work() continues to setup_io_queues() as it observes no error
         in init_identify(). However, the admin queue has already been
         quiesced in dev_disable(). Thus, any following commands would be
         blocked forever in blk_execute_rq().
      
      This can be fixed by restricting usercmd commands when controller is not
      in a LIVE state in nvme_queue_rq(), as what has been done previously in
      fabrics.
      
      ```
      nvme_reset_work():                     |
          nvme_alloc_admin_tags()            |
                                             | nvme_submit_user_cmd():
          nvme_init_identify():              |     ...
              __nvme_submit_sync_cmd():      |
                  ...                        |     ...
      ---------------------------------------> nvme_timeout():
      (Controller starts reponding commands) |     nvme_dev_disable(, true):
          nvme_setup_io_queues():            |
              __nvme_submit_sync_cmd():      |
                  (hung in blk_execute_rq    |
                   since run_hw_queue sees   |
                   queue quiesced)           |
      
      ```
      Signed-off-by: NTao Chiu <taochiu@synology.com>
      Signed-off-by: NCody Wong <codywong@synology.com>
      Reviewed-by: NLeon Chien <leonchien@synology.com>
      Reviewed-by: NKeith Busch <kbusch@kernel.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      d4060d2b
  24. 15 4月, 2021 1 次提交