author: Matthew Wilcox (Oracle) <willy@infradead.org> 2023-06-28 19:55:48 +0100
committer: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2023-07-19 16:36:50 +0200
commit: e22ca18614d2dfb935d9b32fb13e76f6dccff783
parent: 22f127fffe72d3739e7e0cf4cae413102df2e356
Commit Summary:
Diffstat:
1 file changed, 5 insertions, 3 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index db7943999007..6faa09f1783b 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2434,6 +2434,7 @@ int write_cache_pages(struct address_space *mapping,
for (i = 0; i < nr_folios; i++) {
struct folio *folio = fbatch.folios[i];
+ unsigned long nr;
done_index = folio->index;
@@ -2471,6 +2472,7 @@ continue_unlock:
trace_wbc_writepage(wbc, inode_to_bdi(mapping->host));
error = writepage(folio, wbc, data);
+ nr = folio_nr_pages(folio);
if (unlikely(error)) {
/*
* Handle errors according to the type of
@@ -2489,8 +2491,7 @@ continue_unlock:
error = 0;
} else if (wbc->sync_mode != WB_SYNC_ALL) {
ret = error;
- done_index = folio->index +
- folio_nr_pages(folio);
+ done_index = folio->index + nr;
done = 1;
break;
}
@@ -2504,7 +2505,8 @@ continue_unlock:
* keep going until we have written all the pages
* 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) {
done = 1;
break;