aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dcache.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/dcache.h')
-rw-r--r--include/linux/dcache.h40
1 files changed, 9 insertions, 31 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index b90337c9d468..9169b91ea2d2 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -9,6 +9,7 @@
9#include <linux/seqlock.h> 9#include <linux/seqlock.h>
10#include <linux/cache.h> 10#include <linux/cache.h>
11#include <linux/rcupdate.h> 11#include <linux/rcupdate.h>
12#include <linux/lockref.h>
12 13
13struct nameidata; 14struct nameidata;
14struct path; 15struct path;
@@ -100,6 +101,8 @@ extern unsigned int full_name_hash(const unsigned char *, unsigned int);
100# endif 101# endif
101#endif 102#endif
102 103
104#define d_lock d_lockref.lock
105
103struct dentry { 106struct dentry {
104 /* RCU lookup touched fields */ 107 /* RCU lookup touched fields */
105 unsigned int d_flags; /* protected by d_lock */ 108 unsigned int d_flags; /* protected by d_lock */
@@ -112,8 +115,7 @@ struct dentry {
112 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */ 115 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
113 116
114 /* Ref lookup also touches following */ 117 /* Ref lookup also touches following */
115 unsigned int d_count; /* protected by d_lock */ 118 struct lockref d_lockref; /* per-dentry lock and refcount */
116 spinlock_t d_lock; /* per dentry lock */
117 const struct dentry_operations *d_op; 119 const struct dentry_operations *d_op;
118 struct super_block *d_sb; /* The root of the dentry tree */ 120 struct super_block *d_sb; /* The root of the dentry tree */
119 unsigned long d_time; /* used by d_revalidate */ 121 unsigned long d_time; /* used by d_revalidate */
@@ -302,31 +304,9 @@ extern struct dentry *__d_lookup(const struct dentry *, const struct qstr *);
302extern struct dentry *__d_lookup_rcu(const struct dentry *parent, 304extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
303 const struct qstr *name, unsigned *seq); 305 const struct qstr *name, unsigned *seq);
304 306
305/**
306 * __d_rcu_to_refcount - take a refcount on dentry if sequence check is ok
307 * @dentry: dentry to take a ref on
308 * @seq: seqcount to verify against
309 * Returns: 0 on failure, else 1.
310 *
311 * __d_rcu_to_refcount operates on a dentry,seq pair that was returned
312 * by __d_lookup_rcu, to get a reference on an rcu-walk dentry.
313 */
314static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq)
315{
316 int ret = 0;
317
318 assert_spin_locked(&dentry->d_lock);
319 if (!read_seqcount_retry(&dentry->d_seq, seq)) {
320 ret = 1;
321 dentry->d_count++;
322 }
323
324 return ret;
325}
326
327static inline unsigned d_count(const struct dentry *dentry) 307static inline unsigned d_count(const struct dentry *dentry)
328{ 308{
329 return dentry->d_count; 309 return dentry->d_lockref.count;
330} 310}
331 311
332/* validate "insecure" dentry pointer */ 312/* validate "insecure" dentry pointer */
@@ -336,6 +316,7 @@ extern int d_validate(struct dentry *, struct dentry *);
336 * helper function for dentry_operations.d_dname() members 316 * helper function for dentry_operations.d_dname() members
337 */ 317 */
338extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); 318extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
319extern char *simple_dname(struct dentry *, char *, int);
339 320
340extern char *__d_path(const struct path *, const struct path *, char *, int); 321extern char *__d_path(const struct path *, const struct path *, char *, int);
341extern char *d_absolute_path(const struct path *, char *, int); 322extern char *d_absolute_path(const struct path *, char *, int);
@@ -356,17 +337,14 @@ extern char *dentry_path(struct dentry *, char *, int);
356static inline struct dentry *dget_dlock(struct dentry *dentry) 337static inline struct dentry *dget_dlock(struct dentry *dentry)
357{ 338{
358 if (dentry) 339 if (dentry)
359 dentry->d_count++; 340 dentry->d_lockref.count++;
360 return dentry; 341 return dentry;
361} 342}
362 343
363static inline struct dentry *dget(struct dentry *dentry) 344static inline struct dentry *dget(struct dentry *dentry)
364{ 345{
365 if (dentry) { 346 if (dentry)
366 spin_lock(&dentry->d_lock); 347 lockref_get(&dentry->d_lockref);
367 dget_dlock(dentry);
368 spin_unlock(&dentry->d_lock);
369 }
370 return dentry; 348 return dentry;
371} 349}
372 350