Skip to content

Commit 385e1ca

Browse files
committed
CacheFiles: Permit the page lock state to be monitored
Add a function to install a monitor on the page lock waitqueue for a particular page, thus allowing the page being unlocked to be detected. This is used by CacheFiles to detect read completion on a page in the backing filesystem so that it can then copy the data to the waiting netfs page. Signed-off-by: David Howells <[email protected]> Acked-by: Steve Dickson <[email protected]> Acked-by: Trond Myklebust <[email protected]> Acked-by: Rik van Riel <[email protected]> Acked-by: Al Viro <[email protected]> Tested-by: Daire Byrne <[email protected]>
1 parent b510882 commit 385e1ca

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

include/linux/pagemap.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ static inline void wait_on_page_writeback(struct page *page)
383383

384384
extern void end_page_writeback(struct page *page);
385385

386+
/*
387+
* Add an arbitrary waiter to a page's wait queue
388+
*/
389+
extern void add_page_wait_queue(struct page *page, wait_queue_t *waiter);
390+
386391
/*
387392
* Fault a userspace page into pagetables. Return non-zero on a fault.
388393
*

mm/filemap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,24 @@ void wait_on_page_bit(struct page *page, int bit_nr)
564564
}
565565
EXPORT_SYMBOL(wait_on_page_bit);
566566

567+
/**
568+
* add_page_wait_queue - Add an arbitrary waiter to a page's wait queue
569+
* @page - Page defining the wait queue of interest
570+
* @waiter - Waiter to add to the queue
571+
*
572+
* Add an arbitrary @waiter to the wait queue for the nominated @page.
573+
*/
574+
void add_page_wait_queue(struct page *page, wait_queue_t *waiter)
575+
{
576+
wait_queue_head_t *q = page_waitqueue(page);
577+
unsigned long flags;
578+
579+
spin_lock_irqsave(&q->lock, flags);
580+
__add_wait_queue(q, waiter);
581+
spin_unlock_irqrestore(&q->lock, flags);
582+
}
583+
EXPORT_SYMBOL_GPL(add_page_wait_queue);
584+
567585
/**
568586
* unlock_page - unlock a locked page
569587
* @page: the page

0 commit comments

Comments
 (0)