diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/semaphore.h | 43 | ||||
-rw-r--r-- | include/linux/six.h | 13 | ||||
-rw-r--r-- | include/linux/types.h | 1 | ||||
-rw-r--r-- | include/trace/events/bcachefs.h | 6 |
4 files changed, 56 insertions, 7 deletions
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h new file mode 100644 index 00000000..498e717a --- /dev/null +++ b/include/linux/semaphore.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2008 Intel Corporation + * Author: Matthew Wilcox <willy@linux.intel.com> + * + * Please see kernel/locking/semaphore.c for documentation of these functions + */ +#ifndef __LINUX_SEMAPHORE_H +#define __LINUX_SEMAPHORE_H + +#include <linux/list.h> +#include <linux/spinlock.h> + +/* Please don't access any members of this structure directly */ +struct semaphore { + raw_spinlock_t lock; + unsigned int count; + struct list_head wait_list; +}; + +#define __SEMAPHORE_INITIALIZER(name, n) \ +{ \ + .lock = __RAW_SPIN_LOCK_UNLOCKED((name).lock), \ + .count = n, \ + .wait_list = LIST_HEAD_INIT((name).wait_list), \ +} + +#define DEFINE_SEMAPHORE(name) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) + +static inline void sema_init(struct semaphore *sem, int val) +{ + *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val); +} + +extern void down(struct semaphore *sem); +extern int __must_check down_interruptible(struct semaphore *sem); +extern int __must_check down_killable(struct semaphore *sem); +extern int __must_check down_trylock(struct semaphore *sem); +extern int __must_check down_timeout(struct semaphore *sem, long); +extern void up(struct semaphore *sem); + +#endif /* __LINUX_SEMAPHORE_H */ diff --git a/include/linux/six.h b/include/linux/six.h index 0fb1b2f4..a16e94f4 100644 --- a/include/linux/six.h +++ b/include/linux/six.h @@ -115,6 +115,8 @@ struct six_lock { #endif }; +typedef int (*six_lock_should_sleep_fn)(struct six_lock *lock, void *); + static __always_inline void __six_lock_init(struct six_lock *lock, const char *name, struct lock_class_key *key) @@ -141,7 +143,7 @@ do { \ #define __SIX_LOCK(type) \ bool six_trylock_##type(struct six_lock *); \ bool six_relock_##type(struct six_lock *, u32); \ -void six_lock_##type(struct six_lock *); \ +int six_lock_##type(struct six_lock *, six_lock_should_sleep_fn, void *);\ void six_unlock_##type(struct six_lock *); __SIX_LOCK(read) @@ -167,14 +169,15 @@ static inline bool six_trylock_type(struct six_lock *lock, enum six_lock_type ty } static inline bool six_relock_type(struct six_lock *lock, enum six_lock_type type, - unsigned seq) + unsigned seq) { SIX_LOCK_DISPATCH(type, six_relock, lock, seq); } -static inline void six_lock_type(struct six_lock *lock, enum six_lock_type type) +static inline int six_lock_type(struct six_lock *lock, enum six_lock_type type, + six_lock_should_sleep_fn should_sleep_fn, void *p) { - SIX_LOCK_DISPATCH(type, six_lock, lock); + SIX_LOCK_DISPATCH(type, six_lock, lock, should_sleep_fn, p); } static inline void six_unlock_type(struct six_lock *lock, enum six_lock_type type) @@ -189,4 +192,6 @@ bool six_trylock_convert(struct six_lock *, enum six_lock_type, void six_lock_increment(struct six_lock *, enum six_lock_type); +void six_lock_wakeup_all(struct six_lock *); + #endif /* _LINUX_SIX_H */ diff --git a/include/linux/types.h b/include/linux/types.h index ee94a222..387c3831 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -27,6 +27,7 @@ typedef unsigned gfp_t; #define GFP_NOFS 0 #define GFP_NOIO 0 #define GFP_NOWAIT 0 +#define __GFP_FS 0 #define __GFP_IO 0 #define __GFP_NOWARN 0 #define __GFP_NORETRY 0 diff --git a/include/trace/events/bcachefs.h b/include/trace/events/bcachefs.h index 01a9cc73..bafbccaf 100644 --- a/include/trace/events/bcachefs.h +++ b/include/trace/events/bcachefs.h @@ -144,8 +144,8 @@ DECLARE_EVENT_CLASS(btree_node, TP_fast_assign( memcpy(__entry->uuid, c->sb.user_uuid.b, 16); - __entry->level = b->level; - __entry->id = b->btree_id; + __entry->level = b->c.level; + __entry->id = b->c.btree_id; __entry->inode = b->key.k.p.inode; __entry->offset = b->key.k.p.offset; ), @@ -262,7 +262,7 @@ TRACE_EVENT(btree_insert_key, ), TP_fast_assign( - __entry->id = b->btree_id; + __entry->id = b->c.btree_id; __entry->inode = k->k.p.inode; __entry->offset = k->k.p.offset; __entry->size = k->k.size; |