diff mbox series

iomap: convert iomap_writepages to writeack_iter

Message ID 20240412061614.1511629-1-hch@lst.de (mailing list archive)
State New
Headers show
Series iomap: convert iomap_writepages to writeack_iter | expand

Commit Message

Christoph Hellwig April 12, 2024, 6:16 a.m. UTC
This removes one indirect function call per folio, and adds type safety
by not casting through a void pointer.

Based on a patch by Matthew Wilcox.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap/buffered-io.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Darrick J. Wong April 12, 2024, 3:34 p.m. UTC | #1
[adding willy to cc just in case he sees something I didn't]

On Fri, Apr 12, 2024 at 08:16:14AM +0200, Christoph Hellwig wrote:
> This removes one indirect function call per folio, and adds type safety
> by not casting through a void pointer.
> 
> Based on a patch by Matthew Wilcox.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks like a straightforward conversion to me...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/iomap/buffered-io.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 4e8e41c8b3c0e4..e09441f4fceb6f 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1958,18 +1958,13 @@ static int iomap_writepage_map(struct iomap_writepage_ctx *wpc,
>  	return error;
>  }
>  
> -static int iomap_do_writepage(struct folio *folio,
> -		struct writeback_control *wbc, void *data)
> -{
> -	return iomap_writepage_map(data, wbc, folio);
> -}
> -
>  int
>  iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
>  		struct iomap_writepage_ctx *wpc,
>  		const struct iomap_writeback_ops *ops)
>  {
> -	int			ret;
> +	struct folio *folio = NULL;
> +	int error;
>  
>  	/*
>  	 * Writeback from reclaim context should never happen except in the case
> @@ -1980,8 +1975,9 @@ iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
>  		return -EIO;
>  
>  	wpc->ops = ops;
> -	ret = write_cache_pages(mapping, wbc, iomap_do_writepage, wpc);
> -	return iomap_submit_ioend(wpc, ret);
> +	while ((folio = writeback_iter(mapping, wbc, folio, &error)))
> +		error = iomap_writepage_map(wpc, wbc, folio);
> +	return iomap_submit_ioend(wpc, error);
>  }
>  EXPORT_SYMBOL_GPL(iomap_writepages);
>  
> -- 
> 2.39.2
> 
>
Mike Snitzer April 12, 2024, 7:11 p.m. UTC | #2
FYI, noticed a typo in the subject: s/writeack_iter/writeback_iter/
Christian Brauner April 15, 2024, 12:26 p.m. UTC | #3
On Fri, 12 Apr 2024 08:16:14 +0200, Christoph Hellwig wrote:
> This removes one indirect function call per folio, and adds type safety
> by not casting through a void pointer.
> 
> Based on a patch by Matthew Wilcox.
> 
> 

Applied to the vfs.iomap branch of the vfs/vfs.git tree.
Patches in the vfs.iomap 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.iomap

[1/1] iomap: convert iomap_writepages to writeack_iter
      https://git.kernel.org/vfs/vfs/c/0fac04e4e0ea
diff mbox series

Patch

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 4e8e41c8b3c0e4..e09441f4fceb6f 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1958,18 +1958,13 @@  static int iomap_writepage_map(struct iomap_writepage_ctx *wpc,
 	return error;
 }
 
-static int iomap_do_writepage(struct folio *folio,
-		struct writeback_control *wbc, void *data)
-{
-	return iomap_writepage_map(data, wbc, folio);
-}
-
 int
 iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
 		struct iomap_writepage_ctx *wpc,
 		const struct iomap_writeback_ops *ops)
 {
-	int			ret;
+	struct folio *folio = NULL;
+	int error;
 
 	/*
 	 * Writeback from reclaim context should never happen except in the case
@@ -1980,8 +1975,9 @@  iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
 		return -EIO;
 
 	wpc->ops = ops;
-	ret = write_cache_pages(mapping, wbc, iomap_do_writepage, wpc);
-	return iomap_submit_ioend(wpc, ret);
+	while ((folio = writeback_iter(mapping, wbc, folio, &error)))
+		error = iomap_writepage_map(wpc, wbc, folio);
+	return iomap_submit_ioend(wpc, error);
 }
 EXPORT_SYMBOL_GPL(iomap_writepages);