[PATCH 13/37] FS-Cache: Provide an add_wait_queue_tail() function

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <Trond.Myklebust@...>, <chuck.lever@...>, <casey@...>
Cc: <nfsv4@...>, <linux-kernel@...>, <linux-fsdevel@...>, <selinux@...>, <linux-security-module@...>, <dhowells@...>
Date: Wednesday, February 20, 2008 - 12:07 pm

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/pagemap.h |    7 +++++--
 include/linux/wait.h    |    1 +
 kernel/wait.c           |   18 ++++++++++++++++++
 mm/filemap.c            |    2 +-
 4 files changed, 25 insertions(+), 3 deletions(-)


diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index c5df3ae..ad9484f 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -225,8 +225,11 @@ static inline void wait_on_page_writeback(struct page *page)
 
 extern void end_page_writeback(struct page *page);
 
-/*
- * Wait for a PG_owner_priv_2 to become clear
+/**
+ * wait_on_page_owner_priv_2 - Wait for PG_owner_priv_2 to become clear
+ * @page: The page to monitor
+ *
+ * Wait for a PG_owner_priv_2 to become clear on the specified page.
  */
 static inline void wait_on_page_owner_priv_2(struct page *page)
 {
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 0081147..a6a6607 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 add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
+extern void add_wait_queue_tail(wait_queue_head_t *q, wait_queue_t *wait);
 extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait);
 extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
 
diff --git a/kernel/wait.c b/kernel/wait.c
index c275c56..191df0d 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -29,6 +29,24 @@ void 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 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 add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait)
 {
 	unsigned long flags;
diff --git a/mm/filemap.c b/mm/filemap.c
index 8951d67..b72e112 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -587,7 +587,7 @@ void end_page_writeback(struct page *page)
 EXPORT_SYMBOL(end_page_writeback);
 
 /**
- * end_page_own - Clear PG_owner_priv_2 and wake up any waiters
+ * end_page_owner_priv_2 - Clear PG_owner_priv_2 and wake up any waiters
  * @page: the page
  *
  * Clear PG_owner_priv_2 and wake up any processes waiting for that event.

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/37] Permit filesystem local caching, David Howells, (Wed Feb 20, 12:05 pm)
Re: [PATCH 00/37] Permit filesystem local caching, Daniel Phillips, (Wed Feb 20, 11:07 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Thu Feb 21, 10:55 am)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Thu Feb 21, 7:33 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Fri Feb 22, 12:14 pm)
Re: [PATCH 00/37] Permit filesystem local caching, Chris Mason, (Fri Feb 22, 9:52 am)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Fri Feb 22, 12:47 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Fri Feb 22, 12:12 pm)
Re: [PATCH 00/37] Permit filesystem local caching, Daniel Phillips, (Thu Feb 21, 6:44 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Thu Feb 21, 8:07 pm)
Re: [PATCH 00/37] Permit filesystem local caching, Daniel Phillips, (Thu Feb 21, 8:57 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Fri Feb 22, 8:48 am)
Re: [PATCH 00/37] Permit filesystem local caching, Daniel Phillips, (Fri Feb 22, 6:25 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Fri Feb 22, 9:22 pm)
RE: [PATCH 00/37] Permit filesystem local caching, Muntz, Daniel, (Thu Feb 21, 6:52 pm)
Re: [PATCH 00/37] Permit filesystem local caching, Kevin Coffman, (Thu Feb 21, 11:17 am)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Thu Feb 21, 8:31 am)
Re: [PATCH 00/37] Permit filesystem local caching, Serge E. Hallyn, (Wed Feb 20, 3:58 pm)
Re: [PATCH 00/37] Permit filesystem local caching, David Howells, (Wed Feb 20, 4:11 pm)
[PATCH 25/37] NFS: Define and create server-level objects, David Howells, (Wed Feb 20, 12:08 pm)
[PATCH 31/37] NFS: FS-Cache page management, David Howells, (Wed Feb 20, 12:08 pm)
[PATCH 36/37] NFS: Display local caching state, David Howells, (Wed Feb 20, 12:09 pm)
[PATCH 28/37] NFS: Use local disk inode cache, David Howells, (Wed Feb 20, 12:08 pm)
[PATCH 22/37] NFS: Add FS-Cache option bit and debug bit, David Howells, (Wed Feb 20, 12:07 pm)
[PATCH 19/37] CacheFiles: Export things for CacheFiles, David Howells, (Wed Feb 20, 12:07 pm)
[PATCH 13/37] FS-Cache: Provide an add_wait_queue_tail() fun..., David Howells, (Wed Feb 20, 12:07 pm)