summaryrefslogtreecommitdiff
path: root/include/linux/closure.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-06-28 18:11:46 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-06-28 18:26:04 -0400
commit34b5654d9eb1999704e75d964645e3aa9b78e249 (patch)
tree27269b040f9128cf33155a9ca47038703efc5606 /include/linux/closure.h
parentb0eb3c29304f9a4ca39c8534bb6476b170b2a7d0 (diff)
Update bcachefs sources to 9404a01d3dc5 bcachefs: Make read_only a mount option again, but hiddenv1.9.2
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux/closure.h')
-rw-r--r--include/linux/closure.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/closure.h b/include/linux/closure.h
index 99155df1..59b8c06b 100644
--- a/include/linux/closure.h
+++ b/include/linux/closure.h
@@ -285,6 +285,21 @@ static inline void closure_get(struct closure *cl)
}
/**
+ * closure_get_not_zero
+ */
+static inline bool closure_get_not_zero(struct closure *cl)
+{
+ unsigned old = atomic_read(&cl->remaining);
+ do {
+ if (!(old & CLOSURE_REMAINING_MASK))
+ return false;
+
+ } while (!atomic_try_cmpxchg_acquire(&cl->remaining, &old, old + 1));
+
+ return true;
+}
+
+/**
* closure_init - Initialize a closure, setting the refcount to 1
* @cl: closure to initialize
* @parent: parent of the new closure. cl will take a refcount on it for its
@@ -310,6 +325,12 @@ static inline void closure_init_stack(struct closure *cl)
atomic_set(&cl->remaining, CLOSURE_REMAINING_INITIALIZER);
}
+static inline void closure_init_stack_release(struct closure *cl)
+{
+ memset(cl, 0, sizeof(struct closure));
+ atomic_set_release(&cl->remaining, CLOSURE_REMAINING_INITIALIZER);
+}
+
/**
* closure_wake_up - wake up all closures on a wait list,
* with memory barrier
@@ -355,6 +376,8 @@ do { \
*/
#define closure_return(_cl) continue_at((_cl), NULL, NULL)
+void closure_return_sync(struct closure *cl);
+
/**
* continue_at_nobarrier - jump to another function without barrier
*