Re: [PATCH v3 14/16] fuse: use iomap for folio laundering

Darrick J. Wong
2025-07-02T18:14:41Z

On Mon, Jun 23, 2025 at 07:21:33PM -0700, Joanne Koong wrote:
> Use iomap for folio laundering, which will do granular dirty
> writeback when laundering a large folio.
>
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> fs/fuse/file.c | 52 ++++++++++++--------------------------------------
> 1 file changed, 12 insertions(+), 40 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 2b4b950eaeed..35ecc03c0c48 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -2062,45 +2062,6 @@ static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio
> return wpa;
> }
>
> -static int fuse_writepage_locked(struct folio *folio)
> -{
> - struct address_space *mapping = folio->mapping;
> - struct inode *inode = mapping->host;
> - struct fuse_inode *fi = get_fuse_inode(inode);
> - struct fuse_writepage_args *wpa;
> - struct fuse_args_pages *ap;
> - struct fuse_file *ff;
> - int error = -EIO;
> -
> - ff = fuse_write_file_get(fi);
> - if (!ff)
> - goto err;
> -
> - wpa = fuse_writepage_args_setup(folio, 0, ff);
> - error = -ENOMEM;
> - if (!wpa)
> - goto err_writepage_args;
> -
> - ap = &wpa->ia.ap;
> - ap->num_folios = 1;
> -
> - folio_start_writeback(folio);
> - fuse_writepage_args_page_fill(wpa, folio, 0, 0, folio_size(folio));
> -
> - spin_lock(&fi->lock);
> - list_add_tail(&wpa->queue_entry, &fi->queued_writes);
> - fuse_flush_writepages(inode);
> - spin_unlock(&fi->lock);
> -
> - return 0;
> -
> -err_writepage_args:
> - fuse_file_put(ff, false);
> -err:
> - mapping_set_error(folio->mapping, error);
> - return error;
> -}
> -
> struct fuse_fill_wb_data {
> struct fuse_writepage_args *wpa;
> struct fuse_file *ff;
> @@ -2281,8 +2242,19 @@ static int fuse_writepages(struct address_space *mapping,
> static int fuse_launder_folio(struct folio *folio)
> {
> int err = 0;
> + struct fuse_fill_wb_data data = {
> + .inode = folio->mapping->host,
> + };
> + struct iomap_writepage_ctx wpc = {
> + .inode = folio->mapping->host,
> + .iomap.type = IOMAP_MAPPED,
> + .ops = &fuse_writeback_ops,
> + .wb_ctx = &data,
> + };
> +
> if (folio_clear_dirty_for_io(folio)) {
> - err = fuse_writepage_locked(folio);
> + err = iomap_writeback_folio(&wpc, folio);
> + err = fuse_iomap_writeback_submit(&wpc, err);

Weird krobot complaints aside, this looks like a reasonable way to write
a single folio similar to what writepage used to do.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> if (!err)
> folio_wait_writeback(folio);
> }
> --
> 2.47.1
>
>