diff options
author | Shehjar Tikoo <shehjart@gluster.com> | 2010-11-03 06:35:29 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-11-03 21:36:59 -0700 |
commit | 86a1ef81527da5b9eb11ba3dc361c1c4ca291ca8 (patch) | |
tree | 216d0952a21a446e6e68bc051ff4ad81027801d8 /xlators/nfs/lib | |
parent | b16c0784da56fc2e7d660753882ec63587e2049e (diff) |
nfs: Introduce rpc.register-with-portmap to disable portmap registration
For systems that need to run multiple nfs servers, we need to prevent
more than one from registering with portmap service. Use this option
to turn off portmap registration for Gluster NFS.
Portmap registration is on by default.
Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1743 (XenServer is not compatible with GlusterNFS)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1743
Diffstat (limited to 'xlators/nfs/lib')
-rw-r--r-- | xlators/nfs/lib/src/rpcsvc.c | 47 | ||||
-rw-r--r-- | xlators/nfs/lib/src/rpcsvc.h | 2 |
2 files changed, 44 insertions, 5 deletions
diff --git a/xlators/nfs/lib/src/rpcsvc.c b/xlators/nfs/lib/src/rpcsvc.c index 6a99514cb..112bf6326 100644 --- a/xlators/nfs/lib/src/rpcsvc.c +++ b/xlators/nfs/lib/src/rpcsvc.c @@ -117,8 +117,39 @@ free_stg: int nfs_rpcsvc_init_options (rpcsvc_t *svc, dict_t *options) { + char *optstr = NULL; + int ret = -1; + + if ((!svc) || (!options)) + return -1; + svc->memfactor = RPCSVC_DEFAULT_MEMFACTOR; - return 0; + + svc->register_portmap = _gf_true; + if (dict_get (options, "rpc.register-with-portmap")) { + ret = dict_get_str (options, "rpc.register-with-portmap", + &optstr); + if (ret < 0) { + gf_log (GF_RPCSVC, GF_LOG_ERROR, "Failed to parse " + "dict"); + goto out; + } + + ret = gf_string2boolean (optstr, &svc->register_portmap); + if (ret < 0) { + gf_log (GF_RPCSVC, GF_LOG_ERROR, "Failed to parse bool " + "string"); + goto out; + } + } + + if (!svc->register_portmap) + gf_log (GF_RPCSVC, GF_LOG_DEBUG, "Portmap registration " + "disabled"); + + ret = 0; +out: + return ret; } @@ -2614,11 +2645,14 @@ err: /* Register the program with the local portmapper service. */ int -nfs_rpcsvc_program_register_portmap (rpcsvc_program_t *newprog) +nfs_rpcsvc_program_register_portmap (rpcsvc_t *svc, rpcsvc_program_t *newprog) { if (!newprog) return -1; + if (!svc->register_portmap) + return 0; + if (!(pmap_set(newprog->prognum, newprog->progver, IPPROTO_TCP, newprog->progport))) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "Could not register with" @@ -2631,11 +2665,14 @@ nfs_rpcsvc_program_register_portmap (rpcsvc_program_t *newprog) int -nfs_rpcsvc_program_unregister_portmap (rpcsvc_program_t *prog) +nfs_rpcsvc_program_unregister_portmap (rpcsvc_t *svc, rpcsvc_program_t *prog) { if (!prog) return -1; + if (!svc->register_portmap) + return 0; + if (!(pmap_unset(prog->prognum, prog->progver))) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "Could not unregister with" " portmap"); @@ -2704,7 +2741,7 @@ nfs_rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t program) goto free_prog; } - ret = nfs_rpcsvc_program_register_portmap (newprog); + ret = nfs_rpcsvc_program_register_portmap (svc, newprog); if (ret == -1) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "portmap registration of" " program failed"); @@ -2753,7 +2790,7 @@ nfs_rpcsvc_program_unregister (rpcsvc_t *svc, rpcsvc_program_t prog) return -1; /* TODO: De-init the listening connection for this program. */ - ret = nfs_rpcsvc_program_unregister_portmap (&prog); + ret = nfs_rpcsvc_program_unregister_portmap (svc, &prog); if (ret == -1) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "portmap unregistration of" " program failed"); diff --git a/xlators/nfs/lib/src/rpcsvc.h b/xlators/nfs/lib/src/rpcsvc.h index 7f73520d4..5a669cf83 100644 --- a/xlators/nfs/lib/src/rpcsvc.h +++ b/xlators/nfs/lib/src/rpcsvc.h @@ -520,6 +520,8 @@ typedef struct rpc_svc_state { int allow_insecure; glusterfs_ctx_t *ctx; + + gf_boolean_t register_portmap; } rpcsvc_t; |