summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-06-25 19:37:09 -0700
committerAnand Avati <avati@redhat.com>2012-07-04 00:18:04 -0700
commit34a06d3c13aba1a22680e070b08284f2d7c69890 (patch)
treebeaaaed313d305900fdb4363b97e24d0cf593992
parent5a3d849b8563067d35c1422e43e605bd9533f3c2 (diff)
nfs: make NFS filehandles deterministic
The NFS3 file handles now includes just the bare minimum of (ident, exportid, gfid) and removes legacy 'variable' members which are unnecessary since the introduction of GFID backend Change-Id: Iff6e4435d170074b18d208742b48e79b130e2a4d BUG: 835336 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.com/3616 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--xlators/nfs/server/src/nfs3-fh.c138
-rw-r--r--xlators/nfs/server/src/nfs3-fh.h19
2 files changed, 6 insertions, 151 deletions
diff --git a/xlators/nfs/server/src/nfs3-fh.c b/xlators/nfs/server/src/nfs3-fh.c
index f41c3f2f1e8..eb822392476 100644
--- a/xlators/nfs/server/src/nfs3-fh.c
+++ b/xlators/nfs/server/src/nfs3-fh.c
@@ -59,7 +59,6 @@ nfs3_fh_init (struct nfs3_fh *fh, struct iatt *buf)
fh->ident[0] = GF_NFSFH_IDENT0;
fh->ident[1] = GF_NFSFH_IDENT1;
- fh->hashcount = 0;
uuid_copy (fh->gfid, buf->ia_gfid);
}
@@ -112,66 +111,6 @@ nfs3_fh_is_root_fh (struct nfs3_fh *fh)
}
-nfs3_hash_entry_t
-nfs3_fh_hash_entry (uuid_t gfid)
-{
- nfs3_hash_entry_t hash = 0;
- int shiftsize = 48;
- uint64_t ino = 0;
- uint64_t gen = 0;
- nfs3_hash_entry_t inomsb = 0;
- nfs3_hash_entry_t inolsb = 0;
- nfs3_hash_entry_t inols23b = 0;
-
- nfs3_hash_entry_t genmsb = 0;
- nfs3_hash_entry_t genlsb = 0;
- nfs3_hash_entry_t genls23b = 0;
-
- memcpy (&ino, &gfid[8], 8);
- hash = ino;
- while (shiftsize != 0) {
- hash ^= (ino >> shiftsize);
- shiftsize -= 16;
- }
-/*
- gf_log ("FILEHANDLE", GF_LOG_TRACE, "INO %"PRIu64, ino);
- gf_log ("FILEHANDLE",GF_LOG_TRACE, "PRI HASH %d", hash);
-*/
- inomsb = (ino >> 56);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inomsb %d", inomsb);
-
- inolsb = ((ino << 56) >> 56);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inolsb %d", inolsb);
-
- inolsb = (inolsb << 8);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inolsb to inomsb %d", inolsb);
- inols23b = ((ino << 40) >> 48);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inols23b %d", inols23b);
-
- inols23b = (inols23b << 8);
-// gf_log ("FILEHDNALE", GF_LOG_TRACE, "inols23b %d", inols23b);
-
- memcpy (&gen, &gfid[0], 8);
- genmsb = (gen >> 56);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inomsb %d", inomsb);
-
- genlsb = ((gen << 56) >> 56);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inolsb %d", inolsb);
-
- genlsb = (genlsb << 8);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inolsb to inomsb %d", inolsb);
-
- genls23b = ((gen << 40) >> 48);
-// gf_log ("FILEHANDLE", GF_LOG_TRACE, "inols23b %d", inols23b);
-
- genls23b = (genls23b << 8);
-// gf_log ("FILEHDNALE", GF_LOG_TRACE, "inols23b %d", inols23b);
-
- hash ^= inolsb ^ inomsb ^ inols23b ^ genmsb ^ genlsb ^ genls23b;
- return hash;
-
-}
-
void
nfs3_fh_to_str (struct nfs3_fh *fh, char *str)
{
@@ -181,30 +120,24 @@ nfs3_fh_to_str (struct nfs3_fh *fh, char *str)
if ((!fh) || (!str))
return;
- sprintf (str, "FH: hashcount %d, exportid %s, gfid %s",
- fh->hashcount, uuid_utoa_r (fh->exportid, exportid),
+ sprintf (str, "FH: exportid %s, gfid %s",
+ uuid_utoa_r (fh->exportid, exportid),
uuid_utoa_r (fh->gfid, gfid));
}
void
nfs3_log_fh (struct nfs3_fh *fh)
{
-// int x = 0;
char gfidstr[512];
char exportidstr[512];
if (!fh)
return;
- gf_log ("nfs3-fh", GF_LOG_TRACE, "filehandle: hashcount %d, exportid "
- "0x%s, gfid 0x%s", fh->hashcount,
+ gf_log ("nfs3-fh", GF_LOG_TRACE, "filehandle: exportid "
+ "0x%s, gfid 0x%s",
uuid_utoa_r (fh->exportid, exportidstr),
uuid_utoa_r (fh->gfid, gfidstr));
-/*
- for (; x < fh->hashcount; ++x)
- gf_log ("FILEHANDLE", GF_LOG_TRACE, "Hash %d: %d", x,
- fh->entryhash[x]);
-*/
}
int
@@ -216,15 +149,6 @@ nfs3_fh_build_parent_fh (struct nfs3_fh *child, struct iatt *newstat,
nfs3_fh_init (newfh, newstat);
uuid_copy (newfh->exportid, child->exportid);
- if (newstat->ia_ino == 1)
- goto done;
-
- newfh->hashcount = child->hashcount - 1;
- memcpy (newfh->entryhash, child->entryhash,
- newfh->hashcount * GF_NFSFH_ENTRYHASH_SIZE);
-
-done:
-// nfs3_log_fh (newfh);
return 0;
}
@@ -246,35 +170,12 @@ int
nfs3_fh_build_child_fh (struct nfs3_fh *parent, struct iatt *newstat,
struct nfs3_fh *newfh)
{
- int hashcount = 0;
- int entry = 0;
-
if ((!parent) || (!newstat) || (!newfh))
return -1;
nfs3_fh_init (newfh, newstat);
uuid_copy (newfh->exportid, parent->exportid);
- newfh->hashcount = parent->hashcount + 1;
- /* Only copy the hashes that are available in the parent file
- * handle. */
- if (parent->hashcount > GF_NFSFH_MAXHASHES)
- hashcount = GF_NFSFH_MAXHASHES;
- else
- hashcount = parent->hashcount;
-
- memcpy (newfh->entryhash, parent->entryhash,
- hashcount * GF_NFSFH_ENTRYHASH_SIZE);
-
- /* Do not insert parent dir hash if there is no space left in the hash
- * array of the child entry. */
- if (newfh->hashcount <= GF_NFSFH_MAXHASHES) {
- entry = newfh->hashcount - 1;
- newfh->entryhash[entry] = nfs3_fh_hash_entry (parent->gfid);
- }
-
-// nfs3_log_fh (newfh);
-
return 0;
}
@@ -282,34 +183,5 @@ nfs3_fh_build_child_fh (struct nfs3_fh *parent, struct iatt *newstat,
uint32_t
nfs3_fh_compute_size (struct nfs3_fh *fh)
{
- uint32_t fhlen = 0;
-
- if (!fh)
- return 0;
-
- if (fh->hashcount <= GF_NFSFH_MAXHASHES)
- fhlen = nfs3_fh_hashcounted_size (fh->hashcount);
- else
- fhlen = nfs3_fh_hashcounted_size (GF_NFSFH_MAXHASHES);
-
- return fhlen;
+ return GF_NFSFH_STATIC_SIZE;
}
-
-
-/* There is no point searching at a directory level which is beyond that of
- * the hashcount given in the file handle.
- */
-int
-nfs3_fh_hash_index_is_beyond (struct nfs3_fh *fh, int hashidx)
-{
- if (!fh)
- return 1;
-
- if (fh->hashcount >= hashidx)
- return 0;
- else
- return 1;
-
- return 1;
-}
-
diff --git a/xlators/nfs/server/src/nfs3-fh.h b/xlators/nfs/server/src/nfs3-fh.h
index 3be043ed3c9..a9002afe724 100644
--- a/xlators/nfs/server/src/nfs3-fh.h
+++ b/xlators/nfs/server/src/nfs3-fh.h
@@ -36,16 +36,7 @@
#define GF_NFSFH_IDENT0 ':'
#define GF_NFSFH_IDENT1 'O'
#define GF_NFSFH_IDENT_SIZE (sizeof(char) * 2)
-#define GF_NFSFH_STATIC_SIZE (GF_NFSFH_IDENT_SIZE + (2*sizeof (uuid_t)) + sizeof (uint16_t))
-#define GF_NFSFH_MAX_HASH_BYTES (NFS3_FHSIZE - GF_NFSFH_STATIC_SIZE)
-
-/* Each hash element in the file handle is of 2 bytes thus giving
- * us theoretically 65536 unique entries in a directory.
- */
-typedef uint16_t nfs3_hash_entry_t;
-#define GF_NFSFH_ENTRYHASH_SIZE (sizeof (nfs3_hash_entry_t))
-#define GF_NFSFH_MAXHASHES ((int)(GF_NFSFH_MAX_HASH_BYTES / GF_NFSFH_ENTRYHASH_SIZE))
-#define nfs3_fh_hashcounted_size(hcount) (GF_NFSFH_STATIC_SIZE + (hcount * GF_NFSFH_ENTRYHASH_SIZE))
+#define GF_NFSFH_STATIC_SIZE (GF_NFSFH_IDENT_SIZE + (2*sizeof (uuid_t)))
#define nfs3_fh_exportid_to_index(exprtid) ((uint16_t)exprtid[15])
/* ATTENTION: Change in size of the structure below should be reflected in the
@@ -72,11 +63,6 @@ struct nfs3_fh {
/* File/dir gfid. */
uuid_t gfid;
-
- /* Number of file/ino hash elements that follow the ino. */
- uint16_t hashcount;
-
- nfs3_hash_entry_t entryhash[GF_NFSFH_MAXHASHES];
} __attribute__((__packed__));
#define GF_NFS3FH_STATIC_INITIALIZER {{0},}
@@ -84,9 +70,6 @@ struct nfs3_fh {
extern uint32_t
nfs3_fh_compute_size (struct nfs3_fh *fh);
-extern int
-nfs3_fh_hash_index_is_beyond (struct nfs3_fh *fh, int hashidx);
-
extern uint16_t
nfs3_fh_hash_entry (uuid_t gfid);