Skip to content

Commit 0b23704

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm: add folio_end_read()
Provide a function for filesystems to call when they have finished reading an entire folio. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f45b494 commit 0b23704

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

include/linux/pagemap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ static inline void wait_on_page_locked(struct page *page)
11011101
folio_wait_locked(page_folio(page));
11021102
}
11031103

1104+
void folio_end_read(struct folio *folio, bool success);
11041105
void wait_on_page_writeback(struct page *page);
11051106
void folio_wait_writeback(struct folio *folio);
11061107
int folio_wait_writeback_killable(struct folio *folio);

mm/filemap.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,28 @@ void folio_unlock(struct folio *folio)
15251525
}
15261526
EXPORT_SYMBOL(folio_unlock);
15271527

1528+
/**
1529+
* folio_end_read - End read on a folio.
1530+
* @folio: The folio.
1531+
* @success: True if all reads completed successfully.
1532+
*
1533+
* When all reads against a folio have completed, filesystems should
1534+
* call this function to let the pagecache know that no more reads
1535+
* are outstanding. This will unlock the folio and wake up any thread
1536+
* sleeping on the lock. The folio will also be marked uptodate if all
1537+
* reads succeeded.
1538+
*
1539+
* Context: May be called from interrupt or process context. May not be
1540+
* called from NMI context.
1541+
*/
1542+
void folio_end_read(struct folio *folio, bool success)
1543+
{
1544+
if (likely(success))
1545+
folio_mark_uptodate(folio);
1546+
folio_unlock(folio);
1547+
}
1548+
EXPORT_SYMBOL(folio_end_read);
1549+
15281550
/**
15291551
* folio_end_private_2 - Clear PG_private_2 and wake any waiters.
15301552
* @folio: The folio.

0 commit comments

Comments
 (0)