mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-22 02:20:40 +00:00
six locks: six_lock_readers_add()
This moves a helper out of the bcachefs code that shouldn't have been there, since it touches six lock internals. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
f375d6ca58
commit
01bf56a977
3 changed files with 14 additions and 12 deletions
|
@ -24,16 +24,6 @@ void bch2_assert_btree_nodes_not_locked(void)
|
||||||
|
|
||||||
/* Btree node locking: */
|
/* Btree node locking: */
|
||||||
|
|
||||||
static inline void six_lock_readers_add(struct six_lock *lock, int nr)
|
|
||||||
{
|
|
||||||
if (lock->readers)
|
|
||||||
this_cpu_add(*lock->readers, nr);
|
|
||||||
else if (nr > 0)
|
|
||||||
atomic64_add(__SIX_VAL(read_lock, nr), &lock->state.counter);
|
|
||||||
else
|
|
||||||
atomic64_sub(__SIX_VAL(read_lock, -nr), &lock->state.counter);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct six_lock_count bch2_btree_node_lock_counts(struct btree_trans *trans,
|
struct six_lock_count bch2_btree_node_lock_counts(struct btree_trans *trans,
|
||||||
struct btree_path *skip,
|
struct btree_path *skip,
|
||||||
struct btree_bkey_cached_common *b,
|
struct btree_bkey_cached_common *b,
|
||||||
|
|
|
@ -40,6 +40,8 @@ struct six_lock_vals {
|
||||||
enum six_lock_type unlock_wakeup;
|
enum six_lock_type unlock_wakeup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define __SIX_VAL(field, _v) (((union six_lock_state) { .field = _v }).v)
|
||||||
|
|
||||||
#define __SIX_LOCK_HELD_read __SIX_VAL(read_lock, ~0)
|
#define __SIX_LOCK_HELD_read __SIX_VAL(read_lock, ~0)
|
||||||
#define __SIX_LOCK_HELD_intent __SIX_VAL(intent_lock, ~0)
|
#define __SIX_LOCK_HELD_intent __SIX_VAL(intent_lock, ~0)
|
||||||
#define __SIX_LOCK_HELD_write __SIX_VAL(seq, 1)
|
#define __SIX_LOCK_HELD_write __SIX_VAL(seq, 1)
|
||||||
|
@ -847,3 +849,14 @@ struct six_lock_count six_lock_counts(struct six_lock *lock)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(six_lock_counts);
|
EXPORT_SYMBOL_GPL(six_lock_counts);
|
||||||
|
|
||||||
|
void six_lock_readers_add(struct six_lock *lock, int nr)
|
||||||
|
{
|
||||||
|
if (lock->readers)
|
||||||
|
this_cpu_add(*lock->readers, nr);
|
||||||
|
else if (nr > 0)
|
||||||
|
atomic64_add(__SIX_VAL(read_lock, nr), &lock->state.counter);
|
||||||
|
else
|
||||||
|
atomic64_sub(__SIX_VAL(read_lock, -nr), &lock->state.counter);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(six_lock_readers_add);
|
||||||
|
|
|
@ -152,8 +152,6 @@ do { \
|
||||||
__six_lock_init((lock), #lock, &__key); \
|
__six_lock_init((lock), #lock, &__key); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define __SIX_VAL(field, _v) (((union six_lock_state) { .field = _v }).v)
|
|
||||||
|
|
||||||
#define __SIX_LOCK(type) \
|
#define __SIX_LOCK(type) \
|
||||||
bool six_trylock_ip_##type(struct six_lock *, unsigned long); \
|
bool six_trylock_ip_##type(struct six_lock *, unsigned long); \
|
||||||
bool six_relock_ip_##type(struct six_lock *, u32, unsigned long); \
|
bool six_relock_ip_##type(struct six_lock *, u32, unsigned long); \
|
||||||
|
@ -258,5 +256,6 @@ struct six_lock_count {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct six_lock_count six_lock_counts(struct six_lock *);
|
struct six_lock_count six_lock_counts(struct six_lock *);
|
||||||
|
void six_lock_readers_add(struct six_lock *, int);
|
||||||
|
|
||||||
#endif /* _LINUX_SIX_H */
|
#endif /* _LINUX_SIX_H */
|
||||||
|
|
Loading…
Reference in a new issue