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