]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: Add folio_end_read()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 30 Jul 2023 03:12:00 +0000 (23:12 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 4 Oct 2023 01:07:28 +0000 (21:07 -0400)
Provide a function for filesystems to call when they have finished
reading an entire folio.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/pagemap.h
mm/filemap.c

index 351c3b7f93a14ee3e7edafb17dbe128cd0e755f9..5bb2f5f802bcdbfd2bb222c9d0e2c1fa42ff22fc 100644 (file)
@@ -1129,6 +1129,7 @@ static inline void wait_on_page_locked(struct page *page)
        folio_wait_locked(page_folio(page));
 }
 
+void folio_end_read(struct folio *folio, bool success);
 void wait_on_page_writeback(struct page *page);
 void folio_wait_writeback(struct folio *folio);
 int folio_wait_writeback_killable(struct folio *folio);
index f0a15ce1bd1ba1cca4856e05e70d9e44128709b4..ea317cdf9532c6ee1809616fc4dab67065e788e1 100644 (file)
@@ -1527,6 +1527,28 @@ void folio_unlock(struct folio *folio)
 }
 EXPORT_SYMBOL(folio_unlock);
 
+/**
+ * folio_end_read - End read on a folio.
+ * @folio: The folio.
+ * @success: True if all reads completed successfully.
+ *
+ * When all reads against a folio have completed, filesystems should
+ * call this function to let the pagecache know that no more reads
+ * are outstanding.  This will unlock the folio and wake up any thread
+ * sleeping on the lock.  The folio will also be marked uptodate if all
+ * reads succeeded.
+ *
+ * Context: May be called from interrupt or process context.  May not be
+ * called from NMI context.
+ */
+void folio_end_read(struct folio *folio, bool success)
+{
+       if (likely(success))
+               folio_mark_uptodate(folio);
+       folio_unlock(folio);
+}
+EXPORT_SYMBOL(folio_end_read);
+
 /**
  * folio_end_private_2 - Clear PG_private_2 and wake any waiters.
  * @folio: The folio.