diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-07-30 23:46:29 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-08-27 14:21:22 -0400 |
commit | ddc04c41636f8cd374d72cdd3a0fcaa916fbc5d0 (patch) | |
tree | 7ec409d79d1cc23d6bc8a0120d0750dcdce10617 /fs/nfsd/nfs4state.c | |
parent | 3e77246393c0a433247631a1f0e9ec98d3d78a1c (diff) |
nfsd4: replace some macros by functions
For all the usual reasons. (Type safety, readability.)
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c7d54f6a19c9..ce8e70cd04c5 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -139,10 +139,19 @@ unsigned int max_delegations; | |||
139 | #define OWNER_HASH_SIZE (1 << OWNER_HASH_BITS) | 139 | #define OWNER_HASH_SIZE (1 << OWNER_HASH_BITS) |
140 | #define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1) | 140 | #define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1) |
141 | 141 | ||
142 | #define ownerid_hashval(id) \ | 142 | static unsigned int ownerid_hashval(const u32 id) |
143 | ((id) & OWNER_HASH_MASK) | 143 | { |
144 | #define ownerstr_hashval(clientid, ownername) \ | 144 | return id & OWNER_HASH_MASK; |
145 | (((clientid) + opaque_hashval((ownername.data), (ownername.len))) & OWNER_HASH_MASK) | 145 | } |
146 | |||
147 | static unsigned int ownerstr_hashval(u32 clientid, struct xdr_netobj *ownername) | ||
148 | { | ||
149 | unsigned int ret; | ||
150 | |||
151 | ret = opaque_hashval(ownername->data, ownername->len); | ||
152 | ret += clientid; | ||
153 | return ret & OWNER_HASH_MASK; | ||
154 | } | ||
146 | 155 | ||
147 | static struct list_head ownerid_hashtbl[OWNER_HASH_SIZE]; | 156 | static struct list_head ownerid_hashtbl[OWNER_HASH_SIZE]; |
148 | static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE]; | 157 | static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE]; |
@@ -156,10 +165,16 @@ static struct list_head ownerstr_hashtbl[OWNER_HASH_SIZE]; | |||
156 | #define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS) | 165 | #define STATEID_HASH_SIZE (1 << STATEID_HASH_BITS) |
157 | #define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1) | 166 | #define STATEID_HASH_MASK (STATEID_HASH_SIZE - 1) |
158 | 167 | ||
159 | #define file_hashval(x) \ | 168 | static unsigned int file_hashval(struct inode *ino) |
160 | hash_ptr(x, FILE_HASH_BITS) | 169 | { |
161 | #define stateid_hashval(owner_id, file_id) \ | 170 | /* XXX: why are we hashing on inode pointer, anyway? */ |
162 | (((owner_id) + (file_id)) & STATEID_HASH_MASK) | 171 | return hash_ptr(ino, FILE_HASH_BITS); |
172 | } | ||
173 | |||
174 | static unsigned int stateid_hashval(u32 owner_id, u32 file_id) | ||
175 | { | ||
176 | return (owner_id + file_id) & STATEID_HASH_MASK; | ||
177 | } | ||
163 | 178 | ||
164 | static struct list_head file_hashtbl[FILE_HASH_SIZE]; | 179 | static struct list_head file_hashtbl[FILE_HASH_SIZE]; |
165 | static struct list_head stateid_hashtbl[STATEID_HASH_SIZE]; | 180 | static struct list_head stateid_hashtbl[STATEID_HASH_SIZE]; |
@@ -290,10 +305,16 @@ static DEFINE_SPINLOCK(client_lock); | |||
290 | #define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS) | 305 | #define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS) |
291 | #define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1) | 306 | #define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1) |
292 | 307 | ||
293 | #define clientid_hashval(id) \ | 308 | static unsigned int clientid_hashval(u32 id) |
294 | ((id) & CLIENT_HASH_MASK) | 309 | { |
295 | #define clientstr_hashval(name) \ | 310 | return id & CLIENT_HASH_MASK; |
296 | (opaque_hashval((name), 8) & CLIENT_HASH_MASK) | 311 | } |
312 | |||
313 | static unsigned int clientstr_hashval(const char *name) | ||
314 | { | ||
315 | return opaque_hashval(name, 8) & CLIENT_HASH_MASK; | ||
316 | } | ||
317 | |||
297 | /* | 318 | /* |
298 | * reclaim_str_hashtbl[] holds known client info from previous reset/reboot | 319 | * reclaim_str_hashtbl[] holds known client info from previous reset/reboot |
299 | * used in reboot/reset lease grace period processing | 320 | * used in reboot/reset lease grace period processing |
@@ -2443,7 +2464,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate, | |||
2443 | if (STALE_CLIENTID(&open->op_clientid)) | 2464 | if (STALE_CLIENTID(&open->op_clientid)) |
2444 | return nfserr_stale_clientid; | 2465 | return nfserr_stale_clientid; |
2445 | 2466 | ||
2446 | strhashval = ownerstr_hashval(clientid->cl_id, open->op_owner); | 2467 | strhashval = ownerstr_hashval(clientid->cl_id, &open->op_owner); |
2447 | sop = find_openstateowner_str(strhashval, open); | 2468 | sop = find_openstateowner_str(strhashval, open); |
2448 | open->op_stateowner = sop; | 2469 | open->op_stateowner = sop; |
2449 | if (!sop) { | 2470 | if (!sop) { |
@@ -3711,8 +3732,10 @@ last_byte_offset(u64 start, u64 len) | |||
3711 | return end > start ? end - 1: NFS4_MAX_UINT64; | 3732 | return end > start ? end - 1: NFS4_MAX_UINT64; |
3712 | } | 3733 | } |
3713 | 3734 | ||
3714 | #define lockownerid_hashval(id) \ | 3735 | static unsigned int lockownerid_hashval(u32 id) |
3715 | ((id) & LOCK_HASH_MASK) | 3736 | { |
3737 | return id & LOCK_HASH_MASK; | ||
3738 | } | ||
3716 | 3739 | ||
3717 | static inline unsigned int | 3740 | static inline unsigned int |
3718 | lock_ownerstr_hashval(struct inode *inode, u32 cl_id, | 3741 | lock_ownerstr_hashval(struct inode *inode, u32 cl_id, |