summaryrefslogtreecommitdiffstats
path: root/xlators/mount/fuse/src/fuse-bridge.c
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2017-05-09 19:26:40 +0200
committerShyamsundar Ranganathan <srangana@redhat.com>2017-05-23 13:21:25 +0000
commit461888bb63b2409f8245c7766aa799ca22f734e6 (patch)
treea8547803299468f49814af66e77cef64bdfae0d7 /xlators/mount/fuse/src/fuse-bridge.c
parent98db583e9b2e7aa8e095a75a6bb5f42b0d65ae79 (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 'xlators/mount/fuse/src/fuse-bridge.c')
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index a0a09a4ec57..03f766082e2 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -5150,7 +5150,7 @@ fuse_thread_proc (void *data)
ZR_MOUNTPOINT_OPT));
if (mount_point) {
gf_log (this->name, GF_LOG_INFO,
- "unmounting %s", mount_point);
+ "initating unmount of %s", mount_point);
}
/* Kill the whole process, not just this thread. */
@@ -5779,6 +5779,24 @@ init (xlator_t *this_xl)
if (!mnt_args)
goto cleanup_exit;
+ {
+ char *mnt_tok = NULL;
+ token_iter_t tit = {0,};
+ gf_boolean_t iter_end = _gf_false;
+
+ for (mnt_tok = token_iter_init (mnt_args, ',', &tit) ;;) {
+ iter_end = next_token (&mnt_tok, &tit);
+
+ if (strcmp (mnt_tok, "auto_unmount") == 0) {
+ priv->auto_unmount = _gf_true;
+ drop_token (mnt_tok, &tit);
+ }
+
+ if (iter_end)
+ break;
+ }
+ }
+
if (pipe(priv->status_pipe) < 0) {
gf_log (this_xl->name, GF_LOG_ERROR,
"could not create pipe to separate mount process");
@@ -5790,6 +5808,11 @@ init (xlator_t *this_xl)
priv->status_pipe[1]);
if (priv->fd == -1)
goto cleanup_exit;
+ if (priv->auto_unmount) {
+ ret = gf_fuse_unmount_daemon (priv->mount_point, priv->fd);
+ if (ret ==-1)
+ goto cleanup_exit;
+ }
event = eh_new (FUSE_EVENT_HISTORY_SIZE, _gf_false, NULL);
if (!event) {
@@ -5867,10 +5890,15 @@ fini (xlator_t *this_xl)
mount_point = data_to_str (dict_get (this_xl->options,
ZR_MOUNTPOINT_OPT));
if (mount_point != NULL) {
+ if (!priv->auto_unmount) {
+ gf_log (this_xl->name, GF_LOG_INFO,
+ "Unmounting '%s'.", mount_point);
+ gf_fuse_unmount (mount_point, priv->fd);
+ }
+
gf_log (this_xl->name, GF_LOG_INFO,
- "Unmounting '%s'.", mount_point);
+ "Closing fuse connection to '%s'.", mount_point);
- gf_fuse_unmount (mount_point, priv->fd);
sys_close (priv->fuse_dump_fd);
dict_del (this_xl->options, ZR_MOUNTPOINT_OPT);
}