From c318acc9bce1df423b2be18a694205cfe90f8a11 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Sat, 23 Oct 2010 06:58:09 -0400 Subject: [PATCH] --- yaml --- r: 217799 b: refs/heads/master c: 4c51acbc66f754e536e1c9e3331656b69bce86d0 h: refs/heads/master i: 217797: 4388fc400d5eaaf4454aac9d971635688342b8b3 217795: 86d1e8368714f5876b935c77766a13292a589b5c 217791: 0b2e44e35e3e26af74f301f875e684745d7a3b75 v: v3 --- [refs] | 2 +- trunk/fs/inode.c | 100 ++++++++++++++++++++++++++--------------------- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/[refs] b/[refs] index 672888b00dec..efc7bbb50765 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9e38d86ff2d8a8db99570e982230861046df32b5 +refs/heads/master: 4c51acbc66f754e536e1c9e3331656b69bce86d0 diff --git a/trunk/fs/inode.c b/trunk/fs/inode.c index 3bdc76f1653a..5e5bafe70ceb 100644 --- a/trunk/fs/inode.c +++ b/trunk/fs/inode.c @@ -336,6 +336,58 @@ static void inode_lru_list_del(struct inode *inode) } } +static unsigned long hash(struct super_block *sb, unsigned long hashval) +{ + unsigned long tmp; + + tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) / + L1_CACHE_BYTES; + tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> I_HASHBITS); + return tmp & I_HASHMASK; +} + +/** + * __insert_inode_hash - hash an inode + * @inode: unhashed inode + * @hashval: unsigned long value used to locate this object in the + * inode_hashtable. + * + * Add an inode to the inode hash for this superblock. + */ +void __insert_inode_hash(struct inode *inode, unsigned long hashval) +{ + struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); + spin_lock(&inode_lock); + hlist_add_head(&inode->i_hash, head); + spin_unlock(&inode_lock); +} +EXPORT_SYMBOL(__insert_inode_hash); + +/** + * __remove_inode_hash - remove an inode from the hash + * @inode: inode to unhash + * + * Remove an inode from the superblock. + */ +static void __remove_inode_hash(struct inode *inode) +{ + hlist_del_init(&inode->i_hash); +} + +/** + * remove_inode_hash - remove an inode from the hash + * @inode: inode to unhash + * + * Remove an inode from the superblock. + */ +void remove_inode_hash(struct inode *inode) +{ + spin_lock(&inode_lock); + hlist_del_init(&inode->i_hash); + spin_unlock(&inode_lock); +} +EXPORT_SYMBOL(remove_inode_hash); + void end_writeback(struct inode *inode) { might_sleep(); @@ -383,7 +435,7 @@ static void dispose_list(struct list_head *head) evict(inode); spin_lock(&inode_lock); - hlist_del_init(&inode->i_hash); + __remove_inode_hash(inode); list_del_init(&inode->i_sb_list); spin_unlock(&inode_lock); @@ -634,16 +686,6 @@ static struct inode *find_inode_fast(struct super_block *sb, return node ? inode : NULL; } -static unsigned long hash(struct super_block *sb, unsigned long hashval) -{ - unsigned long tmp; - - tmp = (hashval * (unsigned long)sb) ^ (GOLDEN_RATIO_PRIME + hashval) / - L1_CACHE_BYTES; - tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> I_HASHBITS); - return tmp & I_HASHMASK; -} - static inline void __inode_add_to_lists(struct super_block *sb, struct hlist_head *head, struct inode *inode) @@ -1194,36 +1236,6 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, } EXPORT_SYMBOL(insert_inode_locked4); -/** - * __insert_inode_hash - hash an inode - * @inode: unhashed inode - * @hashval: unsigned long value used to locate this object in the - * inode_hashtable. - * - * Add an inode to the inode hash for this superblock. - */ -void __insert_inode_hash(struct inode *inode, unsigned long hashval) -{ - struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); - spin_lock(&inode_lock); - hlist_add_head(&inode->i_hash, head); - spin_unlock(&inode_lock); -} -EXPORT_SYMBOL(__insert_inode_hash); - -/** - * remove_inode_hash - remove an inode from the hash - * @inode: inode to unhash - * - * Remove an inode from the superblock. - */ -void remove_inode_hash(struct inode *inode) -{ - spin_lock(&inode_lock); - hlist_del_init(&inode->i_hash); - spin_unlock(&inode_lock); -} -EXPORT_SYMBOL(remove_inode_hash); int generic_delete_inode(struct inode *inode) { @@ -1279,7 +1291,7 @@ static void iput_final(struct inode *inode) spin_lock(&inode_lock); WARN_ON(inode->i_state & I_NEW); inode->i_state &= ~I_WILL_FREE; - hlist_del_init(&inode->i_hash); + __remove_inode_hash(inode); } WARN_ON(inode->i_state & I_NEW); inode->i_state |= I_FREEING; @@ -1294,9 +1306,7 @@ static void iput_final(struct inode *inode) list_del_init(&inode->i_sb_list); spin_unlock(&inode_lock); evict(inode); - spin_lock(&inode_lock); - hlist_del_init(&inode->i_hash); - spin_unlock(&inode_lock); + remove_inode_hash(inode); wake_up_inode(inode); BUG_ON(inode->i_state != (I_FREEING | I_CLEAR)); destroy_inode(inode);