aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dcache.h
diff options
context:
space:
mode:
authorNick Piggin <npiggin@kernel.dk>2011-01-07 01:49:32 -0500
committerNick Piggin <npiggin@kernel.dk>2011-01-07 01:50:21 -0500
commitb7ab39f631f505edc2bbdb86620d5493f995c9da (patch)
tree62be97ebc7fc69ceb601f23312d335ebb8038ee7 /include/linux/dcache.h
parent2304450783dfde7b0b94ae234edd0dbffa865073 (diff)
fs: dcache scale dentry refcount
Make d_count non-atomic and protect it with d_lock. This allows us to ensure a 0 refcount dentry remains 0 without dcache_lock. It is also fairly natural when we start protecting many other dentry members with d_lock. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'include/linux/dcache.h')
-rw-r--r--include/linux/dcache.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 2feb624b67f1..b0ade2d46805 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -87,7 +87,7 @@ full_name_hash(const unsigned char *name, unsigned int len)
87#endif 87#endif
88 88
89struct dentry { 89struct dentry {
90 atomic_t d_count; 90 unsigned int d_count; /* protected by d_lock */
91 unsigned int d_flags; /* protected by d_lock */ 91 unsigned int d_flags; /* protected by d_lock */
92 spinlock_t d_lock; /* per dentry lock */ 92 spinlock_t d_lock; /* per dentry lock */
93 int d_mounted; 93 int d_mounted;
@@ -297,17 +297,28 @@ extern char *dentry_path(struct dentry *, char *, int);
297 * needs and they take necessary precautions) you should hold dcache_lock 297 * needs and they take necessary precautions) you should hold dcache_lock
298 * and call dget_locked() instead of dget(). 298 * and call dget_locked() instead of dget().
299 */ 299 */
300 300static inline struct dentry *dget_dlock(struct dentry *dentry)
301{
302 if (dentry) {
303 BUG_ON(!dentry->d_count);
304 dentry->d_count++;
305 }
306 return dentry;
307}
301static inline struct dentry *dget(struct dentry *dentry) 308static inline struct dentry *dget(struct dentry *dentry)
302{ 309{
303 if (dentry) { 310 if (dentry) {
304 BUG_ON(!atomic_read(&dentry->d_count)); 311 spin_lock(&dentry->d_lock);
305 atomic_inc(&dentry->d_count); 312 dget_dlock(dentry);
313 spin_unlock(&dentry->d_lock);
306 } 314 }
307 return dentry; 315 return dentry;
308} 316}
309 317
310extern struct dentry * dget_locked(struct dentry *); 318extern struct dentry * dget_locked(struct dentry *);
319extern struct dentry * dget_locked_dlock(struct dentry *);
320
321extern struct dentry *dget_parent(struct dentry *dentry);
311 322
312/** 323/**
313 * d_unhashed - is dentry hashed 324 * d_unhashed - is dentry hashed
@@ -338,16 +349,6 @@ static inline void dont_mount(struct dentry *dentry)
338 spin_unlock(&dentry->d_lock); 349 spin_unlock(&dentry->d_lock);
339} 350}
340 351
341static inline struct dentry *dget_parent(struct dentry *dentry)
342{
343 struct dentry *ret;
344
345 spin_lock(&dentry->d_lock);
346 ret = dget(dentry->d_parent);
347 spin_unlock(&dentry->d_lock);
348 return ret;
349}
350
351extern void dput(struct dentry *); 352extern void dput(struct dentry *);
352 353
353static inline int d_mountpoint(struct dentry *dentry) 354static inline int d_mountpoint(struct dentry *dentry)