summaryrefslogtreecommitdiffstats
path: root/glusterfsd
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-05-15 04:52:33 +0000
committerAnand Avati <avati@gluster.com>2011-05-19 15:41:47 -0700
commitc5d781e05599e9e7ad736d42c9c1033992c76ded (patch)
treeaff88649bc98a6c8babc3d75760fae2ef36b4cc3 /glusterfsd
parent357df32e16dd21e7aedb699c7bd99cac9b95a040 (diff)
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 <csaba@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2690 (race between mtab updates of mount and umount) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2690
Diffstat (limited to 'glusterfsd')
-rw-r--r--glusterfsd/src/Makefile.am10
-rw-r--r--glusterfsd/src/glusterfsd.c33
2 files changed, 29 insertions, 14 deletions
diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am
index 537eda0bbdd..2056ca89806 100644
--- a/glusterfsd/src/Makefile.am
+++ b/glusterfsd/src/Makefile.am
@@ -1,9 +1,6 @@
sbin_PROGRAMS = glusterfsd
-glusterfsd_SOURCES = glusterfsd.c glusterfsd-mgmt.c
-if GF_DARWIN_HOST_OS
-glusterfsd_SOURCES += $(CONTRIBDIR)/apple/daemon.c
-endif
+glusterfsd_SOURCES = glusterfsd.c glusterfsd-mgmt.c $(CONTRIBDIR)/apple/daemon.c
glusterfsd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \
$(top_builddir)/rpc/xdr/src/libgfxdr.la \
@@ -14,10 +11,7 @@ noinst_HEADERS = glusterfsd.h glusterfsd-mem-types.h
AM_CFLAGS = -fPIC -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)\
-I$(top_srcdir)/libglusterfs/src -DDATADIR=\"$(localstatedir)\" \
-DCONFDIR=\"$(sysconfdir)/glusterfs\" $(GF_GLUSTERFS_CFLAGS) \
- -I$(top_srcdir)/rpc/rpc-lib/src -I$(top_srcdir)/rpc/xdr/src
-if GF_DARWIN_HOST_OS
-AM_CFLAGS += -I$(CONTRIBDIR)/apple
-endif
+ -I$(top_srcdir)/rpc/rpc-lib/src -I$(top_srcdir)/rpc/xdr/src -I$(CONTRIBDIR)/apple
CLEANFILES =
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 9406d74ac63..2d2024409ee 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/file.h>
+#include <sys/wait.h>
#include <netdb.h>
#include <signal.h>
#include <libgen.h>
@@ -75,11 +76,7 @@
#include <fnmatch.h>
#include "rpc-clnt.h"
-#ifdef GF_DARWIN_HOST_OS
#include "daemon.h"
-#else
-#define os_daemon(u, v) daemon (u, v)
-#endif
/* using argp for command line parsing */
@@ -315,6 +312,16 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
break;
}
+ if (!cmd_args->no_daemon_mode) {
+ ret = dict_set_static_ptr (master->options, "sync-mtab",
+ "enable");
+ if (ret < 0) {
+ gf_log ("glusterfsd", GF_LOG_ERROR,
+ "failed to set dict value for key sync-mtab");
+ goto err;
+ }
+ }
+
ret = xlator_init (master);
if (ret) {
gf_log ("", GF_LOG_DEBUG, "failed to initialize fuse translator");
@@ -1310,6 +1317,7 @@ daemonize (glusterfs_ctx_t *ctx)
{
int ret = -1;
cmd_args_t *cmd_args = NULL;
+ int cstatus = 0;
cmd_args = &ctx->cmd_args;
@@ -1323,11 +1331,24 @@ daemonize (glusterfs_ctx_t *ctx)
if (cmd_args->debug_mode)
goto postfork;
- ret = os_daemon (0, 0);
- if (ret == -1) {
+ ret = os_daemon_return (0, 0);
+ switch (ret) {
+ case -1:
gf_log ("daemonize", GF_LOG_ERROR,
"Daemonization failed: %s", strerror(errno));
goto out;
+ case 0:
+ break;
+ default:
+ if (ctx->mtab_pid > 0) {
+ ret = waitpid (ctx->mtab_pid, &cstatus, 0);
+ if (!(ret == ctx->mtab_pid && cstatus == 0)) {
+ gf_log ("daemonize", GF_LOG_ERROR,
+ "/etc/mtab update failed");
+ exit (1);
+ }
+ }
+ _exit (0);
}
postfork: