fs: use writeback_iter directly in mpage_writepages
PATCH 1/1 fs: use writeback_iter directly in mpage_writepages
Stop using write_cache_pages and use writeback_iter directly. This removes an indirect call per written folio and makes the code easier to follow.
--- fs/mpage.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/mpage.c +7 -6
@@ -445,10 +445,9 @@ static void clean_buffers(struct folio *folio, unsigned first_unmapped)try_to_free_buffers (folio); } -static int __mpage_writepage (struct folio *folio,struct writeback_control *wbc, -void *data) +static int mpage_write_folio (struct writeback_control *wbc,struct folio *folio, +struct mpage_data *mpd) { -struct mpage_data *mpd = data;struct bio *bio = mpd->bio;struct address_space *mapping = folio->mapping;struct inode *inode = mapping->host;
@@ -656,14 +655,16 @@ mpage_writepages(struct address_space *mapping,struct mpage_data mpd = { .get_block = get_block, }; +struct folio *folio =NULL ;struct blk_plug plug; -int ret; +int error;blk_start_plug (&plug); - ret =write_cache_pages (mapping, wbc, __mpage_writepage, &mpd); +while ((folio =writeback_iter (mapping, wbc, folio, &error))) + error =mpage_write_folio (wbc, folio, &mpd);if (mpd.bio)mpage_bio_submit_write (mpd.bio);blk_finish_plug (&plug); -return ret; +return error; }EXPORT_SYMBOL (mpage_writepages);
Signature · 1 line
2.47.2
Looks good,
Quoted 5 lines · Christoph Hellwig
Stop using
write_cache_pagesand usewriteback_iterdirectly. This removes an indirect call per written folio and makes the code easier to follow.Signed-off-by Christoph Hellwig <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 44 lines
--- fs/mpage.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)fs/mpage.c +7
-6@@ -445,10 +445,9 @@ static void clean_buffers(struct folio *folio, unsigned first_unmapped)try_to_free_buffers (folio); } -static int __mpage_writepage (struct folio *folio,struct writeback_control *wbc, -void *data) +static int mpage_write_folio (struct writeback_control *wbc,struct folio *folio, +struct mpage_data *mpd) { -struct mpage_data *mpd = data;struct bio *bio = mpd->bio;struct address_space *mapping = folio->mapping;struct inode *inode = mapping->host;@@ -656,14 +655,16 @@ mpage_writepages(struct address_space *mapping,struct mpage_data mpd = { .get_block = get_block, }; +struct folio *folio =NULL ;struct blk_plug plug; -int ret; +int error;blk_start_plug (&plug); - ret =write_cache_pages (mapping, wbc, __mpage_writepage, &mpd); +while ((folio =writeback_iter (mapping, wbc, folio, &error))) + error =mpage_write_folio (wbc, folio, &mpd);if (mpd.bio)mpage_bio_submit_write (mpd.bio);blk_finish_plug (&plug); -return ret; +return error; }EXPORT_SYMBOL (mpage_writepages);Signature · 1 line
2.47.2
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 5 lines · Christoph Hellwig
Stop using
write_cache_pagesand usewriteback_iterdirectly. This removes an indirect call per written folio and makes the code easier to follow.
Applied to the vfs-6.16.misc branch of the vfs/vfs.git tree. Patches in the vfs-6.16.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-6.16.misc
[1/1] fs: use writeback_iter directly in mpage_writepages
https://git.kernel.org/vfs/vfs/c/bb01e8cc10f0