diff options
| author | Christoph Hellwig <hch@lst.de> | 2025-07-10 16:33:28 +0300 | 
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-07-14 11:51:31 +0300 | 
| commit | fb7399cf2d0b33825b8039f95c45395c7deba25c (patch) | |
| tree | 849825cc5c90ac56c4a163db7eac3752e92d7f12 /fs/gfs2/bmap.c | |
| parent | 40368a6acb95635824f6a45ec1de6233977309f3 (diff) | |
| download | linux-fb7399cf2d0b33825b8039f95c45395c7deba25c.tar.xz | |
iomap: refactor the writeback interface
Replace ->map_blocks with a new ->writeback_range, which differs in the
following ways:
 - it must also queue up the I/O for writeback, that is called into the
   slightly refactored and extended in scope iomap_add_to_ioend for
   each region
 - can handle only a part of the requested region, that is the retry
   loop for partial mappings moves to the caller
 - handles cleanup on failures as well, and thus also replaces the
   discard_folio method only implemented by XFS.
This will allow to use the iomap writeback code also for file systems
that are not block based like fuse.
Co-developed-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/20250710133343.399917-5-hch@lst.de
Acked-by: Damien Le Moal <dlemoal@kernel.org>	# zonefs
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/gfs2/bmap.c')
| -rw-r--r-- | fs/gfs2/bmap.c | 26 | 
1 files changed, 14 insertions, 12 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 7703d0471139..0cc41de54aba 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -2469,23 +2469,25 @@ out:  	return error;  } -static int gfs2_map_blocks(struct iomap_writepage_ctx *wpc, struct inode *inode, -		loff_t offset, unsigned int len) +static ssize_t gfs2_writeback_range(struct iomap_writepage_ctx *wpc, +		struct folio *folio, u64 offset, unsigned int len, u64 end_pos)  { -	int ret; - -	if (WARN_ON_ONCE(gfs2_is_stuffed(GFS2_I(inode)))) +	if (WARN_ON_ONCE(gfs2_is_stuffed(GFS2_I(wpc->inode))))  		return -EIO; -	if (offset >= wpc->iomap.offset && -	    offset < wpc->iomap.offset + wpc->iomap.length) -		return 0; +	if (offset < wpc->iomap.offset || +	    offset >= wpc->iomap.offset + wpc->iomap.length) { +		int ret; -	memset(&wpc->iomap, 0, sizeof(wpc->iomap)); -	ret = gfs2_iomap_get(inode, offset, INT_MAX, &wpc->iomap); -	return ret; +		memset(&wpc->iomap, 0, sizeof(wpc->iomap)); +		ret = gfs2_iomap_get(wpc->inode, offset, INT_MAX, &wpc->iomap); +		if (ret) +			return ret; +	} + +	return iomap_add_to_ioend(wpc, folio, offset, end_pos, len);  }  const struct iomap_writeback_ops gfs2_writeback_ops = { -	.map_blocks		= gfs2_map_blocks, +	.writeback_range	= gfs2_writeback_range,  };  | 
