[PATCH 07/22] FS-Cache: Provide an add_wait_queue_tail() function

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <viro@...>, <hch@...>, <Trond.Myklebust@...>, <sds@...>, <casey@...>
Cc: <linux-kernel@...>, <selinux@...>, <linux-security-module@...>, <dhowells@...>
Date: Friday, September 21, 2007 - 10:47 am

Provide an add_wait_queue_tail() function to add a waiter to the back of a
wait queue instead of the front.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 include/linux/wait.h |    1 +
 kernel/wait.c        |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 0e68628..4cae7db 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -118,6 +118,7 @@ static inline int waitqueue_active(wait_queue_head_t *q)
 #define is_sync_wait(wait)	(!(wait) || ((wait)->private))
 
 extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
+extern void FASTCALL(add_wait_queue_tail(wait_queue_head_t *q, wait_queue_t * wait));
 extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
 extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
 
diff --git a/kernel/wait.c b/kernel/wait.c
index 444ddbf..7acc9cc 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -29,6 +29,24 @@ void fastcall add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
 }
 EXPORT_SYMBOL(add_wait_queue);
 
+/**
+ * add_wait_queue_tail - Add a waiter to the back of a waitqueue
+ * @q: the wait queue to append the waiter to
+ * @wait: the waiter to be queued
+ *
+ * Add a waiter to the back of a waitqueue so that it gets woken up last.
+ */
+void fastcall add_wait_queue_tail(wait_queue_head_t *q, wait_queue_t *wait)
+{
+	unsigned long flags;
+
+	wait->flags &= ~WQ_FLAG_EXCLUSIVE;
+	spin_lock_irqsave(&q->lock, flags);
+	__add_wait_queue_tail(q, wait);
+	spin_unlock_irqrestore(&q->lock, flags);
+}
+EXPORT_SYMBOL(add_wait_queue_tail);
+
 void fastcall add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait)
 {
 	unsigned long flags;

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/22] Introduce credential record, David Howells, (Fri Sep 21, 10:47 am)
[PATCH 01/22] CRED: Introduce a COW credentials record, David Howells, (Fri Sep 21, 10:47 am)
Re: [PATCH 00/22] Introduce credential record, David Howells, (Fri Sep 21, 10:58 am)
[PATCH 07/22] FS-Cache: Provide an add_wait_queue_tail() fun..., David Howells, (Fri Sep 21, 10:47 am)
Re: [PATCH 00/22] Introduce credential record, Casey Schaufler, (Fri Sep 21, 11:36 am)
Re: [PATCH 00/22] Introduce credential record, David Howells, (Fri Sep 21, 11:40 am)
Re: [PATCH 00/22] Introduce credential record, Casey Schaufler, (Fri Sep 21, 12:04 pm)
Re: [PATCH 00/22] Introduce credential record, David Howells, (Fri Sep 21, 7:18 pm)
[PATCH 22/22] FS-Cache: Make kAFS use FS-Cache, David Howells, (Fri Sep 21, 10:48 am)
[PATCH 20/22] AFS: Implement shared-writable mmap, David Howells, (Fri Sep 21, 10:48 am)
[PATCH 17/22] AFS: Add TestSetPageError(), David Howells, (Fri Sep 21, 10:48 am)
[PATCH 16/22] NFS: Display local caching state, David Howells, (Fri Sep 21, 10:48 am)
[PATCH 14/22] NFS: Use local caching, David Howells, (Fri Sep 21, 10:48 am)
Re: [PATCH 14/22] NFS: Use local caching, Peter Staubach, (Fri Sep 21, 1:00 pm)
Re: [PATCH 14/22] NFS: Use local caching, David Howells, (Fri Sep 21, 7:22 pm)
Re: [PATCH 14/22] NFS: Use local caching, David Howells, (Fri Sep 21, 7:37 pm)
Re: [PATCH 14/22] NFS: Use local caching, Peter Staubach, (Mon Sep 24, 9:31 am)
[PATCH 12/22] CacheFiles: Export things for CacheFiles, David Howells, (Fri Sep 21, 10:48 am)