summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorpelikan <pelikan@cvs.openbsd.org>2013-12-10 13:43:06 +0000
committerpelikan <pelikan@cvs.openbsd.org>2013-12-10 13:43:06 +0000
commitee3973476043ec468021775731425ec57f8df99b (patch)
treed6f75e5a1d62838032c5fc09127130a3072b3c1a /sys
parent6a54213e7ba85af13b6334f8d037c6433bee8d4e (diff)
Unset fuse_mnt in fusefs_unmount after vflushing and freeing fbufs in use.
This way, if fuse unmounts a FS without FBT_DESTROY, the fuse_mnt pointer is already invalidated. Also, on weird unmount situations with vnodes in use, vflush() them before doing fuse_device_cleanup(). Tested with ntfs-3g, ok syl@.
Diffstat (limited to 'sys')
-rw-r--r--sys/miscfs/fuse/fuse_device.c6
-rw-r--r--sys/miscfs/fuse/fuse_vfsops.c10
-rw-r--r--sys/miscfs/fuse/fusefs.h4
3 files changed, 10 insertions, 10 deletions
diff --git a/sys/miscfs/fuse/fuse_device.c b/sys/miscfs/fuse/fuse_device.c
index 787e9f89724..1d9b4b900f3 100644
--- a/sys/miscfs/fuse/fuse_device.c
+++ b/sys/miscfs/fuse/fuse_device.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_device.c,v 1.11 2013/12/03 09:53:37 syl Exp $ */
+/* $OpenBSD: fuse_device.c,v 1.12 2013/12/10 13:43:05 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -202,7 +202,7 @@ fuse_device_queue_fbuf(dev_t dev, struct fusebuf *fbuf)
}
void
-fuse_device_set_fmp(struct fusefs_mnt *fmp)
+fuse_device_set_fmp(struct fusefs_mnt *fmp, int set)
{
struct fuse_d *fd;
@@ -210,7 +210,7 @@ fuse_device_set_fmp(struct fusefs_mnt *fmp)
if (fd == NULL)
return;
- fd->fd_fmp = fmp;
+ fd->fd_fmp = set ? fmp : NULL;
}
void
diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c
index 04517393991..6b34645d20c 100644
--- a/sys/miscfs/fuse/fuse_vfsops.c
+++ b/sys/miscfs/fuse/fuse_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_vfsops.c,v 1.7 2013/10/07 18:25:32 syl Exp $ */
+/* $OpenBSD: fuse_vfsops.c,v 1.8 2013/12/10 13:43:05 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -108,7 +108,7 @@ fusefs_mount(struct mount *mp, const char *path, void *data,
bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
bcopy("fusefs", mp->mnt_stat.f_mntfromname, sizeof("fusefs"));
- fuse_device_set_fmp(fmp);
+ fuse_device_set_fmp(fmp, 1);
fbuf = fb_setup(0, 0, FBT_INIT, p);
/* cannot tsleep on mount */
@@ -141,13 +141,11 @@ fusefs_unmount(struct mount *mp, int mntflags, struct proc *p)
error = fb_queue(fmp->dev, fbuf);
if (error)
- printf("fusefs: error from fuse\n");
+ printf("fusefs: error %d on destroy\n", error);
fb_delete(fbuf);
}
- fuse_device_cleanup(fmp->dev, NULL);
-
if (mntflags & MNT_FORCE) {
/* fusefs can never be rootfs so don't check for it */
if (!doforce)
@@ -159,6 +157,8 @@ fusefs_unmount(struct mount *mp, int mntflags, struct proc *p)
if ((error = vflush(mp, 0, flags)))
return (error);
+ fuse_device_cleanup(fmp->dev, NULL);
+ fuse_device_set_fmp(fmp, 0);
free(fmp, M_FUSEFS);
return (error);
diff --git a/sys/miscfs/fuse/fusefs.h b/sys/miscfs/fuse/fusefs.h
index c0994148fb8..60b6fa12b49 100644
--- a/sys/miscfs/fuse/fusefs.h
+++ b/sys/miscfs/fuse/fusefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fusefs.h,v 1.4 2013/10/07 18:07:04 syl Exp $ */
+/* $OpenBSD: fusefs.h,v 1.5 2013/12/10 13:43:05 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -82,7 +82,7 @@ int fusefs_file_close(struct fusefs_mnt *, struct fusefs_node *,
/* device helpers. */
void fuse_device_cleanup(dev_t, struct fusebuf *);
void fuse_device_queue_fbuf(dev_t, struct fusebuf *);
-void fuse_device_set_fmp(struct fusefs_mnt *);
+void fuse_device_set_fmp(struct fusefs_mnt *, int);
/*
* The root inode is the root of the file system. Inode 0 can't be used for