summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server
diff options
context:
space:
mode:
authorHarshavardhana <harsha@harshavardhana.net>2014-04-17 15:54:34 -0700
committerAnand Avati <avati@redhat.com>2014-04-24 14:41:48 -0700
commita3cb38e3edf005bef73da4c9cfd958474a14d50f (patch)
treea406029332a9eb096c14d441160bb670a42df8cb /xlators/nfs/server
parent9c13471b109587a639662fc690384285bee02bc6 (diff)
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 <harsha@harshavardhana.net> Signed-off-by: Dennis Schafroth <dennis@schafroth.com> Tested-by: Harshavardhana <harsha@harshavardhana.net> Tested-by: Dennis Schafroth <dennis@schafroth.com> Reviewed-on: http://review.gluster.org/7503 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/nfs/server')
-rw-r--r--xlators/nfs/server/src/nfs-fops.c11
-rw-r--r--xlators/nfs/server/src/nfs.c70
-rw-r--r--xlators/nfs/server/src/nfs.h2
-rw-r--r--xlators/nfs/server/src/nfs3-helpers.c4
-rw-r--r--xlators/nfs/server/src/nfs3.c6
-rw-r--r--xlators/nfs/server/src/nlm4.c38
-rw-r--r--xlators/nfs/server/src/nlm4.h9
7 files changed, 110 insertions, 30 deletions
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index b91f73a5378..56d4cba47c6 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -38,20 +38,25 @@ nfs_fix_groups (xlator_t *this, call_stack_t *root)
struct passwd mypw;
char mystrs[1024];
struct passwd *result;
+#ifdef GF_DARWIN_HOST_OS
+ /* BSD/DARWIN does not correctly uses gid_t in getgrouplist */
+ int mygroups[GF_MAX_AUX_GROUPS];
+#else
gid_t mygroups[GF_MAX_AUX_GROUPS];
+#endif
int ngroups;
int i;
int max_groups;
struct nfs_state *priv = this->private;
const gid_list_t *agl;
- gid_list_t gl;
+ gid_list_t gl;
if (!priv->server_aux_gids) {
return;
}
- /* RPC enforces the GF_AUTH_GLUSTERFS_MAX_GROUPS limit */
- max_groups = GF_AUTH_GLUSTERFS_MAX_GROUPS(root->lk_owner.len);
+ /* RPC enforces the GF_AUTH_GLUSTERFS_MAX_GROUPS limit */
+ max_groups = GF_AUTH_GLUSTERFS_MAX_GROUPS(root->lk_owner.len);
agl = gid_cache_lookup(&priv->gid_cache, root->uid, 0, 0);
if (agl) {
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index d962663bafa..918e8631255 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -35,12 +35,16 @@
#include "options.h"
#include "acl3.h"
#include "rpc-drc.h"
+#include "syscall.h"
#define STRINGIFY(val) #val
#define TOSTRING(val) STRINGIFY(val)
#define OPT_SERVER_AUX_GIDS "nfs.server-aux-gids"
#define OPT_SERVER_GID_CACHE_TIMEOUT "nfs.server.aux-gid-timeout"
+#define OPT_SERVER_RPC_STATD "nfs.rpc-statd"
+#define OPT_SERVER_RPC_STATD_PIDFILE "nfs.rpc-statd-pidfile"
+#define OPT_SERVER_RPC_STATD_NOTIFY_PIDFILE "nfs.rpc-statd-notify-pidfile"
/* TODO: DATADIR should be based on configure's $(localstatedir) */
#define DATADIR "/var/lib/glusterd"
@@ -942,10 +946,14 @@ nfs_init_state (xlator_t *this)
goto free_foppool;
}
}
+ GF_OPTION_INIT (OPT_SERVER_RPC_STATD, nfs->rpc_statd, path, free_foppool);
+
+ GF_OPTION_INIT (OPT_SERVER_RPC_STATD_PIDFILE, nfs->rpc_statd_pid_file, path, free_foppool);
GF_OPTION_INIT (OPT_SERVER_AUX_GIDS, nfs->server_aux_gids,
bool, free_foppool);
- GF_OPTION_INIT (OPT_SERVER_GID_CACHE_TIMEOUT, nfs->server_aux_gids_max_age,
+ GF_OPTION_INIT (OPT_SERVER_GID_CACHE_TIMEOUT,
+ nfs->server_aux_gids_max_age,
uint32, free_foppool);
if (gid_cache_init(&nfs->gid_cache, nfs->server_aux_gids_max_age) < 0) {
@@ -953,9 +961,17 @@ nfs_init_state (xlator_t *this)
goto free_foppool;
}
- if (stat("/sbin/rpc.statd", &stbuf) == -1) {
- gf_log (GF_NFS, GF_LOG_WARNING, "/sbin/rpc.statd not found. "
- "Disabling NLM");
+ ret = sys_access (nfs->rpc_statd, X_OK);
+ if (ret) {
+ gf_log (GF_NFS, GF_LOG_WARNING, "%s not enough permissions to"
+ " access. Disabling NLM", nfs->rpc_statd);
+ nfs->enable_nlm = _gf_false;
+ }
+
+ ret = sys_stat (nfs->rpc_statd, &stbuf);
+ if (ret || !S_ISREG (stbuf.st_mode)) {
+ gf_log (GF_NFS, GF_LOG_WARNING, "%s not a regular file."
+ " Disabling NLM", nfs->rpc_statd);
nfs->enable_nlm = _gf_false;
}
@@ -968,8 +984,8 @@ nfs_init_state (xlator_t *this)
}
ret = rpcsvc_set_outstanding_rpc_limit (nfs->rpcsvc,
- this->options,
- RPCSVC_DEF_NFS_OUTSTANDING_RPC_LIMIT);
+ this->options,
+ RPCSVC_DEF_NFS_OUTSTANDING_RPC_LIMIT);
if (ret < 0) {
gf_log (GF_NFS, GF_LOG_ERROR,
"Failed to configure outstanding-rpc-limit");
@@ -1023,7 +1039,8 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options)
{
int ret = 0;
int keyindx = 0;
- char *optstr = NULL;
+ char *rmtab = NULL;
+ char *rpc_statd = NULL;
gf_boolean_t optbool;
uint32_t optuint32;
struct nfs_state *nfs = NULL;
@@ -1068,19 +1085,36 @@ nfs_reconfigure_state (xlator_t *this, dict_t *options)
goto out;
}
+ /* reconfig nfs.rpc-statd... */
+ rpc_statd = GF_RPC_STATD_PROG;
+ if (dict_get (options, OPT_SERVER_RPC_STATD_PIDFILE)) {
+ ret = dict_get_str (options, "nfs.rpc-statd", &rpc_statd);
+ if (ret < 0) {
+ gf_log (GF_NFS, GF_LOG_ERROR, "Failed to read "
+ "reconfigured option: nfs.rpc-statd");
+ goto out;
+ }
+ }
+
+ if (strcmp(nfs->rpc_statd, rpc_statd) != 0) {
+ gf_log (GF_NFS, GF_LOG_INFO,
+ "Reconfiguring nfs.rpc-statd needs NFS restart");
+ goto out;
+ }
+
/* reconfig nfs.mount-rmtab */
- optstr = NFS_DATADIR "/rmtab";
+ rmtab = NFS_DATADIR "/rmtab";
if (dict_get (options, "nfs.mount-rmtab")) {
- ret = dict_get_str (options, "nfs.mount-rmtab", &optstr);
+ ret = dict_get_str (options, "nfs.mount-rmtab", &rmtab);
if (ret < 0) {
gf_log (GF_NFS, GF_LOG_ERROR, "Failed to read "
"reconfigured option: nfs.mount-rmtab");
goto out;
}
- gf_path_strip_trailing_slashes (optstr);
+ gf_path_strip_trailing_slashes (rmtab);
}
- if (strcmp (nfs->rmtab, optstr) != 0) {
- mount_rewrite_rmtab (nfs->mstate, optstr);
+ if (strcmp (nfs->rmtab, rmtab) != 0) {
+ mount_rewrite_rmtab (nfs->mstate, rmtab);
gf_log (GF_NFS, GF_LOG_INFO,
"Reconfigured nfs.mount-rmtab path: %s",
nfs->rmtab);
@@ -1819,6 +1853,18 @@ struct volume_options options[] = {
"storage, all GlusterFS servers will update and "
"output (with 'showmount') the same list."
},
+ { .key = {OPT_SERVER_RPC_STATD},
+ .type = GF_OPTION_TYPE_PATH,
+ .default_value = GF_RPC_STATD_PROG,
+ .description = "The executable of RPC statd utility. "
+ "Defaults to " GF_RPC_STATD_PROG
+ },
+ { .key = {OPT_SERVER_RPC_STATD_PIDFILE},
+ .type = GF_OPTION_TYPE_PATH,
+ .default_value = GF_RPC_STATD_PIDFILE,
+ .description = "The pid file of RPC statd utility. "
+ "Defaults to " GF_RPC_STATD_PIDFILE
+ },
{ .key = {OPT_SERVER_AUX_GIDS},
.type = GF_OPTION_TYPE_BOOL,
.default_value = "off",
diff --git a/xlators/nfs/server/src/nfs.h b/xlators/nfs/server/src/nfs.h
index 00c7f80469c..fc745fbbdc4 100644
--- a/xlators/nfs/server/src/nfs.h
+++ b/xlators/nfs/server/src/nfs.h
@@ -86,6 +86,8 @@ struct nfs_state {
gid_cache_t gid_cache;
uint32_t generation;
gf_boolean_t register_portmap;
+ char *rpc_statd;
+ char *rpc_statd_pid_file;
};
struct nfs_inode_ctx {
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index 9059fc341d9..f67cccf1a9b 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -85,7 +85,7 @@ struct nfs3stat_strerror nfs3stat_strerror_table[] = {
{ NFS3ERR_SERVERFAULT, "Error occurred on the server or IO Error" },
{ NFS3ERR_BADTYPE, "Type not supported by the server" },
{ NFS3ERR_JUKEBOX, "Cannot complete server initiated request" },
- { -1, "IO Error" },
+ { NFS3ERR_END_OF_LIST, "IO Error" },
};
@@ -543,7 +543,7 @@ char *
nfsstat3_strerror(int stat)
{
int i;
- for(i = 0; nfs3stat_strerror_table[i].stat != -1; i++) {
+ for(i = 0; nfs3stat_strerror_table[i].stat != NFS3ERR_END_OF_LIST ; i++) {
if (nfs3stat_strerror_table[i].stat == stat)
return nfs3stat_strerror_table[i].strerror;
}
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
index 0fea135c784..6361f9e20aa 100644
--- a/xlators/nfs/server/src/nfs3.c
+++ b/xlators/nfs/server/src/nfs3.c
@@ -5186,7 +5186,7 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options)
goto err;
}
- ret = gf_string2bytesize (optstr, &size64);
+ ret = gf_string2uint64 (optstr, &size64);
if (ret == -1) {
gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format"
" option: nfs3.read-size");
@@ -5209,7 +5209,7 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options)
goto err;
}
- ret = gf_string2bytesize (optstr, &size64);
+ ret = gf_string2uint64 (optstr, &size64);
if (ret == -1) {
gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format"
" option: nfs3.write-size");
@@ -5232,7 +5232,7 @@ nfs3_init_options (struct nfs3_state *nfs3, dict_t *options)
goto err;
}
- ret = gf_string2bytesize (optstr, &size64);
+ ret = gf_string2uint64 (optstr, &size64);
if (ret == -1) {
gf_log (GF_NFS3, GF_LOG_ERROR, "Failed to format"
" option: nfs3.readdir-size");
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index c186537ea0c..d0caa97c287 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;
diff --git a/xlators/nfs/server/src/nlm4.h b/xlators/nfs/server/src/nlm4.h
index 9b5d5408184..5b629611088 100644
--- a/xlators/nfs/server/src/nlm4.h
+++ b/xlators/nfs/server/src/nlm4.h
@@ -34,6 +34,15 @@
/* Registered with portmap */
#define GF_NLM4_PORT 38468
#define GF_NLM GF_NFS"-NLM"
+#ifdef GF_DARWIN_HOST_OS
+#define GF_RPC_STATD_PROG "/usr/sbin/rpc.statd"
+#define GF_RPC_STATD_PIDFILE "/var/run/statd.pid"
+#define GF_SM_NOTIFY_PIDFILE "/var/run/statd.notify.pid"
+#else
+#define GF_RPC_STATD_PROG "/sbin/rpc.stat"
+#define GF_RPC_STATD_PIDFILE "/var/run/rpc.statd.pid"
+#define GF_SM_NOTIFY_PIDFILE "/var/run/sm-notify.pid"
+#endif
extern rpcsvc_program_t *
nlm4svc_init (xlator_t *nfsx);