From a3cb38e3edf005bef73da4c9cfd958474a14d50f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 17 Apr 2014 15:54:34 -0700 Subject: build: MacOSX Porting fixes git@forge.gluster.org:~schafdog/glusterfs-core/osx-glusterfs Working functionality on MacOSX - GlusterD (management daemon) - GlusterCLI (management cli) - GlusterFS FUSE (using OSXFUSE) - GlusterNFS (without NLM - issues with rpc.statd) Change-Id: I20193d3f8904388e47344e523b3787dbeab044ac BUG: 1089172 Signed-off-by: Harshavardhana Signed-off-by: Dennis Schafroth Tested-by: Harshavardhana Tested-by: Dennis Schafroth Reviewed-on: http://review.gluster.org/7503 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/nfs/server/src/nlm4.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'xlators/nfs/server/src/nlm4.c') diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index c186537ea..d0caa97c2 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -2423,9 +2423,21 @@ nlm4svc_init(xlator_t *nfsx) /* unlink sm-notify.pid so that when we restart rpc.statd/sm-notify * it thinks that the machine has restarted and sends NOTIFY to clients. */ - ret = unlink ("/var/run/sm-notify.pid"); + + /* TODO: + notify/rpc.statd is done differently on OSX + + On OSX rpc.statd is controlled by rpc.lockd and are part for launchd + (unified service management framework) + + A runcmd() should be invoking "launchctl start com.apple.lockd" + instead. This is still a theory but we need to thoroughly test it + out. Until then NLM support is non-existent on OSX. + */ + ret = unlink (GF_SM_NOTIFY_PIDFILE); if (ret == -1 && errno != ENOENT) { - gf_log (GF_NLM, GF_LOG_ERROR, "unable to unlink sm-notify"); + gf_log (GF_NLM, GF_LOG_ERROR, "unable to unlink %s: %d", + GF_SM_NOTIFY_PIDFILE, errno); goto err; } /* temporary work around to restart statd, not distro/OS independant. @@ -2433,37 +2445,43 @@ nlm4svc_init(xlator_t *nfsx) * killall will cause problems on solaris. */ - pidfile = fopen ("/var/run/rpc.statd.pid", "r"); + char *pid_file = GF_RPC_STATD_PIDFILE; + if (nfs->rpc_statd_pid_file) + pid_file = nfs->rpc_statd_pid_file; + pidfile = fopen (pid_file, "r"); if (pidfile) { ret = fscanf (pidfile, "%d", &pid); if (ret <= 0) { gf_log (GF_NLM, GF_LOG_WARNING, "unable to get pid of " - "rpc.statd"); + "rpc.statd from %s ", GF_RPC_STATD_PIDFILE); ret = runcmd ("killall", "-9", "rpc.statd", NULL); } else kill (pid, SIGKILL); fclose (pidfile); } else { - gf_log (GF_NLM, GF_LOG_WARNING, "opening the pid file of " - "rpc.statd failed (%s)", strerror (errno)); + gf_log (GF_NLM, GF_LOG_WARNING, "opening %s of " + "rpc.statd failed (%s)", pid_file, strerror (errno)); /* if ret == -1, do nothing - case either statd was not * running or was running in valgrind mode */ ret = runcmd ("killall", "-9", "rpc.statd", NULL); } - ret = unlink ("/var/run/rpc.statd.pid"); + ret = unlink (GF_RPC_STATD_PIDFILE); if (ret == -1 && errno != ENOENT) { - gf_log (GF_NLM, GF_LOG_ERROR, "unable to unlink rpc.statd"); + gf_log (GF_NLM, GF_LOG_ERROR, "unable to unlink %s", pid_file); goto err; } - ret = runcmd ("/sbin/rpc.statd", NULL); + ret = runcmd (nfs->rpc_statd, NULL); if (ret == -1) { - gf_log (GF_NLM, GF_LOG_ERROR, "unable to start rpc.statd"); + gf_log (GF_NLM, GF_LOG_ERROR, "unable to start %s", + nfs->rpc_statd); goto err; } + + pthread_create (&thr, NULL, nsm_thread, (void*)NULL); timeout.tv_sec = nlm_grace_period; -- cgit From 9819fcedf10f1430d4969c86e6df4dfe975b7dcf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 22 Apr 2014 13:27:35 -0700 Subject: rpcgen: Remove autogenerated files instead build on demand Avoid modifying autogenerated files and keeping them in repository - autogenerate them on demand from ".x" files Change-Id: I2cdb1fe9b99768ceb80a8cb100fa00bd1d8fe2c6 BUG: 1090807 Signed-off-by: Harshavardhana Reviewed-on: http://review.gluster.org/7526 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Anand Avati --- xlators/nfs/server/src/nlm4.c | 45 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'xlators/nfs/server/src/nlm4.c') diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index d0caa97c2..042cfeba1 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -33,7 +33,6 @@ #include "nfs-generics.h" #include "rpc-clnt.h" #include "nsm-xdr.h" -#include "nlmcbk-xdr.h" #include "run.h" #include #include @@ -157,9 +156,9 @@ nlm4_prep_nlm4_testargs (nlm4_testargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes) { memset (args, 0, sizeof (*args)); - args->alock.fh.n_bytes = (void *)fh; - args->alock.oh.n_bytes = (void *)oh; - args->cookie.n_bytes = (void *)cookiebytes; + args->alock.fh.nlm4_netobj_val = (void *)fh; + args->alock.oh.nlm4_netobj_val = (void *)oh; + args->cookie.nlm4_netobj_val = (void *)cookiebytes; } void @@ -167,9 +166,9 @@ nlm4_prep_nlm4_lockargs (nlm4_lockargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes) { memset (args, 0, sizeof (*args)); - args->alock.fh.n_bytes = (void *)fh; - args->alock.oh.n_bytes = (void *)oh; - args->cookie.n_bytes = (void *)cookiebytes; + args->alock.fh.nlm4_netobj_val = (void *)fh; + args->alock.oh.nlm4_netobj_val = (void *)oh; + args->cookie.nlm4_netobj_val = (void *)cookiebytes; } void @@ -177,9 +176,9 @@ nlm4_prep_nlm4_cancargs (nlm4_cancargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes) { memset (args, 0, sizeof (*args)); - args->alock.fh.n_bytes = (void *)fh; - args->alock.oh.n_bytes = (void *)oh; - args->cookie.n_bytes = (void *)cookiebytes; + args->alock.fh.nlm4_netobj_val = (void *)fh; + args->alock.oh.nlm4_netobj_val = (void *)oh; + args->cookie.nlm4_netobj_val = (void *)cookiebytes; } void @@ -187,9 +186,9 @@ nlm4_prep_nlm4_unlockargs (nlm4_unlockargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes) { memset (args, 0, sizeof (*args)); - args->alock.fh.n_bytes = (void *)fh; - args->alock.oh.n_bytes = (void *)oh; - args->cookie.n_bytes = (void *)cookiebytes; + args->alock.fh.nlm4_netobj_val = (void *)fh; + args->alock.oh.nlm4_netobj_val = (void *)oh; + args->cookie.nlm4_netobj_val = (void *)cookiebytes; } void @@ -197,9 +196,9 @@ nlm4_prep_shareargs (nlm4_shareargs *args, struct nfs3_fh *fh, nlm4_lkowner_t *oh, char *cookiebytes) { memset (args, 0, sizeof (*args)); - args->share.fh.n_bytes = (void *)fh; - args->share.oh.n_bytes = (void *)oh; - args->cookie.n_bytes = (void *)cookiebytes; + args->share.fh.nlm4_netobj_val = (void *)fh; + args->share.oh.nlm4_netobj_val = (void *)oh; + args->cookie.nlm4_netobj_val = (void *)cookiebytes; } void @@ -210,22 +209,22 @@ nlm4_prep_freeallargs (nlm4_freeallargs *args, nlm4_lkowner_t *oh) } void -nlm_copy_lkowner (gf_lkowner_t *dst, netobj *src) +nlm_copy_lkowner (gf_lkowner_t *dst, nlm4_netobj *src) { - dst->len = src->n_len; - memcpy (dst->data, src->n_bytes, dst->len); + dst->len = src->nlm4_netobj_len; + memcpy (dst->data, src->nlm4_netobj_val, dst->len); } int -nlm_is_oh_same_lkowner (gf_lkowner_t *a, netobj *b) +nlm_is_oh_same_lkowner (gf_lkowner_t *a, nlm4_netobj *b) { if (!a || !b) { gf_log (GF_NLM, GF_LOG_ERROR, "invalid args"); return -1; } - return (a->len == b->n_len && - !memcmp (a->data, b->n_bytes, a->len)); + return (a->len == b->nlm4_netobj_len && + !memcmp (a->data, b->nlm4_netobj_val, a->len)); } nlm4_stats @@ -653,7 +652,7 @@ err: } int -nlm4_generic_reply (rpcsvc_request_t *req, netobj cookie, nlm4_stats stat) +nlm4_generic_reply (rpcsvc_request_t *req, nlm4_netobj cookie, nlm4_stats stat) { nlm4_res res; -- cgit From 3b40a553f466aa3d671efc2ae892215bebaa4c7b Mon Sep 17 00:00:00 2001 From: Santosh Kumar Pradhan Date: Thu, 24 Apr 2014 12:55:05 +0530 Subject: gNFS: Log properly for pmap_getport() fail in NLM In NLM callback path, if pmap_getport() FAILs, it just log the error message saying "Is firewall running on the client". It may happen that RPC services are not running e.g. "rpcbind" is not running or nlockmgr (NLM) is not registered with portmapper which all can be checked using "rpcinfo -p" command. FIX: Modify the log message to include the later case mentioned above. Change-Id: If422275b2ab59d1e974a6caa37132f31e9a34329 BUG: 1090782 Signed-off-by: Santosh Kumar Pradhan Reviewed-on: http://review.gluster.org/7544 Reviewed-by: Niels de Vos Tested-by: Gluster Build System Reviewed-by: Rajesh Joseph --- xlators/nfs/server/src/nlm4.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'xlators/nfs/server/src/nlm4.c') diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index 042cfeba1..4d0083fe2 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -974,8 +974,10 @@ nlm4_establish_callback (void *csarg) NLM_V4, IPPROTO_TCP); if (port == 0) { - gf_log (GF_NLM, GF_LOG_ERROR, "Unable to get NLM port of the " - "client. Is the firewall running on client?"); + gf_log (GF_NLM, GF_LOG_ERROR, + "Unable to get NLM port of the client." + " Is the firewall running on client?" + " OR Are RPC services running (rpcinfo -p)?"); goto err; } -- cgit