]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
vm: Add wait/unlock functions for PG_fscache
authorDavid Howells <dhowells@redhat.com>
Mon, 10 Feb 2020 10:00:21 +0000 (10:00 +0000)
committerDavid Howells <dhowells@redhat.com>
Thu, 21 Jan 2021 17:30:46 +0000 (17:30 +0000)
Add functions to unlock and wait for unlock of PG_fscache analogously with
those for PG_lock.

Signed-off-by: David Howells <dhowells@redhat.com>
include/linux/pagemap.h
mm/filemap.c

index d5570deff4003f0cec29eed2cfbb77b06a8f0cec..1fa160e682facead0954c28df56451626cabe272 100644 (file)
@@ -591,6 +591,7 @@ extern int __lock_page_async(struct page *page, struct wait_page_queue *wait);
 extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
                                unsigned int flags);
 extern void unlock_page(struct page *page);
+extern void unlock_page_fscache(struct page *page);
 
 /*
  * Return true if the page was successfully locked
@@ -681,6 +682,19 @@ static inline int wait_on_page_locked_killable(struct page *page)
        return wait_on_page_bit_killable(compound_head(page), PG_locked);
 }
 
+/**
+ * wait_on_page_fscache - Wait for PG_fscache to be cleared on a page
+ * @page: The page
+ *
+ * Wait for the fscache mark to be removed from a page, usually signifying the
+ * completion of a write from that page to the cache.
+ */
+static inline void wait_on_page_fscache(struct page *page)
+{
+       if (PagePrivate2(page))
+               wait_on_page_bit(compound_head(page), PG_fscache);
+}
+
 extern void put_and_wait_on_page_locked(struct page *page);
 
 void wait_on_page_writeback(struct page *page);
index 5c9d564317a5c5eb2e7f5c4edc6e5e3571bd9c2d..91fcae006d6482d001a36e4a325a5c90bb56149d 100644 (file)
@@ -1466,6 +1466,24 @@ void unlock_page(struct page *page)
 }
 EXPORT_SYMBOL(unlock_page);
 
+/**
+ * unlock_page_fscache - Unlock a page pinned with PG_fscache
+ * @page: The page
+ *
+ * Unlocks the page and wakes up sleepers in wait_on_page_fscache().  Also
+ * wakes those waiting for the lock and writeback bits because the wakeup
+ * mechanism is shared.  But that's OK - those sleepers will just go back to
+ * sleep.
+ */
+void unlock_page_fscache(struct page *page)
+{
+       page = compound_head(page);
+       VM_BUG_ON_PAGE(!PagePrivate2(page), page);
+       clear_bit_unlock(PG_fscache, &page->flags);
+       wake_up_page_bit(page, PG_fscache);
+}
+EXPORT_SYMBOL(unlock_page_fscache);
+
 /**
  * end_page_writeback - end writeback against a page
  * @page: the page