diff options
| author | Alex Williamson <alex.williamson@redhat.com> | 2013-09-04 13:25:44 -0400 |
|---|---|---|
| committer | Alex Williamson <alex.williamson@redhat.com> | 2013-09-04 13:25:44 -0400 |
| commit | 3bc4f3993b93dbf1f6402e2034a2e20eb07db807 (patch) | |
| tree | 592283e59e121b76355836295d6016fe33cfc5d1 /include/linux/dcache.h | |
| parent | 17638db1b88184d8895f3f4551c936d7480a1d3f (diff) | |
| parent | cb3e4330e697dffaf3d9cefebc9c7e7d39c89f2e (diff) | |
Merge remote branch 'origin/master' into next-merge
Diffstat (limited to 'include/linux/dcache.h')
| -rw-r--r-- | include/linux/dcache.h | 40 |
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 | ||
| 13 | struct nameidata; | 14 | struct nameidata; |
| 14 | struct path; | 15 | struct 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 | |||
| 103 | struct dentry { | 106 | struct 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 *); | |||
| 302 | extern struct dentry *__d_lookup_rcu(const struct dentry *parent, | 304 | extern 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 | */ | ||
| 314 | static 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 | |||
| 327 | static inline unsigned d_count(const struct dentry *dentry) | 307 | static 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 | */ |
| 338 | extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); | 318 | extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); |
| 319 | extern char *simple_dname(struct dentry *, char *, int); | ||
| 339 | 320 | ||
| 340 | extern char *__d_path(const struct path *, const struct path *, char *, int); | 321 | extern char *__d_path(const struct path *, const struct path *, char *, int); |
| 341 | extern char *d_absolute_path(const struct path *, char *, int); | 322 | extern char *d_absolute_path(const struct path *, char *, int); |
| @@ -356,17 +337,14 @@ extern char *dentry_path(struct dentry *, char *, int); | |||
| 356 | static inline struct dentry *dget_dlock(struct dentry *dentry) | 337 | static 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 | ||
| 363 | static inline struct dentry *dget(struct dentry *dentry) | 344 | static 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 | ||
