Skip to content

Commit 872617a

Browse files
boryaskdave
authored andcommitted
btrfs: implement launder_folio for clearing dirty page reserve
In the buffered write path, dirty pages can be said to "own" the qgroup reservation until they create an ordered_extent. It is possible for there to be outstanding dirty pages when a transaction is aborted, in which case there is no cancellation path for freeing this reservation and it is leaked. We do already walk the list of outstanding delalloc inodes in btrfs_destroy_delalloc_inodes() and call invalidate_inode_pages2() on them. This does *not* call btrfs_invalidate_folio(), as one might guess, but rather calls launder_folio() and release_folio(). Since this is a reservation associated with dirty pages only, rather than something associated with the private bit (ordered_extent is cancelled separately already in the cleanup transaction path), implementing this release should be done via launder_folio. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Boris Burkov <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 63447b7 commit 872617a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/btrfs/inode.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7202,6 +7202,12 @@ static void wait_subpage_spinlock(struct page *page)
72027202
spin_unlock_irq(&subpage->lock);
72037203
}
72047204

7205+
static int btrfs_launder_folio(struct folio *folio)
7206+
{
7207+
return btrfs_qgroup_free_data(folio_to_inode(folio), NULL, folio_pos(folio),
7208+
PAGE_SIZE, NULL);
7209+
}
7210+
72057211
static bool __btrfs_release_folio(struct folio *folio, gfp_t gfp_flags)
72067212
{
72077213
if (try_release_extent_mapping(&folio->page, gfp_flags)) {
@@ -10137,6 +10143,7 @@ static const struct address_space_operations btrfs_aops = {
1013710143
.writepages = btrfs_writepages,
1013810144
.readahead = btrfs_readahead,
1013910145
.invalidate_folio = btrfs_invalidate_folio,
10146+
.launder_folio = btrfs_launder_folio,
1014010147
.release_folio = btrfs_release_folio,
1014110148
.migrate_folio = btrfs_migrate_folio,
1014210149
.dirty_folio = filemap_dirty_folio,

0 commit comments

Comments
 (0)