FILESYSTEM IN USERSPACE (FUSE) development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: bernd@bsbernd.com
Cc: fuse-devel@lists.linux.dev
Subject: Re: [PATCH 09/10] fuse mount: Do not set sync_init when sync_init was not used
Date: Fri, 8 May 2026 17:35:34 -0700	[thread overview]
Message-ID: <20260509003534.GN2241589@frogsfrogsfrogs> (raw)
In-Reply-To: <20260508-new-mount-fixes-and-tests-v1-9-c67a0893ddbc@bsbernd.com>

On Fri, May 08, 2026 at 06:39:12PM +0200, Bernd Schubert via B4 Relay wrote:
> From: Bernd Schubert <bernd@bsbernd.com>
> 
> synchronous init is just a hint and we cannot fail on it, but for
> daemonization we need to do know when it was actually used.
> Bug was that se->sync_init() was set unconditionally on mount success.
> 
> Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
> ---
>  lib/fuse_lowlevel.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
> index 6e078e82..60b936c3 100644
> --- a/lib/fuse_lowlevel.c
> +++ b/lib/fuse_lowlevel.c
> @@ -4471,10 +4471,13 @@ static void *session_sync_init_worker(void *data)
>  }
>  
>  /* Enable synchronous FUSE_INIT and start worker thread */
> -static int session_start_sync_init(struct fuse_session *se, int fd)
> +static int session_start_sync_init(struct fuse_session *se, int fd,
> +				   bool *is_sync_init)
>  {
>  	int err, res;
>  
> +	*is_sync_init = false;
> +
>  	/*
>  	 * Older fuse servers do not set want_sync_init or start the new
>  	 * daemonize code, so they get async init.
> @@ -4536,6 +4539,8 @@ static int session_start_sync_init(struct fuse_session *se, int fd)
>  		return -EIO;
>  	}
>  
> +	*is_sync_init = true;

Hrm.  So we only end up with return value == 0 and *is_sync_init==true
if SYNC_INIT was enabled via ioctl and all the pthread stuff is ready to
go.  The other two outcomes are:

1. return == 0 && *is_sync_init==false if the kernel didn't let us use
   synchronous init

2. return != 0 if something broke and we just want to abort

If that's all correct then I've understood this patch well enough to say
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> +
>  	return 0;
>  }
>  
> @@ -4594,7 +4599,8 @@ static int session_wait_sync_init_completion(struct fuse_session *se)
>  static int new_api_fusermount(struct fuse_session *se,
>  			      const char *mountpoint,
>  			      const char *mnt_opts,
> -			      int *sock_fd, pid_t *fusermount_pid)
> +			      int *sock_fd, pid_t *fusermount_pid,
> +			      bool *is_sync_init)
>  {
>  	int fd, err;
>  
> @@ -4617,7 +4623,7 @@ static int new_api_fusermount(struct fuse_session *se,
>  
>  	/* Start worker thread with correct fd from fusermount3 */
>  	se->fd = fd;
> -	err = session_start_sync_init(se, fd);
> +	err = session_start_sync_init(se, fd, is_sync_init);
>  	if (err) {
>  		fuse_log(FUSE_LOG_ERR,
>  			 "fuse: failed to start sync init worker\n");
> @@ -4649,6 +4655,7 @@ static int fuse_session_mount_new_api(struct fuse_session *se,
>  	char *mnt_opts = NULL;
>  	char *mnt_opts_with_fd = NULL;
>  	char fd_opt[32];
> +	bool is_sync_init = false;
>  
>  	res = fuse_kern_mount_get_base_mnt_opts(se->mo, &mnt_opts);
>  	err = -EIO;
> @@ -4665,7 +4672,7 @@ static int fuse_session_mount_new_api(struct fuse_session *se,
>  	}
>  
>  	se->fd = fd;
> -	err = session_start_sync_init(se, fd);
> +	err = session_start_sync_init(se, fd, &is_sync_init);
>  	if (err)
>  		goto err;
>  
> @@ -4684,7 +4691,8 @@ static int fuse_session_mount_new_api(struct fuse_session *se,
>  		close(fd);
>  		se->fd = -1;
>  		fd = new_api_fusermount(se, mountpoint, mnt_opts,
> -					&sock_fd, &fusermount_pid);
> +					&sock_fd, &fusermount_pid,
> +					&is_sync_init);
>  		if (fd < 0) {
>  			err = fd;
>  			goto err_with_sock;
> @@ -4711,11 +4719,12 @@ err:
>  		se->fd = -1;
>  		se->error = err;
>  	}
> +	se->is_sync_init = is_sync_init;
> +
>  	/* Wait for synchronous FUSE_INIT to complete */
>  	if (session_wait_sync_init_completion(se) < 0)
>  		fuse_log(FUSE_LOG_ERR, "fuse: sync init completion failed\n");
>  
> -	se->is_sync_init = true;
>  	free(mnt_opts);
>  	free(mnt_opts_with_fd);
>  	return fd;
> @@ -4791,7 +4800,6 @@ int fuse_session_mount(struct fuse_session *se, const char *_mountpoint)
>  out:
>  	se->fd = fd;
>  	se->mountpoint = mountpoint;
> -
>  	fuse_daemonize_early_set_mounted();
>  
>  	return 0;
> 
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-05-09  0:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 16:39 [PATCH 00/10] libfuse: new mount API and SYNC_INIT fixes and tests Bernd Schubert via B4 Relay
2026-05-08 16:39 ` [PATCH 01/10] test: register pytest run as a meson test Bernd Schubert via B4 Relay
2026-05-08 23:53   ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 02/10] Add tests to verify that mountinfo matches requested options Bernd Schubert via B4 Relay
2026-05-08 23:59   ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 03/10] test: assert ro/rw, nosuid/suid, nodev/dev round-trip via fsmount Bernd Schubert via B4 Relay
2026-05-09  0:04   ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 04/10] New mount API: read-only option is for fsmount() and fsconfig() Bernd Schubert via B4 Relay
2026-05-09  0:17   ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 05/10] libfuse: don't use SYNC_INIT unless asked for Bernd Schubert via B4 Relay
2026-05-08 16:39 ` [PATCH 06/10] example: silence add_languages warning by setting 'native: false' Bernd Schubert via B4 Relay
2026-05-09  0:23   ` Darrick J. Wong
2026-05-08 16:39 ` [PATCH 07/10] mount: clarify kernel_opts vs mnt_opts vs flags in fuse_kern_fsmount Bernd Schubert via B4 Relay
2026-05-09  0:27   ` Darrick J. Wong
2026-05-10 17:21     ` Bernd Schubert
2026-05-08 16:39 ` [PATCH 08/10] fuse_daemonize_early_start: Disallow daemonization when already active Bernd Schubert via B4 Relay
2026-05-09  0:30   ` Darrick J. Wong
2026-05-10 16:53     ` Bernd Schubert
2026-05-10 17:01       ` Bernd Schubert
2026-05-08 16:39 ` [PATCH 09/10] fuse mount: Do not set sync_init when sync_init was not used Bernd Schubert via B4 Relay
2026-05-09  0:35   ` Darrick J. Wong [this message]
2026-05-10 17:04     ` Bernd Schubert
2026-05-08 16:39 ` [PATCH 10/10] highlevel: Switch fuse_main_real_versioned() to fuse_daemonize_early() Bernd Schubert via B4 Relay
2026-05-09  0:38   ` Darrick J. Wong
2026-05-10 17:19     ` Bernd Schubert

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=20260509003534.GN2241589@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=bernd@bsbernd.com \
    --cc=fuse-devel@lists.linux.dev \
    /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