From 6a83d70ef53042aa12bf0ea1f08b7b237783f114 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 20 Apr 2025 17:01:39 -0400 Subject: Update bcachefs sources to c9d875f9be1f bcachefs: Casefold is now a regular opts.h option Signed-off-by: Kent Overstreet --- linux/wait.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'linux/wait.c') 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; +} -- cgit v1.2.3