vfs: get rid of 'struct dcache_hash_bucket' abstraction

It's a useless abstraction for 'hlist_bl_head', and it doesn't actually
help anything - quite the reverse. All the users end up having to know
about the hlist_bl_head details anyway, using 'struct hlist_bl_node *'
etc. So it just makes the code look confusing.

And the cost of it is extra '&b->head' syntactic noise, but more
importantly it spuriously makes the hash table dentry list look
different from the per-superblock DCACHE_DISCONNECTED dentry list.

As a result, the code ended up using ad-hoc locking for one case and
special helper functions for what is really another totally identical
case in the very same function.

Make it all look and work the same.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+21 -24
+21 -24
fs/dcache.c
··· 99 static unsigned int d_hash_mask __read_mostly; 100 static unsigned int d_hash_shift __read_mostly; 101 102 - struct dcache_hash_bucket { 103 - struct hlist_bl_head head; 104 - }; 105 - static struct dcache_hash_bucket *dentry_hashtable __read_mostly; 106 107 - static inline struct dcache_hash_bucket *d_hash(struct dentry *parent, 108 unsigned long hash) 109 { 110 hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES; ··· 109 return dentry_hashtable + (hash & D_HASHMASK); 110 } 111 112 - static inline void spin_lock_bucket(struct dcache_hash_bucket *b) 113 { 114 - bit_spin_lock(0, (unsigned long *)&b->head.first); 115 } 116 117 - static inline void spin_unlock_bucket(struct dcache_hash_bucket *b) 118 { 119 - __bit_spin_unlock(0, (unsigned long *)&b->head.first); 120 } 121 122 /* Statistics gathering. */ ··· 328 void __d_drop(struct dentry *dentry) 329 { 330 if (!(dentry->d_flags & DCACHE_UNHASHED)) { 331 if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED)) { 332 - bit_spin_lock(0, 333 - (unsigned long *)&dentry->d_sb->s_anon.first); 334 dentry->d_flags |= DCACHE_UNHASHED; 335 hlist_bl_del_init(&dentry->d_hash); 336 - __bit_spin_unlock(0, 337 - (unsigned long *)&dentry->d_sb->s_anon.first); 338 } else { 339 - struct dcache_hash_bucket *b; 340 b = d_hash(dentry->d_parent, dentry->d_name.hash); 341 spin_lock_bucket(b); 342 /* ··· 1786 unsigned int len = name->len; 1787 unsigned int hash = name->hash; 1788 const unsigned char *str = name->name; 1789 - struct dcache_hash_bucket *b = d_hash(parent, hash); 1790 struct hlist_bl_node *node; 1791 struct dentry *dentry; 1792 ··· 1810 * 1811 * See Documentation/filesystems/path-lookup.txt for more details. 1812 */ 1813 - hlist_bl_for_each_entry_rcu(dentry, node, &b->head, d_hash) { 1814 struct inode *i; 1815 const char *tname; 1816 int tlen; ··· 1905 unsigned int len = name->len; 1906 unsigned int hash = name->hash; 1907 const unsigned char *str = name->name; 1908 - struct dcache_hash_bucket *b = d_hash(parent, hash); 1909 struct hlist_bl_node *node; 1910 struct dentry *found = NULL; 1911 struct dentry *dentry; ··· 1932 */ 1933 rcu_read_lock(); 1934 1935 - hlist_bl_for_each_entry_rcu(dentry, node, &b->head, d_hash) { 1936 const char *tname; 1937 int tlen; 1938 ··· 2083 } 2084 EXPORT_SYMBOL(d_delete); 2085 2086 - static void __d_rehash(struct dentry * entry, struct dcache_hash_bucket *b) 2087 { 2088 BUG_ON(!d_unhashed(entry)); 2089 spin_lock_bucket(b); 2090 entry->d_flags &= ~DCACHE_UNHASHED; 2091 - hlist_bl_add_head_rcu(&entry->d_hash, &b->head); 2092 spin_unlock_bucket(b); 2093 } 2094 ··· 3022 3023 dentry_hashtable = 3024 alloc_large_system_hash("Dentry cache", 3025 - sizeof(struct dcache_hash_bucket), 3026 dhash_entries, 3027 13, 3028 HASH_EARLY, ··· 3031 0); 3032 3033 for (loop = 0; loop < (1 << d_hash_shift); loop++) 3034 - INIT_HLIST_BL_HEAD(&dentry_hashtable[loop].head); 3035 } 3036 3037 static void __init dcache_init(void) ··· 3054 3055 dentry_hashtable = 3056 alloc_large_system_hash("Dentry cache", 3057 - sizeof(struct dcache_hash_bucket), 3058 dhash_entries, 3059 13, 3060 0, ··· 3063 0); 3064 3065 for (loop = 0; loop < (1 << d_hash_shift); loop++) 3066 - INIT_HLIST_BL_HEAD(&dentry_hashtable[loop].head); 3067 } 3068 3069 /* SLAB cache for __getname() consumers */
··· 99 static unsigned int d_hash_mask __read_mostly; 100 static unsigned int d_hash_shift __read_mostly; 101 102 + static struct hlist_bl_head *dentry_hashtable __read_mostly; 103 104 + static inline struct hlist_bl_head *d_hash(struct dentry *parent, 105 unsigned long hash) 106 { 107 hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES; ··· 112 return dentry_hashtable + (hash & D_HASHMASK); 113 } 114 115 + static inline void spin_lock_bucket(struct hlist_bl_head *b) 116 { 117 + bit_spin_lock(0, (unsigned long *)&b->first); 118 } 119 120 + static inline void spin_unlock_bucket(struct hlist_bl_head *b) 121 { 122 + __bit_spin_unlock(0, (unsigned long *)&b->first); 123 } 124 125 /* Statistics gathering. */ ··· 331 void __d_drop(struct dentry *dentry) 332 { 333 if (!(dentry->d_flags & DCACHE_UNHASHED)) { 334 + struct hlist_bl_head *b; 335 if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED)) { 336 + b = &dentry->d_sb->s_anon; 337 + spin_lock_bucket(b); 338 dentry->d_flags |= DCACHE_UNHASHED; 339 hlist_bl_del_init(&dentry->d_hash); 340 + spin_unlock_bucket(b); 341 } else { 342 + struct hlist_bl_head *b; 343 b = d_hash(dentry->d_parent, dentry->d_name.hash); 344 spin_lock_bucket(b); 345 /* ··· 1789 unsigned int len = name->len; 1790 unsigned int hash = name->hash; 1791 const unsigned char *str = name->name; 1792 + struct hlist_bl_head *b = d_hash(parent, hash); 1793 struct hlist_bl_node *node; 1794 struct dentry *dentry; 1795 ··· 1813 * 1814 * See Documentation/filesystems/path-lookup.txt for more details. 1815 */ 1816 + hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { 1817 struct inode *i; 1818 const char *tname; 1819 int tlen; ··· 1908 unsigned int len = name->len; 1909 unsigned int hash = name->hash; 1910 const unsigned char *str = name->name; 1911 + struct hlist_bl_head *b = d_hash(parent, hash); 1912 struct hlist_bl_node *node; 1913 struct dentry *found = NULL; 1914 struct dentry *dentry; ··· 1935 */ 1936 rcu_read_lock(); 1937 1938 + hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { 1939 const char *tname; 1940 int tlen; 1941 ··· 2086 } 2087 EXPORT_SYMBOL(d_delete); 2088 2089 + static void __d_rehash(struct dentry * entry, struct hlist_bl_head *b) 2090 { 2091 BUG_ON(!d_unhashed(entry)); 2092 spin_lock_bucket(b); 2093 entry->d_flags &= ~DCACHE_UNHASHED; 2094 + hlist_bl_add_head_rcu(&entry->d_hash, b); 2095 spin_unlock_bucket(b); 2096 } 2097 ··· 3025 3026 dentry_hashtable = 3027 alloc_large_system_hash("Dentry cache", 3028 + sizeof(struct hlist_bl_head), 3029 dhash_entries, 3030 13, 3031 HASH_EARLY, ··· 3034 0); 3035 3036 for (loop = 0; loop < (1 << d_hash_shift); loop++) 3037 + INIT_HLIST_BL_HEAD(dentry_hashtable + loop); 3038 } 3039 3040 static void __init dcache_init(void) ··· 3057 3058 dentry_hashtable = 3059 alloc_large_system_hash("Dentry cache", 3060 + sizeof(struct hlist_bl_head), 3061 dhash_entries, 3062 13, 3063 0, ··· 3066 0); 3067 3068 for (loop = 0; loop < (1 << d_hash_shift); loop++) 3069 + INIT_HLIST_BL_HEAD(dentry_hashtable + loop); 3070 } 3071 3072 /* SLAB cache for __getname() consumers */