From c5d781e05599e9e7ad736d42c9c1033992c76ded Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Sun, 15 May 2011 04:52:33 +0000 Subject: upon daemonizing, wait on mtab update to terminate in parent This fixes the race in between the mtab update attempts of mount and umount when we do a lazy umount right after mounting, in order to hide the given fs instance; yet this way we still avoid the deadlock of the fs and mount which we can hit if we wait unconditionally for the mtab update to terminate (cf. bz #511). Signed-off-by: Csaba Henk Signed-off-by: Anand Avati BUG: 2690 (race between mtab updates of mount and umount) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2690 --- xlators/mount/fuse/src/fuse-bridge.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index d34a747f4..dafc0a93c 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -3485,6 +3485,8 @@ init (xlator_t *this_xl) int i = 0; int xl_name_allocated = 0; int fsname_allocated = 0; + glusterfs_ctx_t *ctx = NULL; + gf_boolean_t sync_mtab = _gf_false; if (this_xl == NULL) return -1; @@ -3492,6 +3494,10 @@ init (xlator_t *this_xl) if (this_xl->options == NULL) return -1; + ctx = glusterfs_ctx_get (); + if (!ctx) + return -1; + options = this_xl->options; if (this_xl->name == NULL) { @@ -3604,6 +3610,14 @@ init (xlator_t *this_xl) priv->fuse_dump_fd = ret; } + sync_mtab = _gf_false; + ret = dict_get_str (options, "sync-mtab", &value_string); + if (ret == 0) { + ret = gf_string2boolean (value_string, + &sync_mtab); + GF_ASSERT (ret == 0); + } + cmd_args = &this_xl->ctx->cmd_args; fsname = cmd_args->volfile; if (!fsname && cmd_args->volfile_server) { @@ -3630,7 +3644,8 @@ init (xlator_t *this_xl) priv->fd = gf_fuse_mount (priv->mount_point, fsname, "allow_other,default_permissions," - "max_read=131072"); + "max_read=131072", + sync_mtab ? &ctx->mtab_pid : NULL); if (priv->fd == -1) goto cleanup_exit; @@ -3727,5 +3742,8 @@ struct volume_options options[] = { { .key = {"client-pid"}, .type = GF_OPTION_TYPE_INT }, + { .key = {"sync-mtab"}, + .type = GF_OPTION_TYPE_BOOL + }, { .key = {NULL} }, }; -- cgit