Skip to content

Commit

Permalink
btrfs: don't stop integrity writeback too early
Browse files Browse the repository at this point in the history
commit effa24f upstream.

extent_write_cache_pages stops writing pages as soon as nr_to_write hits
zero.  That is the right thing for opportunistic writeback, but incorrect
for data integrity writeback, which needs to ensure that no dirty pages
are left in the range.  Thus only stop the writeback for WB_SYNC_NONE
if nr_to_write hits 0.

This is a port of write_cache_pages changes in commit 05fe478
("mm: write_cache_pages integrity fix").

Note that I've only trigger the problem with other changes to the btrfs
writeback code, but this condition seems worthwhile fixing anyway.

CC: stable@vger.kernel.org # 4.14+
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
[ updated comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Christoph Hellwig authored and gregkh committed Aug 16, 2023
1 parent 4e18c82 commit 504d81c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/btrfs/extent_io.c
Expand Up @@ -3015,11 +3015,12 @@ int btree_write_cache_pages(struct address_space *mapping,
}

/*
* the filesystem may choose to bump up nr_to_write.
* The filesystem may choose to bump up nr_to_write.
* We have to make sure to honor the new nr_to_write
* at any time
* at any time.
*/
nr_to_write_done = wbc->nr_to_write <= 0;
nr_to_write_done = (wbc->sync_mode == WB_SYNC_NONE &&
wbc->nr_to_write <= 0);
}
pagevec_release(&pvec);
cond_resched();
Expand Down

0 comments on commit 504d81c

Please sign in to comment.