Patchwork [BUG:2051,1/3] nfs3: More robust root gfid checks

login
register
Submitter Shehjar Tikoo
Date 2010-11-03 12:05:27
Message ID <1288785929-516-1-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/5633/
State Accepted
Headers show

Comments

Shehjar Tikoo - 2010-11-03 12:05:27
From: Shehjar Tikoo <shehjart@gluster.com>


Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 xlators/nfs/server/src/nfs3-fh.c      |   10 ++++++----
 xlators/nfs/server/src/nfs3-helpers.c |    3 ++-
 xlators/nfs/server/src/nfs3.c         |    2 ++
 3 files changed, 10 insertions(+), 5 deletions(-)

Patch

diff --git a/xlators/nfs/server/src/nfs3-fh.c b/xlators/nfs/server/src/nfs3-fh.c
index 2239148..49236d6 100644
--- a/xlators/nfs/server/src/nfs3-fh.c
+++ b/xlators/nfs/server/src/nfs3-fh.c
@@ -68,10 +68,12 @@  nfs3_fh_build_indexed_root_fh (xlator_list_t *cl, xlator_t *xl)
 {
         struct nfs3_fh  fh = {{0}, };
         struct iatt     buf = {0, };
+        uuid_t          root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+
         if ((!cl) || (!xl))
                 return fh;
 
-        buf.ia_gfid[15] = 1;
+        uuid_copy (buf.ia_gfid, root);
         nfs3_fh_init (&fh, &buf);
         fh.exportid [15] = nfs_xlator_to_xlid (cl, xl);
 
@@ -84,8 +86,9 @@  nfs3_fh_build_uuid_root_fh (uuid_t volumeid)
 {
         struct nfs3_fh  fh = {{0}, };
         struct iatt     buf = {0, };
+        uuid_t          root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
 
-        buf.ia_gfid[15] = 1;
+        uuid_copy (buf.ia_gfid, root);
         nfs3_fh_init (&fh, &buf);
         uuid_copy (fh.exportid, volumeid);
 
@@ -96,12 +99,11 @@  nfs3_fh_build_uuid_root_fh (uuid_t volumeid)
 int
 nfs3_fh_is_root_fh (struct nfs3_fh *fh)
 {
-        uuid_t  rootgfid = {0, 1};
+        uuid_t  rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
 
         if (!fh)
                 return 0;
 
-        rootgfid[15] = 1;
         if (uuid_compare (fh->gfid, rootgfid) == 0)
                 return 1;
 
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index 298a5c8..cff029d 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -94,12 +94,13 @@  struct nfs3stat_strerror nfs3stat_strerror_table[] = {
 uint64_t
 nfs3_iatt_gfid_to_ino (struct iatt *buf)
 {
+        uuid_t          gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
         uint64_t        ino = 0;
 
         if (!buf)
                 return 0;
 
-        if ((buf->ia_ino != 1) && (buf->ia_gfid[15] != 1)) {
+        if ((buf->ia_ino != 1) && (uuid_compare (buf->ia_gfid, gfid) != 0)) {
                 if (gf_nfs_enable_ino32()) {
                         ino = (uint32_t )nfs_hash_gfid (buf->ia_gfid);
                         goto hashout;
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
index 742c63a..d142a31 100644
--- a/xlators/nfs/server/src/nfs3.c
+++ b/xlators/nfs/server/src/nfs3.c
@@ -244,12 +244,14 @@  out:
 #define nfs3_funge_solaris_zerolen_fh(nfs3st, fhd, enam, nfsst, erl)    \
         do {                                                            \
                 xlator_t        *fungexl = NULL;                        \
+                uuid_t          zero = {0, };                           \
                 fungexl =nfs_mntpath_to_xlator ((nfs3st)->exportslist,enam);\
                 if (!fungexl) {                                         \
                         (nfsst) = NFS3ERR_NOENT;                        \
                         goto erl;                                       \
                 }                                                       \
                                                                         \
+                uuid_copy ((fhd)->gfid, zero);                          \
                 (fhd)->gfid[15] = 1;                                    \
                 (enam) = NULL;                                          \
                 if ((gf_nfs_dvm_off (nfs_state (nfs3st->nfsx))))        \