diff options
author | Csaba Henk <csaba@redhat.com> | 2017-05-09 19:26:40 +0200 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-05-23 13:21:25 +0000 |
commit | 461888bb63b2409f8245c7766aa799ca22f734e6 (patch) | |
tree | a8547803299468f49814af66e77cef64bdfae0d7 /contrib/fuse-lib/mount.c | |
parent | 98db583e9b2e7aa8e095a75a6bb5f42b0d65ae79 (diff) |
fuse: implement "-oauto_unmount"
libfuse has an auto_unmount option which,
if enabled, ensures that the file system
is unmounted at FUSE server termination
by running a separate monitor process
that performs the unmount when that
occurs. (This feature would probably
better be called "robust auto-unmount",
as FUSE servers usually do try to unmount
their file systems upon termination,
it's just this mechanism is not crash
resilient.)
This change implements that option and
behavior for glusterfs.
Note that "auto unmount" (robust or not) is
a leaky abstraction, as the kernel cannot
guarantee that at the path where the FUSE
fs is mounted is actually the toplevel mount
at the time of the umount(2) call, for
multiple reasons, among others, see:
fuse-devel: "fuse: feasible to distinguish between umount and abort?"
http://fuse.996288.n3.nabble.com/fuse-feasible-to-distinguish-between-umount-and-abort-tt14358.html
https://github.com/libfuse/libfuse/issues/122
Updates #153
Change-Id: Ia4432580c9fd2c156d9c73c3a44f4bfd42437599
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: https://review.gluster.org/17230
Tested-by: Amar Tumballi <amarts@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'contrib/fuse-lib/mount.c')
-rw-r--r-- | contrib/fuse-lib/mount.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/fuse-lib/mount.c b/contrib/fuse-lib/mount.c index 5bdf454686b..05d04b769e5 100644 --- a/contrib/fuse-lib/mount.c +++ b/contrib/fuse-lib/mount.c @@ -75,6 +75,52 @@ gf_fuse_unmount (const char *mountpoint, int fd) /* gluster-specific routines */ +/* Unmounting in a daemon that lurks 'till main process exits */ +int +gf_fuse_unmount_daemon (const char *mountpoint, int fd) +{ + int ret = -1; + pid_t pid = -1; + + if (fd == -1) + return -1; + + int ump[2] = {0,}; + + ret = pipe(ump); + if (ret == -1) { + close (fd); + return -1; + } + + pid = fork (); + switch (pid) { + char c = 0; + sigset_t sigset; + case 0: + + close_fds_except (ump, 1); + + setsid(); + chdir("/"); + sigfillset(&sigset); + sigprocmask(SIG_BLOCK, &sigset, NULL); + + read (ump[0], &c, 1); + + gf_fuse_unmount (mountpoint, fd); + exit (0); + case -1: + close (fd); + fd = -1; + ret = -1; + close (ump[1]); + } + close (ump[0]); + + return ret; +} + static char * escape (char *s) { |