aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2013-04-02 09:01:59 -0400
committerJ. Bruce Fields <bfields@redhat.com>2013-04-03 15:11:04 -0400
commit89876f8c0dbcc2947b13b9e22cf28c5308cee3c1 (patch)
treec80bd0eeac5972e64b852624baaedb6a1db4af64 /fs/nfsd
parent66b2b9b2b0e8a9034806293a436628400a44a71d (diff)
nfsd: convert the file_hashtbl to a hlist
We only ever traverse the hash chains in the forward direction, so a double pointer list head isn't really necessary. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c14
-rw-r--r--fs/nfsd/state.h2
2 files changed, 5 insertions, 11 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 2fd015587167..7293e298aeed 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -236,7 +236,7 @@ static inline void
236put_nfs4_file(struct nfs4_file *fi) 236put_nfs4_file(struct nfs4_file *fi)
237{ 237{
238 if (atomic_dec_and_lock(&fi->fi_ref, &recall_lock)) { 238 if (atomic_dec_and_lock(&fi->fi_ref, &recall_lock)) {
239 list_del(&fi->fi_hash); 239 hlist_del(&fi->fi_hash);
240 spin_unlock(&recall_lock); 240 spin_unlock(&recall_lock);
241 iput(fi->fi_inode); 241 iput(fi->fi_inode);
242 nfsd4_free_file(fi); 242 nfsd4_free_file(fi);
@@ -280,7 +280,7 @@ static unsigned int file_hashval(struct inode *ino)
280 return hash_ptr(ino, FILE_HASH_BITS); 280 return hash_ptr(ino, FILE_HASH_BITS);
281} 281}
282 282
283static struct list_head file_hashtbl[FILE_HASH_SIZE]; 283static struct hlist_head file_hashtbl[FILE_HASH_SIZE];
284 284
285static void __nfs4_file_get_access(struct nfs4_file *fp, int oflag) 285static void __nfs4_file_get_access(struct nfs4_file *fp, int oflag)
286{ 286{
@@ -2347,7 +2347,6 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)
2347 unsigned int hashval = file_hashval(ino); 2347 unsigned int hashval = file_hashval(ino);
2348 2348
2349 atomic_set(&fp->fi_ref, 1); 2349 atomic_set(&fp->fi_ref, 1);
2350 INIT_LIST_HEAD(&fp->fi_hash);
2351 INIT_LIST_HEAD(&fp->fi_stateids); 2350 INIT_LIST_HEAD(&fp->fi_stateids);
2352 INIT_LIST_HEAD(&fp->fi_delegations); 2351 INIT_LIST_HEAD(&fp->fi_delegations);
2353 fp->fi_inode = igrab(ino); 2352 fp->fi_inode = igrab(ino);
@@ -2356,7 +2355,7 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)
2356 memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); 2355 memset(fp->fi_fds, 0, sizeof(fp->fi_fds));
2357 memset(fp->fi_access, 0, sizeof(fp->fi_access)); 2356 memset(fp->fi_access, 0, sizeof(fp->fi_access));
2358 spin_lock(&recall_lock); 2357 spin_lock(&recall_lock);
2359 list_add(&fp->fi_hash, &file_hashtbl[hashval]); 2358 hlist_add_head(&fp->fi_hash, &file_hashtbl[hashval]);
2360 spin_unlock(&recall_lock); 2359 spin_unlock(&recall_lock);
2361} 2360}
2362 2361
@@ -2542,7 +2541,7 @@ find_file(struct inode *ino)
2542 struct nfs4_file *fp; 2541 struct nfs4_file *fp;
2543 2542
2544 spin_lock(&recall_lock); 2543 spin_lock(&recall_lock);
2545 list_for_each_entry(fp, &file_hashtbl[hashval], fi_hash) { 2544 hlist_for_each_entry(fp, &file_hashtbl[hashval], fi_hash) {
2546 if (fp->fi_inode == ino) { 2545 if (fp->fi_inode == ino) {
2547 get_nfs4_file(fp); 2546 get_nfs4_file(fp);
2548 spin_unlock(&recall_lock); 2547 spin_unlock(&recall_lock);
@@ -4810,11 +4809,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_
4810void 4809void
4811nfs4_state_init(void) 4810nfs4_state_init(void)
4812{ 4811{
4813 int i;
4814
4815 for (i = 0; i < FILE_HASH_SIZE; i++) {
4816 INIT_LIST_HEAD(&file_hashtbl[i]);
4817 }
4818 INIT_LIST_HEAD(&del_recall_lru); 4812 INIT_LIST_HEAD(&del_recall_lru);
4819} 4813}
4820 4814
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index f6ae4db3efdb..7674bc806200 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -380,7 +380,7 @@ static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)
380/* nfs4_file: a file opened by some number of (open) nfs4_stateowners. */ 380/* nfs4_file: a file opened by some number of (open) nfs4_stateowners. */
381struct nfs4_file { 381struct nfs4_file {
382 atomic_t fi_ref; 382 atomic_t fi_ref;
383 struct list_head fi_hash; /* hash by "struct inode *" */ 383 struct hlist_node fi_hash; /* hash by "struct inode *" */
384 struct list_head fi_stateids; 384 struct list_head fi_stateids;
385 struct list_head fi_delegations; 385 struct list_head fi_delegations;
386 /* One each for O_RDONLY, O_WRONLY, O_RDWR: */ 386 /* One each for O_RDONLY, O_WRONLY, O_RDWR: */