Skip to content

Commit f878973

Browse files
committed
Merge patch series "iomap: allow the file system to submit the writeback bios"
Christoph Hellwig <hch@lst.de> says: This series contains the iomap prep work to support zoned XFS. The biggest changes are: - an option to reuse the ioend code for direct writes in addition to the current use for buffered writeback, which allows the file system to track completions on a per-bio basis instead of the current end_io callback which operates on the entire I/O. Note that it might make sense to split the ioend code from buffered-io.c into its own file with this. Let me know what you think of that and I can include it in the next version - change of the writeback_ops so that the submit_bio call can be done by the file system. Note that btrfs will also need this eventually when it starts using iomap - helpers to split ioend to the zone append queue_limits that plug into the previous item above. - a new ANON_WRITE flags for writes that don't have a block number assigned to them at the iomap level, leaving the file system to do that work in the submission handler. Note that btrfs wants something similar also for compressed I/O, which should be able to reuse this, maybe with minor tweaks. - passing private data to a few more helper The XFS changes to use this will be posted to the xfs list only to not spam fsdevel too much. * patches from https://lore.kernel.org/r/20250206064035.2323428-2-hch@lst.de: iomap: pass private data to iomap_truncate_page iomap: pass private data to iomap_zero_range iomap: pass private data to iomap_page_mkwrite iomap: add a io_private field to struct iomap_ioend iomap: optionally use ioends for direct I/O iomap: factor out a iomap_dio_done helper iomap: move common ioend code to ioend.c iomap: split bios to zone append limits in the submission handlers iomap: add a IOMAP_F_ANON_WRITE flag iomap: simplify io_flags and io_type in struct iomap_ioend iomap: allow the file system to submit the writeback bios Link: https://lore.kernel.org/r/20250206064035.2323428-2-hch@lst.de Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 2014c95 + ddd402b commit f878973

13 files changed

Lines changed: 446 additions & 231 deletions

File tree

Documentation/filesystems/iomap/design.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ The fields are as follows:
246246
* **IOMAP_F_PRIVATE**: Starting with this value, the upper bits can
247247
be set by the filesystem for its own purposes.
248248

249+
* **IOMAP_F_ANON_WRITE**: Indicates that (write) I/O does not have a target
250+
block assigned to it yet and the file system will do that in the bio
251+
submission handler, splitting the I/O as needed.
252+
249253
These flags can be set by iomap itself during file operations.
250254
The filesystem should supply an ``->iomap_end`` function if it needs
251255
to observe these flags:

Documentation/filesystems/iomap/operations.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ The ``ops`` structure must be specified and is as follows:
283283
struct iomap_writeback_ops {
284284
int (*map_blocks)(struct iomap_writepage_ctx *wpc, struct inode *inode,
285285
loff_t offset, unsigned len);
286-
int (*prepare_ioend)(struct iomap_ioend *ioend, int status);
286+
int (*submit_ioend)(struct iomap_writepage_ctx *wpc, int status);
287287
void (*discard_folio)(struct folio *folio, loff_t pos);
288288
};
289289
@@ -306,13 +306,12 @@ The fields are as follows:
306306
purpose.
307307
This function must be supplied by the filesystem.
308308

309-
- ``prepare_ioend``: Enables filesystems to transform the writeback
310-
ioend or perform any other preparatory work before the writeback I/O
311-
is submitted.
309+
- ``submit_ioend``: Allows the file systems to hook into writeback bio
310+
submission.
312311
This might include pre-write space accounting updates, or installing
313312
a custom ``->bi_end_io`` function for internal purposes, such as
314313
deferring the ioend completion to a workqueue to run metadata update
315-
transactions from process context.
314+
transactions from process context before submitting the bio.
316315
This function is optional.
317316

318317
- ``discard_folio``: iomap calls this function after ``->map_blocks``
@@ -341,7 +340,7 @@ This can happen in interrupt or process context, depending on the
341340
storage device.
342341

343342
Filesystems that need to update internal bookkeeping (e.g. unwritten
344-
extent conversions) should provide a ``->prepare_ioend`` function to
343+
extent conversions) should provide a ``->submit_ioend`` function to
345344
set ``struct iomap_end::bio::bi_end_io`` to its own function.
346345
This function should call ``iomap_finish_ioends`` after finishing its
347346
own work (e.g. unwritten extent conversion).

fs/gfs2/bmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,8 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from,
13001300
unsigned int length)
13011301
{
13021302
BUG_ON(current->journal_info);
1303-
return iomap_zero_range(inode, from, length, NULL, &gfs2_iomap_ops);
1303+
return iomap_zero_range(inode, from, length, NULL, &gfs2_iomap_ops,
1304+
NULL);
13041305
}
13051306

13061307
#define GFS2_JTRUNC_REVOKES 8192

fs/iomap/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ iomap-y += trace.o \
1212
iter.o
1313
iomap-$(CONFIG_BLOCK) += buffered-io.o \
1414
direct-io.o \
15+
ioend.o \
1516
fiemap.o \
1617
seek.o
1718
iomap-$(CONFIG_SWAP) += swapfile.o

0 commit comments

Comments
 (0)