Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dhowells@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Daire Byrne <Daire.Byrne@framestore.com>

+23
+5
include/linux/pagemap.h
··· 384 384 extern void end_page_writeback(struct page *page); 385 385 386 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 + 391 + /* 387 392 * Fault a userspace page into pagetables. Return non-zero on a fault. 388 393 * 389 394 * This assumes that two userspace pages are always sufficient. That's
+18
mm/filemap.c
··· 565 565 EXPORT_SYMBOL(wait_on_page_bit); 566 566 567 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 + 585 + /** 568 586 * unlock_page - unlock a locked page 569 587 * @page: the page 570 588 *