public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ming Lei <[email protected]>
To: Sagi Grimberg <[email protected]>
Cc: Jens Axboe <[email protected]>,
	[email protected],
	Harris James R <[email protected]>,
	[email protected], [email protected],
	Gabriel Krisman Bertazi <[email protected]>,
	ZiyangZhang <[email protected]>,
	Xiaoguang Wang <[email protected]>,
	Stefan Hajnoczi <[email protected]>,
	[email protected]
Subject: Re: [PATCH V3 1/1] ublk: add io_uring based userspace block driver
Date: Mon, 4 Jul 2022 20:34:15 +0800	[thread overview]
Message-ID: <YsLeR1QWPmqfNAQY@T590> (raw)
In-Reply-To: <[email protected]>

On Mon, Jul 04, 2022 at 02:17:44PM +0300, Sagi Grimberg wrote:
> 
> > 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 should be small/simple enough.
> > 
> > [1] ublksrv
> > 
> > https://github.com/ming1/ubdsrv
> > 
> > Signed-off-by: Ming Lei <[email protected]>
> > ---
> >   drivers/block/Kconfig         |    6 +
> >   drivers/block/Makefile        |    2 +
> >   drivers/block/ublk_drv.c      | 1603 +++++++++++++++++++++++++++++++++
> >   include/uapi/linux/ublk_cmd.h |  158 ++++
> >   4 files changed, 1769 insertions(+)
> >   create mode 100644 drivers/block/ublk_drv.c
> >   create mode 100644 include/uapi/linux/ublk_cmd.h
> > 
> > diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> > index fdb81f2794cd..d218089cdbec 100644
> > --- a/drivers/block/Kconfig
> > +++ b/drivers/block/Kconfig
> > @@ -408,6 +408,12 @@ config BLK_DEV_RBD
> >   	  If unsure, say N.
> > +config BLK_DEV_UBLK
> > +	bool "Userspace block driver"
> 
> Really? why compile this to the kernel and not tristate as loadable
> module?

So far, this is only one reason: task_work_add() is required, which
isn't exported for modules.


Thanks,
Ming


  reply	other threads:[~2022-07-04 12:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 16:08 [PATCH V3 0/1] ublk: add io_uring based userspace block driver Ming Lei
2022-06-28 16:08 ` [PATCH V3 1/1] " Ming Lei
2022-06-30 11:35   ` Ziyang Zhang
2022-06-30 12:33     ` Ming Lei
2022-07-01  2:47       ` Ziyang Zhang
2022-07-01  4:06         ` Ming Lei
2022-07-04 11:17   ` Sagi Grimberg
2022-07-04 12:34     ` Ming Lei [this message]
2022-07-04 14:00       ` Sagi Grimberg
2022-07-04 16:13         ` Gabriel Krisman Bertazi
2022-07-04 16:19           ` Sagi Grimberg
2022-07-05  0:43             ` Ming Lei
2022-07-04 22:10   ` Gabriel Krisman Bertazi
2022-07-05  4:16     ` Ziyang Zhang
2022-07-05  8:12       ` Ming Lei
2022-07-05  8:06     ` Ming Lei
2022-07-07  7:49       ` Ming Lei
2022-07-07  7:58         ` Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YsLeR1QWPmqfNAQY@T590 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox