Skip to content

Commit 010054a

Browse files
Trond MyklebustAnna Schumaker
authored andcommitted
filemap: Add a version of folio_end_writeback that ignores dropbehind
Filesystems such as NFS may need to defer dropbehind until after their 2-stage writes are done. This adds a helper folio_end_writeback_no_dropbehind() that allows them to release the writeback flag without immediately dropping the folio. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
1 parent 24bbd53 commit 010054a

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

include/linux/pagemap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,7 @@ void folio_wait_writeback(struct folio *folio);
12211221
int folio_wait_writeback_killable(struct folio *folio);
12221222
void end_page_writeback(struct page *page);
12231223
void folio_end_writeback(struct folio *folio);
1224+
void folio_end_writeback_no_dropbehind(struct folio *folio);
12241225
void folio_end_dropbehind(struct folio *folio);
12251226
void folio_wait_stable(struct folio *folio);
12261227
void __folio_mark_dirty(struct folio *folio, struct address_space *, int warn);

mm/filemap.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,14 +1628,15 @@ void folio_end_dropbehind(struct folio *folio)
16281628
EXPORT_SYMBOL_GPL(folio_end_dropbehind);
16291629

16301630
/**
1631-
* folio_end_writeback - End writeback against a folio.
1631+
* folio_end_writeback_no_dropbehind - End writeback against a folio.
16321632
* @folio: The folio.
16331633
*
16341634
* The folio must actually be under writeback.
1635+
* This call is intended for filesystems that need to defer dropbehind.
16351636
*
16361637
* Context: May be called from process or interrupt context.
16371638
*/
1638-
void folio_end_writeback(struct folio *folio)
1639+
void folio_end_writeback_no_dropbehind(struct folio *folio)
16391640
{
16401641
VM_BUG_ON_FOLIO(!folio_test_writeback(folio), folio);
16411642

@@ -1651,18 +1652,34 @@ void folio_end_writeback(struct folio *folio)
16511652
folio_rotate_reclaimable(folio);
16521653
}
16531654

1655+
if (__folio_end_writeback(folio))
1656+
folio_wake_bit(folio, PG_writeback);
1657+
1658+
acct_reclaim_writeback(folio);
1659+
}
1660+
EXPORT_SYMBOL_GPL(folio_end_writeback_no_dropbehind);
1661+
1662+
/**
1663+
* folio_end_writeback - End writeback against a folio.
1664+
* @folio: The folio.
1665+
*
1666+
* The folio must actually be under writeback.
1667+
*
1668+
* Context: May be called from process or interrupt context.
1669+
*/
1670+
void folio_end_writeback(struct folio *folio)
1671+
{
1672+
VM_BUG_ON_FOLIO(!folio_test_writeback(folio), folio);
1673+
16541674
/*
16551675
* Writeback does not hold a folio reference of its own, relying
16561676
* on truncation to wait for the clearing of PG_writeback.
16571677
* But here we must make sure that the folio is not freed and
16581678
* reused before the folio_wake_bit().
16591679
*/
16601680
folio_get(folio);
1661-
if (__folio_end_writeback(folio))
1662-
folio_wake_bit(folio, PG_writeback);
1663-
1681+
folio_end_writeback_no_dropbehind(folio);
16641682
folio_end_dropbehind(folio);
1665-
acct_reclaim_writeback(folio);
16661683
folio_put(folio);
16671684
}
16681685
EXPORT_SYMBOL(folio_end_writeback);

0 commit comments

Comments
 (0)