Patchwork [BUG:1743,3/3] nfs: Support nfs.port to allow changing nfs port numbers

login
register
Submitter Shehjar Tikoo
Date 2010-11-08 11:55:18
Message ID <1289217318-1872-3-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/5653/
State Accepted
Headers show

Comments

Shehjar Tikoo - 2010-11-08 11:55:18
From: Shehjar Tikoo <shehjart@gluster.com>


Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 xlators/nfs/server/src/nfs.c |   25 +++++++++++++++++++++++++
 xlators/nfs/server/src/nfs.h |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)

Patch

diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 3dbb0bc..ec939a5 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -120,6 +120,8 @@  nfs_init_versions (struct nfs_state *nfs, xlator_t *this)
                         goto err;
                 }
 
+                if (nfs->override_portnum)
+                        prog->progport = nfs->override_portnum;
                 gf_log (GF_NFS, GF_LOG_DEBUG, "Starting program: %s",
                         prog->progname);
                 ret = nfs_rpcsvc_program_register (nfs->rpcsvc, *prog);
@@ -539,6 +541,24 @@  nfs_init_state (xlator_t *this)
                 if (boolt == _gf_true)
                         nfs->enable_ino32 = 1;
         }
+
+        nfs->override_portnum = 0;
+        if (dict_get (this->options, "nfs.port")) {
+                ret = dict_get_str (this->options, "nfs.port",
+                                    &optstr);
+                if (ret < 0) {
+                        gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict");
+                        goto free_foppool;
+                }
+
+                ret = gf_string2uint (optstr, &nfs->override_portnum);
+                if (ret < 0) {
+                        gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse uint "
+                                "string");
+                        goto free_foppool;
+                }
+        }
+
         this->private = (void *)nfs;
         INIT_LIST_HEAD (&nfs->versions);
 
@@ -865,6 +885,11 @@  struct volume_options options[] = {
                          "portmap service. Use this option to turn off portmap "
                          "registration for Gluster NFS. On by default"
         },
+        { .key  = {"nfs.port"},
+          .type = GF_OPTION_TYPE_INT,
+          .description = "Use this option on systems that need Gluster NFS to "
+                         "be associated with a non-default port number."
+        },
 	{ .key  = {NULL} },
 };
 
diff --git a/xlators/nfs/server/src/nfs.h b/xlators/nfs/server/src/nfs.h
index 8cbcf63..6d7ed2f 100644
--- a/xlators/nfs/server/src/nfs.h
+++ b/xlators/nfs/server/src/nfs.h
@@ -74,6 +74,7 @@  struct nfs_state {
         int                     subvols_started;
         int                     dynamicvolumes;
         int                     enable_ino32;
+        unsigned int            override_portnum;
 };
 
 #define gf_nfs_dvm_on(nfsstt)   (((struct nfs_state *)nfsstt)->dynamicvolumes == GF_NFS_DVM_ON)