diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-25 16:39:14 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-15 22:04:17 -0500 |
| commit | 2bc74feba12fbf052ec97aee8624c9f13593a9ac (patch) | |
| tree | 411129cf4fe962f1afc2c9bca127d9db0924fbfd | |
| parent | b26d4cd385fc51e8844e2cdf9ba2051f5bba11a5 (diff) | |
take read_seqbegin_or_lock() and friends to seqlock.h
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | fs/dcache.c | 29 | ||||
| -rw-r--r-- | include/linux/seqlock.h | 29 |
2 files changed, 29 insertions, 29 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 0a38ef8d7f00..667e23ab0b4c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
| @@ -88,35 +88,6 @@ EXPORT_SYMBOL(rename_lock); | |||
| 88 | 88 | ||
| 89 | static struct kmem_cache *dentry_cache __read_mostly; | 89 | static struct kmem_cache *dentry_cache __read_mostly; |
| 90 | 90 | ||
| 91 | /** | ||
| 92 | * read_seqbegin_or_lock - begin a sequence number check or locking block | ||
| 93 | * @lock: sequence lock | ||
| 94 | * @seq : sequence number to be checked | ||
| 95 | * | ||
| 96 | * First try it once optimistically without taking the lock. If that fails, | ||
| 97 | * take the lock. The sequence number is also used as a marker for deciding | ||
| 98 | * whether to be a reader (even) or writer (odd). | ||
| 99 | * N.B. seq must be initialized to an even number to begin with. | ||
| 100 | */ | ||
| 101 | static inline void read_seqbegin_or_lock(seqlock_t *lock, int *seq) | ||
| 102 | { | ||
| 103 | if (!(*seq & 1)) /* Even */ | ||
| 104 | *seq = read_seqbegin(lock); | ||
| 105 | else /* Odd */ | ||
| 106 | read_seqlock_excl(lock); | ||
| 107 | } | ||
| 108 | |||
| 109 | static inline int need_seqretry(seqlock_t *lock, int seq) | ||
| 110 | { | ||
| 111 | return !(seq & 1) && read_seqretry(lock, seq); | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline void done_seqretry(seqlock_t *lock, int seq) | ||
| 115 | { | ||
| 116 | if (seq & 1) | ||
| 117 | read_sequnlock_excl(lock); | ||
| 118 | } | ||
| 119 | |||
| 120 | /* | 91 | /* |
| 121 | * This is the single most critical data structure when it comes | 92 | * This is the single most critical data structure when it comes |
| 122 | * to the dcache: the hashtable for lookups. Somebody should try | 93 | * to the dcache: the hashtable for lookups. Somebody should try |
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 1e8a8b6e837d..cf87a24c0f92 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h | |||
| @@ -354,6 +354,35 @@ static inline void read_sequnlock_excl(seqlock_t *sl) | |||
| 354 | spin_unlock(&sl->lock); | 354 | spin_unlock(&sl->lock); |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | /** | ||
| 358 | * read_seqbegin_or_lock - begin a sequence number check or locking block | ||
| 359 | * @lock: sequence lock | ||
| 360 | * @seq : sequence number to be checked | ||
| 361 | * | ||
| 362 | * First try it once optimistically without taking the lock. If that fails, | ||
| 363 | * take the lock. The sequence number is also used as a marker for deciding | ||
| 364 | * whether to be a reader (even) or writer (odd). | ||
| 365 | * N.B. seq must be initialized to an even number to begin with. | ||
| 366 | */ | ||
| 367 | static inline void read_seqbegin_or_lock(seqlock_t *lock, int *seq) | ||
| 368 | { | ||
| 369 | if (!(*seq & 1)) /* Even */ | ||
| 370 | *seq = read_seqbegin(lock); | ||
| 371 | else /* Odd */ | ||
| 372 | read_seqlock_excl(lock); | ||
| 373 | } | ||
| 374 | |||
| 375 | static inline int need_seqretry(seqlock_t *lock, int seq) | ||
| 376 | { | ||
| 377 | return !(seq & 1) && read_seqretry(lock, seq); | ||
| 378 | } | ||
| 379 | |||
| 380 | static inline void done_seqretry(seqlock_t *lock, int seq) | ||
| 381 | { | ||
| 382 | if (seq & 1) | ||
| 383 | read_sequnlock_excl(lock); | ||
| 384 | } | ||
| 385 | |||
| 357 | static inline void read_seqlock_excl_bh(seqlock_t *sl) | 386 | static inline void read_seqlock_excl_bh(seqlock_t *sl) |
| 358 | { | 387 | { |
| 359 | spin_lock_bh(&sl->lock); | 388 | spin_lock_bh(&sl->lock); |
