提交 ddc04c41 编写于 作者: J J. Bruce Fields

nfsd4: replace some macros by functions

For all the usual reasons.  (Type safety, readability.)
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 3e772463
...@@ -139,10 +139,19 @@ unsigned int max_delegations; ...@@ -139,10 +139,19 @@ unsigned int max_delegations;
#define OWNER_HASH_SIZE (1 << OWNER_HASH_BITS) #define OWNER_HASH_SIZE (1 << OWNER_HASH_BITS)
#define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1) #define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1)
#define ownerid_hashval(id) \ static unsigned int ownerid_hashval(const u32 id)
((id) & OWNER_HASH_MASK) {
#define ownerstr_hashval(clientid, ownername) \ return id & OWNER_HASH_MASK;
(((clientid) + opaque_hashval((ownername.data), (ownername.len))) & OWNER_HASH_MASK) }
static unsigned int ownerstr_hashval(u32 clientid, struct xdr_netobj *ownername)
{
unsigned int ret;
ret = opaque_hashval(ownername->data, ownername->len);
ret += clientid;
return ret & OWNER_HASH_MASK;
}
static struct list_head ownerid_hashtbl[OWNER_HASH_SIZE]; static struct list_head ownerid_hashtbl[OWNER_HASH_SIZE];
static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE]; static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE];
...@@ -156,10 +165,16 @@ static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE]; ...@@ -156,10 +165,16 @@ static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE];
#define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS) #define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS)
#define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1) #define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1)
#define file_hashval(x) \ static unsigned int file_hashval(struct inode *ino)
hash_ptr(x, FILE_HASH_BITS) {
#define stateid_hashval(owner_id, file_id) \ /* XXX: why are we hashing on inode pointer, anyway? */
(((owner_id) + (file_id)) & STATEID_HASH_MASK) return hash_ptr(ino, FILE_HASH_BITS);
}
static unsigned int stateid_hashval(u32 owner_id, u32 file_id)
{
return (owner_id + file_id) & STATEID_HASH_MASK;
}
static struct list_head file_hashtbl[FILE_HASH_SIZE]; static struct list_head file_hashtbl[FILE_HASH_SIZE];
static struct list_head stateid_hashtbl[STATEID_HASH_SIZE]; static struct list_head stateid_hashtbl[STATEID_HASH_SIZE];
...@@ -290,10 +305,16 @@ static DEFINE_SPINLOCK(client_lock); ...@@ -290,10 +305,16 @@ static DEFINE_SPINLOCK(client_lock);
#define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS) #define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS)
#define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1) #define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1)
#define clientid_hashval(id) \ static unsigned int clientid_hashval(u32 id)
((id) & CLIENT_HASH_MASK) {
#define clientstr_hashval(name) \ return id & CLIENT_HASH_MASK;
(opaque_hashval((name), 8) & CLIENT_HASH_MASK) }
static unsigned int clientstr_hashval(const char *name)
{
return opaque_hashval(name, 8) & CLIENT_HASH_MASK;
}
/* /*
* reclaim_str_hashtbl[] holds known client info from previous reset/reboot * reclaim_str_hashtbl[] holds known client info from previous reset/reboot
* used in reboot/reset lease grace period processing * used in reboot/reset lease grace period processing
...@@ -2443,7 +2464,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate, ...@@ -2443,7 +2464,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
if (STALE_CLIENTID(&open->op_clientid)) if (STALE_CLIENTID(&open->op_clientid))
return nfserr_stale_clientid; return nfserr_stale_clientid;
strhashval = ownerstr_hashval(clientid->cl_id, open->op_owner); strhashval = ownerstr_hashval(clientid->cl_id, &open->op_owner);
sop = find_openstateowner_str(strhashval, open); sop = find_openstateowner_str(strhashval, open);
open->op_stateowner = sop; open->op_stateowner = sop;
if (!sop) { if (!sop) {
...@@ -3711,8 +3732,10 @@ last_byte_offset(u64 start, u64 len) ...@@ -3711,8 +3732,10 @@ last_byte_offset(u64 start, u64 len)
return end > start ? end - 1: NFS4_MAX_UINT64; return end > start ? end - 1: NFS4_MAX_UINT64;
} }
#define lockownerid_hashval(id) \ static unsigned int lockownerid_hashval(u32 id)
((id) & LOCK_HASH_MASK) {
return id & LOCK_HASH_MASK;
}
static inline unsigned int static inline unsigned int
lock_ownerstr_hashval(struct inode *inode, u32 cl_id, lock_ownerstr_hashval(struct inode *inode, u32 cl_id,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册