Re: [PATCH 04/12] iomap: hide ioends from the generic writeback code

Randy Dunlap
2025-06-28T03:10:05Z

On 6/27/25 12:02 AM, Christoph Hellwig wrote:
> Replace the ioend pointer in iomap_writeback_ctx with a void *wb_ctx
> one to facilitate non-block, non-ioend writeback for use. Rename
> the submit_ioend method to writeback_submit and make it mandatory so
> that the generic writeback code stops seeing ioends and bios.
>
> Co-developed-by: Joanne Koong <joannelkoong@gmail.com>
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> .../filesystems/iomap/operations.rst | 16 +---
> block/fops.c | 1 +
> fs/gfs2/bmap.c | 1 +
> fs/iomap/buffered-io.c | 91 ++++++++++---------
> fs/xfs/xfs_aops.c | 60 ++++++------
> fs/zonefs/file.c | 1 +
> include/linux/iomap.h | 19 ++--
> 7 files changed, 93 insertions(+), 96 deletions(-)
>
> diff --git a/Documentation/filesystems/iomap/operations.rst b/Documentation/filesystems/iomap/operations.rst
> index 3c7989ee84ff..7073c1a3ede3 100644
> --- a/Documentation/filesystems/iomap/operations.rst
> +++ b/Documentation/filesystems/iomap/operations.rst
> @@ -285,7 +285,7 @@ The ``ops`` structure must be specified and is as follows:
> struct iomap_writeback_ops {
> int (*writeback_range)(struct iomap_writeback_ctx *wpc,
> struct folio *folio, u64 pos, unsigned int len, u64 end_pos);
> - int (*submit_ioend)(struct iomap_writeback_ctx *wpc, int status);
> + int (*writeback_submit)(struct iomap_writeback_ctx *wpc, int error);
> };
>
> The fields are as follows:
> @@ -307,13 +307,7 @@ The fields are as follows:
> purpose.
> This function must be supplied by the filesystem.
>
> - - ``submit_ioend``: Allows the file systems to hook into writeback bio
> - submission.
> - This might include pre-write space accounting updates, or installing
> - a custom ``->bi_end_io`` function for internal purposes, such as
> - deferring the ioend completion to a workqueue to run metadata update
> - transactions from process context before submitting the bio.
> - This function is optional.
> + - ``writeback_submit``: Submit the previous built writeback context.

previously

>
> Pagecache Writeback Completion
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index a54b14817cd0..a72ab487c8ab 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c

> @@ -1956,6 +1947,18 @@ iomap_writepages(struct iomap_writeback_ctx *wpc)
>
> while ((folio = writeback_iter(mapping, wpc->wbc, folio, &error)))
> error = iomap_writepage_map(wpc, folio);
> - return iomap_submit_ioend(wpc, error);
> +
> + /*
> + * If @error is non-zero, it means that we have a situation where some
> + * part of the submission process has failed after we've marked pages
> + * for writeback.
> + *
> + * We cannot cancel the writeback directly in that case, so always call
> + * ->writeback_submit to run the I/O completion handler to clear the
> + * writeback bit and let the file system proess the errors.

process

> + */
> + if (wpc->wb_ctx)
> + return wpc->ops->writeback_submit(wpc, error);
> + return error;
> }
> EXPORT_SYMBOL_GPL(iomap_writepages);

--
~Randy