summaryrefslogtreecommitdiff
path: root/linux/wait.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-04-20 17:01:39 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-04-21 15:47:15 -0400
commit6a83d70ef53042aa12bf0ea1f08b7b237783f114 (patch)
treef6442be818d4f7f043b4cb2b8caf34ea51ceeb92 /linux/wait.c
parent98f2c06d418d85557f39c6541295766457d68d53 (diff)
Update bcachefs sources to c9d875f9be1f bcachefs: Casefold is now a regular opts.h option
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'linux/wait.c')
-rw-r--r--linux/wait.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/linux/wait.c b/linux/wait.c
index b1f002b9..e5fe2cb9 100644
--- a/linux/wait.c
+++ b/linux/wait.c
@@ -248,3 +248,28 @@ void wait_for_completion(struct completion *x)
out:
spin_unlock_irq(&x->wait.lock);
}
+
+unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
+{
+ spin_lock_irq(&x->wait.lock);
+
+ if (!x->done) {
+ DECLARE_WAITQUEUE(wait, current);
+
+ __add_wait_queue_tail_exclusive(&x->wait, &wait);
+ do {
+ __set_current_state(TASK_UNINTERRUPTIBLE);
+ spin_unlock_irq(&x->wait.lock);
+
+ timeout = schedule_timeout(timeout);
+ spin_lock_irq(&x->wait.lock);
+ } while (!x->done);
+ __remove_wait_queue(&x->wait, &wait);
+ if (!x->done)
+ goto out;
+ }
+ x->done--;
+out:
+ spin_unlock_irq(&x->wait.lock);
+ return timeout;
+}