Skip to content

Commit effa24f

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: don't stop integrity writeback too early
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>
1 parent fc1f91b commit effa24f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/btrfs/extent_io.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,11 +2164,12 @@ static int extent_write_cache_pages(struct address_space *mapping,
21642164
}
21652165

21662166
/*
2167-
* the filesystem may choose to bump up nr_to_write.
2167+
* The filesystem may choose to bump up nr_to_write.
21682168
* We have to make sure to honor the new nr_to_write
2169-
* at any time
2169+
* at any time.
21702170
*/
2171-
nr_to_write_done = wbc->nr_to_write <= 0;
2171+
nr_to_write_done = (wbc->sync_mode == WB_SYNC_NONE &&
2172+
wbc->nr_to_write <= 0);
21722173
}
21732174
folio_batch_release(&fbatch);
21742175
cond_resched();

0 commit comments

Comments
 (0)