Patchwork [BUG:2093,1/3] nfs: Export subvolumes on per-subvolume CHILD-UP

login
register
Submitter Shehjar Tikoo
Date 2010-11-25 09:41:09
Message ID <1290678071-14424-1-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/5782/
State Accepted
Headers show

Comments

Shehjar Tikoo - 2010-11-25 09:41:09
From: Shehjar Tikoo <shehjart@gluster.com>

..so that nfs clients can mount an UP subvolume even if other subvolumes
havent come up yet.

This was a problem because nfs was waiting for all children to receive
CHILD-UP before exporting any subvolume.

Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 xlators/nfs/server/src/mount3.c |   20 ++++++++++++++++++++
 xlators/nfs/server/src/nfs.c    |   20 +++++++-------------
 xlators/nfs/server/src/nfs.h    |    2 ++
 3 files changed, 29 insertions(+), 13 deletions(-)

Patch

diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index 2e4a739..25754a3 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -37,6 +37,7 @@ 
 #include "locking.h"
 #include "iatt.h"
 #include "nfs-mem-types.h"
+#include "nfs.h"
 
 
 #include <errno.h>
@@ -736,6 +737,7 @@  mnt3svc_mnt (rpcsvc_request_t *req)
         struct mount3_state     *ms = NULL;
         mountstat3              mntstat = MNT3ERR_SERVERFAULT;
         struct mnt3_export      *exp = NULL;
+        struct nfs_state        *nfs = NULL;
 
         if (!req)
                 return -1;
@@ -766,6 +768,15 @@  mnt3svc_mnt (rpcsvc_request_t *req)
                 goto mnterr;
         }
 
+        nfs = (struct nfs_state *)ms->nfsx->private;
+        if (!nfs_subvolume_started (nfs, exp->vol)) {
+                gf_log (GF_MNT, GF_LOG_DEBUG, "Volume %s not started",
+                        exp->vol->name);
+                ret = -1;
+                mntstat = MNT3ERR_NOENT;
+                goto mnterr;
+        }
+
         ret = mnt3_check_client_net (ms, req, exp->vol);
         if (ret == RPCSVC_AUTH_REJECT) {
                 mntstat = MNT3ERR_ACCES;
@@ -1150,11 +1161,20 @@  mnt3_xlchildren_to_exports (rpcsvc_t *svc, struct mount3_state *ms)
         int                     ret = -1;
         char                    *addrstr = NULL;
         struct mnt3_export      *ent = NULL;
+        struct nfs_state        *nfs = NULL;
 
         if ((!ms) || (!svc))
                 return NULL;
 
+        nfs = (struct nfs_state *)ms->nfsx->private;
         list_for_each_entry(ent, &ms->exportlist, explist) {
+
+                /* If volume is not started yet, do not list it for tools like
+                 * showmount.
+                 */
+                if (!nfs_subvolume_started (nfs, ent->vol))
+                        continue;
+
                 namelen = strlen (ent->expname) + 1;
                 elist = GF_CALLOC (1, sizeof (*elist), gf_nfs_mt_exportnode);
                 if (!elist) {
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 5f116a3..001df8e 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -639,6 +639,13 @@  init (xlator_t *this) {
                 goto err;
         }
 
+        ret = nfs_init_versions (nfs, this);
+        if (ret == -1) {
+                gf_log (GF_NFS, GF_LOG_CRITICAL, "Failed to initialize "
+                        "protocols");
+                goto err;
+        }
+
         ret = 0;
 err:
         if (ret == 0)
@@ -653,7 +660,6 @@  notify (xlator_t *this, int32_t event, void *data, ...)
 {
         struct nfs_state        *nfs = NULL;
         xlator_t                *subvol = NULL;
-        int                     ret = -1;
 
         nfs = (struct nfs_state *)this->private;
         subvol = (xlator_t *)data;
@@ -662,21 +668,9 @@  notify (xlator_t *this, int32_t event, void *data, ...)
                 event);
         switch (event)
         {
-                case GF_EVENT_CHILD_CONNECTING:
                 case GF_EVENT_CHILD_UP:
                 {
                         nfs_startup_subvolume (this, subvol);
-                        if ((nfs->upsubvols == nfs->allsubvols) &&
-                            (!nfs->subvols_started)) {
-                                nfs->subvols_started = 1;
-                                gf_log (GF_NFS, GF_LOG_TRACE, "All children up,"
-                                " starting RPC");
-                                ret = nfs_init_versions (nfs, this);
-                                if (ret == -1)
-                                        gf_log (GF_NFS, GF_LOG_CRITICAL,
-                                                "Failed to initialize "
-                                                "protocols");
-                        }
                         break;
                 }
 
diff --git a/xlators/nfs/server/src/nfs.h b/xlators/nfs/server/src/nfs.h
index e7a023c..7b93cd5 100644
--- a/xlators/nfs/server/src/nfs.h
+++ b/xlators/nfs/server/src/nfs.h
@@ -106,4 +106,6 @@  nfs_user_create (nfs_user_t *newnfu, uid_t uid, gid_t gid, gid_t *auxgids,
 extern void
 nfs_request_user_init (nfs_user_t *nfu, rpcsvc_request_t *req);
 
+extern int
+nfs_subvolume_started (struct nfs_state *nfs, xlator_t *xl);
 #endif