nfsd: convert the file_hashtbl to a hlist
Subsystems (2)
PATCH 1/1 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 <[email protected]>
--- fs/nfsd/nfs4state.c | 14 ++++---------- fs/nfsd/state.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-)
fs/nfsd/nfs4state.c +4 -10
@@ -137,7 +137,7 @@ static inline void put_nfs4_file(struct nfs4_file *fi) {if (atomic_dec_and_lock (&fi->fi_ref, &recall_lock)) { -list_del (&fi->fi_hash); +hlist_del (&fi->fi_hash);spin_unlock (&recall_lock);iput (fi->fi_inode);nfsd4_free_file (fi);
@@ -181,7 +181,7 @@ static unsigned int file_hashval(struct inode *ino)return hash_ptr (ino,FILE_HASH_BITS ); } -static struct list_head file_hashtbl[FILE_HASH_SIZE ]; +static struct hlist_head file_hashtbl[FILE_HASH_SIZE ];static void __nfs4_file_get_access (struct nfs4_file *fp,int oflag) {
@@ -2303,7 +2303,6 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)unsigned int hashval =file_hashval (ino);atomic_set (&fp->fi_ref,1 ); -INIT_LIST_HEAD (&fp->fi_hash);INIT_LIST_HEAD (&fp->fi_stateids);INIT_LIST_HEAD (&fp->fi_delegations); fp->fi_inode =igrab (ino);
@@ -2312,7 +2311,7 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)memset (fp->fi_fds,0 ,sizeof (fp->fi_fds));memset (fp->fi_access,0 ,sizeof (fp->fi_access));spin_lock (&recall_lock); -list_add (&fp->fi_hash, &file_hashtbl[hashval]); +hlist_add_head (&fp->fi_hash, &file_hashtbl[hashval]);spin_unlock (&recall_lock); }
@@ -2498,7 +2497,7 @@ find_file(struct inode *ino)struct nfs4_file *fp;spin_lock (&recall_lock); -list_for_each_entry (fp, &file_hashtbl[hashval], fi_hash) { +hlist_for_each_entry (fp, &file_hashtbl[hashval], fi_hash) {if (fp->fi_inode == ino) {get_nfs4_file (fp);spin_unlock (&recall_lock);
@@ -4775,11 +4774,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_void nfs4_state_init (void ) { -int i; - -for (i =0 ; i <FILE_HASH_SIZE ; i++) { -INIT_LIST_HEAD (&file_hashtbl[i]); - }INIT_LIST_HEAD (&del_recall_lru); }
fs/nfsd/state.h +1 -1
@@ -390,7 +390,7 @@ static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)/* nfs4_file: a file opened by some number of (open) nfs4_stateowners. */ struct nfs4_file {atomic_t fi_ref; -struct list_head fi_hash;/* hash by "struct inode *" */ +struct hlist_node fi_hash;/* hash by "struct inode *" */ struct list_head fi_stateids;struct list_head fi_delegations;/* One each for O_RDONLY, O_WRONLY, O_RDWR: */
Signature · 1 line
1.7.11.7
Quoted 2 lines · Jeff Layton
We only ever traverse the hash chains in the forward direction, so a double pointer list head isn't really necessary.
Thanks, applying.--b.
Quoted 83 lines
Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfs4state.c | 14 ++++---------- fs/nfsd/state.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-)fs/nfsd/nfs4state.c +4
-10@@ -137,7 +137,7 @@ static inline void put_nfs4_file(struct nfs4_file *fi) {if (atomic_dec_and_lock (&fi->fi_ref, &recall_lock)) { -list_del (&fi->fi_hash); +hlist_del (&fi->fi_hash);spin_unlock (&recall_lock);iput (fi->fi_inode);nfsd4_free_file (fi);@@ -181,7 +181,7 @@ static unsigned int file_hashval(struct inode *ino)return hash_ptr (ino,FILE_HASH_BITS ); } -static struct list_head file_hashtbl[FILE_HASH_SIZE ]; +static struct hlist_head file_hashtbl[FILE_HASH_SIZE ];static void __nfs4_file_get_access (struct nfs4_file *fp,int oflag) {@@ -2303,7 +2303,6 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)unsigned int hashval =file_hashval (ino);atomic_set (&fp->fi_ref,1 ); -INIT_LIST_HEAD (&fp->fi_hash);INIT_LIST_HEAD (&fp->fi_stateids);INIT_LIST_HEAD (&fp->fi_delegations); fp->fi_inode =igrab (ino);@@ -2312,7 +2311,7 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino)memset (fp->fi_fds,0 ,sizeof (fp->fi_fds));memset (fp->fi_access,0 ,sizeof (fp->fi_access));spin_lock (&recall_lock); -list_add (&fp->fi_hash, &file_hashtbl[hashval]); +hlist_add_head (&fp->fi_hash, &file_hashtbl[hashval]);spin_unlock (&recall_lock); }@@ -2498,7 +2497,7 @@ find_file(struct inode *ino)struct nfs4_file *fp;spin_lock (&recall_lock); -list_for_each_entry (fp, &file_hashtbl[hashval], fi_hash) { +hlist_for_each_entry (fp, &file_hashtbl[hashval], fi_hash) {if (fp->fi_inode == ino) {get_nfs4_file (fp);spin_unlock (&recall_lock);@@ -4775,11 +4774,6 @@ struct nfs4_client *nfsd_find_client(struct sockaddr_storage *addr, size_t addr_void nfs4_state_init (void ) { -int i; - -for (i =0 ; i <FILE_HASH_SIZE ; i++) { -INIT_LIST_HEAD (&file_hashtbl[i]); - }INIT_LIST_HEAD (&del_recall_lru); }fs/nfsd/state.h +1
-1@@ -390,7 +390,7 @@ static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)/* nfs4_file: a file opened by some number of (open) nfs4_stateowners. */ struct nfs4_file {atomic_t fi_ref; -struct list_head fi_hash;/* hash by "struct inode *" */ +struct hlist_node fi_hash;/* hash by "struct inode *" */ struct list_head fi_stateids;struct list_head fi_delegations;/* One each for O_RDONLY, O_WRONLY, O_RDWR: */ Signature · 1 line
1.7.11.7