diff options
Diffstat (limited to 'xlators/nfs/server/src/nfs.c')
| -rw-r--r-- | xlators/nfs/server/src/nfs.c | 70 | 
1 files changed, 58 insertions, 12 deletions
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",  | 
