mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
writeback: account the number of pages written back
nr_to_write is a count of pages, so we need to decrease it by the number
of pages in the folio we just wrote, not by 1. Most callers specify
either LONG_MAX or 1, so are unaffected, but writeback_sb_inodes() might
end up writing 512x as many pages as it asked for.
Dave added:
: XFS is the only filesystem this would affect, right? AFAIA, nothing
: else enables large folios and uses writeback through
: write_cache_pages() at this point...
:
: In which case, I'd be surprised if much difference, if any, gets
: noticed by anyone.
Link: https://lkml.kernel.org/r/20230628185548.981888-1-willy@infradead.org
Fixes: 793917d997
("mm/readahead: Add large folio readahead")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Jan Kara <jack@suse.cz>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
6dca4ac6fc
commit
8344a3d44b
1 changed files with 5 additions and 3 deletions
|
@ -2434,6 +2434,7 @@ int write_cache_pages(struct address_space *mapping,
|
||||||
|
|
||||||
for (i = 0; i < nr_folios; i++) {
|
for (i = 0; i < nr_folios; i++) {
|
||||||
struct folio *folio = fbatch.folios[i];
|
struct folio *folio = fbatch.folios[i];
|
||||||
|
unsigned long nr;
|
||||||
|
|
||||||
done_index = folio->index;
|
done_index = folio->index;
|
||||||
|
|
||||||
|
@ -2471,6 +2472,7 @@ int write_cache_pages(struct address_space *mapping,
|
||||||
|
|
||||||
trace_wbc_writepage(wbc, inode_to_bdi(mapping->host));
|
trace_wbc_writepage(wbc, inode_to_bdi(mapping->host));
|
||||||
error = writepage(folio, wbc, data);
|
error = writepage(folio, wbc, data);
|
||||||
|
nr = folio_nr_pages(folio);
|
||||||
if (unlikely(error)) {
|
if (unlikely(error)) {
|
||||||
/*
|
/*
|
||||||
* Handle errors according to the type of
|
* Handle errors according to the type of
|
||||||
|
@ -2489,8 +2491,7 @@ int write_cache_pages(struct address_space *mapping,
|
||||||
error = 0;
|
error = 0;
|
||||||
} else if (wbc->sync_mode != WB_SYNC_ALL) {
|
} else if (wbc->sync_mode != WB_SYNC_ALL) {
|
||||||
ret = error;
|
ret = error;
|
||||||
done_index = folio->index +
|
done_index = folio->index + nr;
|
||||||
folio_nr_pages(folio);
|
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2504,7 +2505,8 @@ int write_cache_pages(struct address_space *mapping,
|
||||||
* keep going until we have written all the pages
|
* keep going until we have written all the pages
|
||||||
* we tagged for writeback prior to entering this loop.
|
* we tagged for writeback prior to entering this loop.
|
||||||
*/
|
*/
|
||||||
if (--wbc->nr_to_write <= 0 &&
|
wbc->nr_to_write -= nr;
|
||||||
|
if (wbc->nr_to_write <= 0 &&
|
||||||
wbc->sync_mode == WB_SYNC_NONE) {
|
wbc->sync_mode == WB_SYNC_NONE) {
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue