Re: [RFC PATCH] ubd: add io_uring based userspace block driver

From: Ming Lei
Date: Wed Jun 01 2022 - 23:20:15 EST


Hello Pavel,

On Mon, May 30, 2022 at 09:07:00AM +0200, Pavel Machek wrote:
> Hi!
>
> > This is the driver part of userspace block driver(ubd driver), the other
> > part is userspace daemon part(ubdsrv)[1].
>
> > @@ -0,0 +1,1193 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Userspace block device - block device which IO is handled from userspace
> > + *
> > + * Take full use of io_uring passthrough command for communicating with
> > + * ubd userspace daemon(ubdsrvd) for handling basic IO request.
>
> > +
> > +static inline unsigned int ubd_req_build_flags(struct request *req)
> > +{
> ...
> > + if (req->cmd_flags & REQ_SWAP)
> > + flags |= UBD_IO_F_SWAP;
> > +
> > + return flags;
> > +}
>
> Does it work? How do you guarantee operation will be deadlock-free with swapping and
> writebacks going on?

The above is just for providing command flags to user side, so that the
user side can understand/handle the request better.

prtrl(PR_SET_IO_FLUSHER) has been merged for avoiding the deadlock.

>
> What are restriction on ubdsrv? What happens when it needs to allocate memory, or is
> swapped out?

Yeah, ubd_copy_pages() needs to pin pages for copying data between
user VM and block request pages, and get_user_pages may run out of pages.
But I think forward progress can still be provided by reserving one VM buffer
with single page locked.

> Have mm people seen this?

I remembered that the early RFC with related discussion is CCed to mm
list, and all follow-up are CC to linux-kernel.

Not one big deal, will Cc mm list in the future post.


thanks,
Ming