1. 15 7月, 2022 17 次提交
  2. 14 7月, 2022 3 次提交
    • M
      ublk_drv: fix request queue leak · cebbe577
      Ming Lei 提交于
      Call blk_cleanup_queue() in release code path for fixing request
      queue leak.
      
      Also for-5.20/block has cleaned up blk_cleanup_queue(), which is
      basically merged to del_gendisk() if blk_mq_alloc_disk() is used
      for allocating disk and queue.
      
      However, ublk may not add disk in case of starting device failure, then
      del_gendisk() won't be called when removing ublk device, so blk_mq_exit_queue
      will not be callsed, and it can be bit hard to deal with this kind of
      merge conflict.
      
      Turns out ublk's queue/disk use model is very similar with scsi, so switch
      to scsi's model by allocating disk and queue independently, then it can be
      quite easy to handle v5.20 merge conflict by replacing blk_cleanup_queue
      with blk_mq_destroy_queue.
      Reported-by: NJens Axboe <axboe@kernel.dk>
      Fixes: 71f28f31 ("ublk_drv: add io_uring based userspace block driver")
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20220714103201.131648-1-ming.lei@redhat.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      cebbe577
    • M
      ublk_drv: support to complete io command via task_work_add · 0edb3696
      Ming Lei 提交于
      Use task_work_add if it is available, since task_work_add can bring
      up better performance, especially batching signaling ->ubq_daemon can
      be done.
      
      It is observed that task_work_add() can boost iops by +4% on random
      4k io test. Also except for completing io command, all other code
      paths are same with completing io command via
      io_uring_cmd_complete_in_task.
      
      Meantime add one flag of UBLK_F_URING_CMD_COMP_IN_TASK for comparing
      the mode easily.
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20220713140711.97356-3-ming.lei@redhat.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      0edb3696
    • M
      ublk_drv: add io_uring based userspace block driver · 71f28f31
      Ming Lei 提交于
      This is the driver part of userspace block driver(ublk driver), the other
      part is userspace daemon part(ublksrv)[1].
      
      The two parts communicate by io_uring's IORING_OP_URING_CMD with one
      shared cmd buffer for storing io command, and the buffer is read only for
      ublksrv, each io command is indexed by io request tag directly, and is
      written by ublk driver.
      
      For example, when one READ io request is submitted to ublk block driver,
      ublk driver stores the io command into cmd buffer first, then completes
      one IORING_OP_URING_CMD for notifying ublksrv, and the URING_CMD is issued
      to ublk driver beforehand by ublksrv for getting notification of any new
      io request, and each URING_CMD is associated with one io request by tag.
      
      After ublksrv gets the io command, it translates and handles the ublk io
      request, such as, for the ublk-loop target, ublksrv translates the request
      into same request on another file or disk, like the kernel loop block
      driver. In ublksrv's implementation, the io is still handled by io_uring,
      and share same ring with IORING_OP_URING_CMD command. When the target io
      request is done, the same IORING_OP_URING_CMD is issued to ublk driver for
      both committing io request result and getting future notification of new
      io request.
      
      Another thing done by ublk driver is to copy data between kernel io
      request and ublksrv's io buffer:
      
      1) before ubsrv handles WRITE request, copy the request's data into
         ublksrv's userspace io buffer, so that ublksrv can handle the write
         request
      
      2) after ubsrv handles READ request, copy ublksrv's userspace io buffer
         into this READ request, then ublk driver can complete the READ request
      
      Zero copy may be switched if mm is ready to support it.
      
      ublk driver doesn't handle any logic of the specific user space driver,
      so it is small/simple enough.
      
      [1] ublksrv
      
      https://github.com/ming1/ubdsrvSigned-off-by: NMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20220713140711.97356-2-ming.lei@redhat.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
      71f28f31
  3. 13 7月, 2022 4 次提交
  4. 12 7月, 2022 1 次提交
  5. 06 7月, 2022 15 次提交