#include "afs/afs_consts.h"
#endif
+/* jhash.h is a standalone header and is fine to pull into kernel code. */
+#include <opr/jhash.h>
+
/*
* afs_fsfragsize cannot be less than 1023, or some cache-tracking
* calculations will be incorrect (since we track cache usage in kb).
#define NSERVERS 16 /* hash table size for server table */
#define NVOLS 64 /* hash table size for volume table */
#define NFENTRIES 256 /* hash table size for disk volume table */
-#define VCSIZE 1024 /* stat cache hash table size */
+#define VCSIZEBITS 10 /* log of stat cache hash table size */
+#define VCSIZE (opr_jhash_size(VCSIZEBITS))
#define CBRSIZE 512 /* call back returns hash table size */
#define PIGGYSIZE 1350 /* max piggyback size */
#define MAXVOLS 128 /* max vols we can store */
#define afs_InReadDir(avc) (((avc)->f.states & CReadDir) && (avc)->readdir_pid == MyPidxx2Pid(MyPidxx))
-/* The PFlush algorithm makes use of the fact that Fid.Unique is not used in
- below hash algorithms. Change it if need be so that flushing algorithm
- doesn't move things from one hash chain to another
-*/
-/* extern int afs_dhashsize; */
-#define DCHash(v, c) ((((v)->Fid.Vnode + (v)->Fid.Volume + (c))) & (afs_dhashsize-1))
- /*Vnode, Chunk -> Hash table index */
-#define DVHash(v) ((((v)->Fid.Vnode + (v)->Fid.Volume )) & (afs_dhashsize-1))
- /*Vnode -> Other hash table index */
-/* don't hash on the cell, our callback-breaking code sometimes fails to compute
- the cell correctly, and only scans one hash bucket */
-#define VCHash(fid) (((fid)->Fid.Volume + (fid)->Fid.Vnode) & (VCSIZE-1))
-/* Hash only on volume to speed up volume callbacks. */
-#define VCHashV(fid) ((fid)->Fid.Volume & (VCSIZE-1))
-
extern struct dcache **afs_indexTable; /*Pointers to in-memory dcache entries */
extern afs_int32 *afs_indexUnique; /*dcache entry Fid.Unique */
extern afs_int32 *afs_dvnextTbl; /*Dcache hash table links */
int cacheDiskType; /*Type of backing disk for cache */
struct afs_cacheOps *afs_cacheType;
+
+/*
+ * The PFlush algorithm makes use of the fact that Fid.Unique is not used in
+ * below hash algorithms. Change it if need be so that flushing algorithm
+ * doesn't move things from one hash chain to another.
+ */
+/*Vnode, Chunk -> Hash table index */
+int DCHash(struct VenusFid *fid, afs_int32 chunk)
+{
+ afs_uint32 buf[3];
+
+ buf[0] = fid->Fid.Volume;
+ buf[1] = fid->Fid.Vnode;
+ buf[2] = chunk;
+ return opr_jhash(buf, 3, 0) & (afs_dhashsize - 1);
+}
+/*Vnode -> Other hash table index */
+int DVHash(struct VenusFid *fid)
+{
+ return opr_jhash_int2(fid->Fid.Volume, fid->Fid.Vnode, 0) &
+ (afs_dhashsize - 1);
+}
+
/*!
* Where is this vcache's entry associated dcache located/
* \param avc The vcache entry.
extern struct afs_cacheOps *afs_cacheType;
extern afs_dcache_id_t cacheInode;
extern struct osi_file *afs_cacheInodep;
+extern int DCHash(struct VenusFid *fid, afs_int32 chunk);
+extern int DVHash(struct VenusFid *fid);
extern void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk,
int aflags);
extern int afs_PutDCache(struct dcache *adc);
#endif
/* afs_vcache.c */
+extern int VCHash(struct VenusFid *fid);
+extern int VCHashV(struct VenusFid *fid);
extern int afs_ShakeLooseVCaches(afs_int32 anumber);
extern afs_int32 afs_maxvcount;
extern afs_int32 afs_vcount;
/* Forward declarations */
static afs_int32 afs_QueueVCB(struct vcache *avc, int *slept);
+
+/*
+ * The PFlush algorithm makes use of the fact that Fid.Unique is not used in
+ * below hash algorithms. Change it if need be so that flushing algorithm
+ * doesn't move things from one hash chain to another.
+ */
+/* Don't hash on the cell; our callback-breaking code sometimes fails to compute
+ * the cell correctly, and only scans one hash bucket. */
+int VCHash(struct VenusFid *fid)
+{
+ return opr_jhash_int2(fid->Fid.Volume, fid->Fid.Vnode, 0) &
+ opr_jhash_mask(VCSIZEBITS);
+}
+/* Hash only on volume to speed up volume callbacks. */
+int VCHashV(struct VenusFid *fid)
+{
+ return opr_jhash_int(fid->Fid.Vnode, 0) & opr_jhash_mask(VCSIZEBITS);
+}
+
/*!
* Generate an index into the hash table for a given Fid.
* \param fid