mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd@bsbernd.com>
To: Yun Wang <arsenova@a7snv.com>
Cc: Joanne Koong <joannelkoong@gmail.com>,
	fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads
Date: Thu, 19 Nov 2026 12:57:53 +0100	[thread overview]
Message-ID: <5f5d6c24-2bb0-4af9-8ece-d53cc6e612f6@bsbernd.com> (raw)
In-Reply-To: <20261116235747.60403-1-arsenova@a7snv.com>



On 11/19/26 12:36, Yun Wang wrote:
> Since commit dfb84c330794 ("fuse: allow synchronous FUSE_INIT"),
> fuse_get_dev() waits until the mount has installed the channel when
> FUSE_DEV_IOC_SYNC_INIT was used on the device.  fuse_dev_read() and
> fuse_dev_splice_read() call it before fuse_dev_do_read() looks at
> O_NONBLOCK, so read(2) or splice(2) on an O_NONBLOCK sync-init device
> that is not mounted yet sleeps until the mount or a signal, instead of
> returning -EAGAIN.  Commit 9f6f44aa5a58 ("fuse: don't block in
> fuse_get_dev() for non-sync_init case") fixed the same hang for
> devices without sync init, which LTP's read_all hit with O_NONBLOCK
> reads of /dev/fuse.
> 
> Add fuse_get_dev_nowait(), which returns -EAGAIN instead of waiting for
> the mount, and fuse_get_dev_read(), which uses it for O_NONBLOCK files,
> and call the latter from fuse_dev_read() and fuse_dev_splice_read().
> fuse_get_dev() is unchanged and keeps waiting for its other callers.
> 
> A non-blocking read before the mount now gets -EAGAIN, the same as
> after the mount while no request is queued.  Blocking reads still wait
> for the mount.
> 
> Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
> Signed-off-by: Yun Wang <arsenova@a7snv.com>
> ---
>  fs/fuse/dev.c        | 12 ++++++++++--
>  fs/fuse/fuse_dev_i.h | 14 ++++++++++++++
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 3641abb90d..23ba4f432d 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -1705,11 +1705,19 @@ struct fuse_dev *fuse_get_dev(struct file *file)
>  	return fud;
>  }
>  
> +/* read(2) and splice(2) of an O_NONBLOCK device don't wait for the mount */
> +static struct fuse_dev *fuse_get_dev_read(struct file *file)
> +{
> +	if (file->f_flags & O_NONBLOCK)
> +		return fuse_get_dev_nowait(file);
> +	return fuse_get_dev(file);
> +}
> +

This is just a style comment, for me "fuse_get_dev_read" sounds weird.
Maybe call this fuse_get_dev() and rename the other to _fuse_get_dev()?
And both could be in the header file?

>  static ssize_t fuse_dev_read(struct kiocb *iocb, struct iov_iter *to)
>  {
>  	struct fuse_copy_state cs;
>  	struct file *file = iocb->ki_filp;
> -	struct fuse_dev *fud = fuse_get_dev(file);
> +	struct fuse_dev *fud = fuse_get_dev_read(file);
>  
>  	if (IS_ERR(fud))
>  		return PTR_ERR(fud);
> @@ -1730,7 +1738,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
>  	int page_nr = 0;
>  	struct pipe_buffer *bufs;
>  	struct fuse_copy_state cs;
> -	struct fuse_dev *fud = fuse_get_dev(in);
> +	struct fuse_dev *fud = fuse_get_dev_read(in);
>  
>  	if (IS_ERR(fud))
>  		return PTR_ERR(fud);
> diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
> index 4b412a7622..bb7e10656a 100644
> --- a/fs/fuse/fuse_dev_i.h
> +++ b/fs/fuse/fuse_dev_i.h
> @@ -367,6 +367,20 @@ static inline struct fuse_dev *__fuse_get_dev(struct file *file)
>  	return fud;
>  }
>  
> +/*
> + * Like fuse_get_dev(), but don't wait for the mount of a sync-init device:
> + * return -EAGAIN instead.
> + */
> +static inline struct fuse_dev *fuse_get_dev_nowait(struct file *file)
> +{
> +	struct fuse_dev *fud = fuse_file_to_fud(file);
> +
> +	if (unlikely(!fuse_dev_chan_get(fud)))
> +		return ERR_PTR(fud->sync_init ? -EAGAIN : -EPERM);
> +
> +	return fud;
> +}
> +
>  void fuse_iqueue_init(struct fuse_iqueue *fiq, const struct fuse_iqueue_ops *ops, void *priv);
>  
>  struct fuse_dev *fuse_get_dev(struct file *file);


Besides of pure style comment (and Miklos might have a different
preference), looks good to me.


Reviewed-by: Bernd Schubert <bernd@bsbernd.com>

  reply	other threads:[~2026-11-19 11:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 11:35 [PATCH 0/2] fuse: don't wait for a sync-init mount in non-blocking reads and uring_cmd Yun Wang
2026-11-19 11:36 ` [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads Yun Wang
2026-11-19 11:57   ` Bernd Schubert [this message]
2026-11-19 11:36 ` [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd() Yun Wang
2026-11-17 21:47   ` Bernd Schubert
2026-11-19 13:15     ` Yun Wang

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=5f5d6c24-2bb0-4af9-8ece-d53cc6e612f6@bsbernd.com \
    --to=bernd@bsbernd.com \
    --cc=arsenova@a7snv.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=joannelkoong@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®