2024-01-25 11:31:47

by Christoph Hellwig

[permalink] [raw]
Subject: [PATCH 18/19] iomap: Convert iomap_writepages() to use for_each_writeback_folio()

From: Matthew Wilcox <[email protected]>

This removes one indirect function call per folio, and adds typesafety
by not casting through a void pointer.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
---
fs/iomap/buffered-io.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 093c4515b22a53..58b3661f5eac9e 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1887,9 +1887,8 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
* regular allocated space.
*/
static int iomap_do_writepage(struct folio *folio,
- struct writeback_control *wbc, void *data)
+ struct writeback_control *wbc, struct iomap_writepage_ctx *wpc)
{
- struct iomap_writepage_ctx *wpc = data;
struct inode *inode = folio->mapping->host;
u64 end_pos, isize;

@@ -1986,10 +1985,12 @@ 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;
+ int ret;

wpc->ops = ops;
- ret = write_cache_pages(mapping, wbc, iomap_do_writepage, wpc);
+ for_each_writeback_folio(mapping, wbc, folio, ret)
+ ret = iomap_do_writepage(folio, wbc, wpc);
if (!wpc->ioend)
return ret;
return iomap_submit_ioend(wpc, wpc->ioend, ret);
--
2.39.2



2024-01-30 10:29:09

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 18/19] iomap: Convert iomap_writepages() to use for_each_writeback_folio()

On Thu 25-01-24 09:57:57, Christoph Hellwig wrote:
> From: Matthew Wilcox <[email protected]>
>
> This removes one indirect function call per folio, and adds typesafety
> by not casting through a void pointer.
>
> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
> Signed-off-by: Christoph Hellwig <[email protected]>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> fs/iomap/buffered-io.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 093c4515b22a53..58b3661f5eac9e 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1887,9 +1887,8 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
> * regular allocated space.
> */
> static int iomap_do_writepage(struct folio *folio,
> - struct writeback_control *wbc, void *data)
> + struct writeback_control *wbc, struct iomap_writepage_ctx *wpc)
> {
> - struct iomap_writepage_ctx *wpc = data;
> struct inode *inode = folio->mapping->host;
> u64 end_pos, isize;
>
> @@ -1986,10 +1985,12 @@ 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;
> + int ret;
>
> wpc->ops = ops;
> - ret = write_cache_pages(mapping, wbc, iomap_do_writepage, wpc);
> + for_each_writeback_folio(mapping, wbc, folio, ret)
> + ret = iomap_do_writepage(folio, wbc, wpc);
> if (!wpc->ioend)
> return ret;
> return iomap_submit_ioend(wpc, wpc->ioend, ret);
> --
> 2.39.2
>
--
Jan Kara <[email protected]>
SUSE Labs, CR