1
0
mirror of https://git.FreeBSD.org/src.git synced 2026-06-02 11:24:32 +00:00

fusefs: Implement support for the auto_unmount option kernel-side

libfuse clients may pass the "-o auto_unmount" flag to ensure that the mountpoint
will get unmounted even if the server terminate abnormally. Without this flag
sending KILL to a FUSE daemon leaves its mountpoint mounted.

Approved by:	asomers
Differential Revision:	https://reviews.freebsd.org/D53086
This commit is contained in:
Gleb Popov
2025-10-14 19:15:50 +03:00
parent 04f6b99947
commit 10037d0978
5 changed files with 14 additions and 3 deletions
+4 -1
View File
@@ -32,7 +32,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd October 9, 2021
.Dd January 24, 2026
.Dt MOUNT_FUSEFS 8
.Os
.Sh NAME
@@ -171,6 +171,9 @@ to the file system name as reported by
.Xr statfs 2 .
This option can be used to identify the file system implemented by
.Ar fuse_daemon .
.It Cm auto_unmount
Instructs the kernel to unmount the mount point when the FUSE device gets closed.
This ensures a proper cleanup if the FUSE daemon exits abnormally.
.El
.El
.Pp
+2
View File
@@ -84,6 +84,8 @@ static struct mntopt mopts[] = {
{ "automounted", 0, ALTF_AUTOMOUNTED, 1 },
#define ALTF_INTR 0x200
{ "intr", 0, ALTF_INTR, 1 },
#define ALTF_AUTOUNMOUNT 0x400
{ "auto_unmount", 0, ALTF_AUTOUNMOUNT, 1 },
/* Linux specific options, we silently ignore them */
{ "fd=", 0, 0x00, 1 },
{ "rootmode=", 0, 0x00, 1 },
+5 -1
View File
@@ -65,7 +65,6 @@
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/uio.h>
@@ -177,6 +176,11 @@ fdata_dtor(void *arg)
fuse_lck_mtx_unlock(fdata->ms_mtx);
FUSE_UNLOCK();
if (fdata->mp && fdata->dataflags & FSESS_AUTO_UNMOUNT) {
vfs_ref(fdata->mp);
dounmount(fdata->mp, MNT_FORCE, curthread);
}
fdata_trydestroy(fdata);
}
+2 -1
View File
@@ -242,8 +242,9 @@ struct fuse_data {
#define FSESS_WARN_INODE_MISMATCH 0x4000000 /* ino != nodeid */
#define FSESS_MNTOPTS_MASK ( \
FSESS_DAEMON_CAN_SPY | FSESS_PUSH_SYMLINKS_IN | \
FSESS_DEFAULT_PERMISSIONS | FSESS_INTR)
FSESS_DEFAULT_PERMISSIONS | FSESS_INTR | FSESS_AUTO_UNMOUNT)
#define FSESS_SETXATTR_EXT 0x8000000 /* extended fuse_setxattr_in */
#define FSESS_AUTO_UNMOUNT 0x10000000 /* perform unmount when server dies */
extern int fuse_data_cache_mode;
+1
View File
@@ -337,6 +337,7 @@ fuse_vfsop_mount(struct mount *mp)
FUSE_FLAGOPT(push_symlinks_in, FSESS_PUSH_SYMLINKS_IN);
FUSE_FLAGOPT(default_permissions, FSESS_DEFAULT_PERMISSIONS);
FUSE_FLAGOPT(intr, FSESS_INTR);
FUSE_FLAGOPT(auto_unmount, FSESS_AUTO_UNMOUNT);
(void)vfs_scanopt(opts, "max_read=", "%u", &max_read);
(void)vfs_scanopt(opts, "linux_errnos", "%d", &linux_errnos);