Commit 98103258 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Andrew Morton

writeback: also update wbc->nr_to_write on writeback failure

When exiting write_cache_pages early due to a non-integrity write failure,
wbc->nr_to_write currently doesn't account for the folio we just failed to
write.  This doesn't matter because the callers always ingore the value on
a failure, but moving the update to common code will allow to simplify the
code, so do it.

Link: https://lkml.kernel.org/r/20240215063649.2164017-5-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Acked-by: default avatarDave Chinner <dchinner@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent a02829f0
...@@ -2473,6 +2473,7 @@ int write_cache_pages(struct address_space *mapping, ...@@ -2473,6 +2473,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); nr = folio_nr_pages(folio);
wbc->nr_to_write -= nr;
if (unlikely(error)) { if (unlikely(error)) {
/* /*
* Handle errors according to the type of * Handle errors according to the type of
...@@ -2506,7 +2507,6 @@ int write_cache_pages(struct address_space *mapping, ...@@ -2506,7 +2507,6 @@ int write_cache_pages(struct address_space *mapping,
* we tagged for writeback prior to entering this loop. * we tagged for writeback prior to entering this loop.
*/ */
done_index = folio->index + nr; done_index = folio->index + nr;
wbc->nr_to_write -= nr;
if (wbc->nr_to_write <= 0 && if (wbc->nr_to_write <= 0 &&
wbc->sync_mode == WB_SYNC_NONE) { wbc->sync_mode == WB_SYNC_NONE) {
done = 1; done = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment