Skip to content

Commit f53d302

Browse files
committed
Merge patch series "iomap: buffered io changes"
This series contains several fixes and cleanups: * Renaming bytes_pending/bytes_accounted to bytes_submitted/bytes_not_submitted for improved code clarity * Accounting for unaligned end offsets when truncating read ranges * Adding documentation for iomap_finish_folio_write() requirements * Optimizing pending async writeback accounting logic * Simplifying error handling in ->read_folio_range() for read operations * Streamlining logic for skipping reads during write operations * Replacing manual bitmap scanning with find_next_bit() for both dirty and uptodate bitmaps, improving performance * patches from https://patch.msgid.link/20251111193658.3495942-1-joannelkoong@gmail.com: iomap: use find_next_bit() for uptodate bitmap scanning iomap: use find_next_bit() for dirty bitmap scanning iomap: simplify when reads can be skipped for writes iomap: simplify ->read_folio_range() error handling for reads iomap: optimize pending async writeback accounting docs: document iomap writeback's iomap_finish_folio_write() requirement iomap: account for unaligned end offsets when truncating read range iomap: rename bytes_pending/bytes_accounted to bytes_submitted/bytes_not_submitted Link: https://patch.msgid.link/20251111193658.3495942-1-joannelkoong@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents ca3557a + b56c1c5 commit f53d302

5 files changed

Lines changed: 196 additions & 131 deletions

File tree

Documentation/filesystems/iomap/operations.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ These ``struct kiocb`` flags are significant for buffered I/O with iomap:
149149
iomap calls these functions:
150150

151151
- ``read_folio_range``: Called to read in the range. This must be provided
152-
by the caller. The caller is responsible for calling
153-
iomap_finish_folio_read() after reading in the folio range. This should be
154-
done even if an error is encountered during the read. This returns 0 on
155-
success or a negative error on failure.
152+
by the caller. If this succeeds, iomap_finish_folio_read() must be called
153+
after the range is read in, regardless of whether the read succeeded or
154+
failed.
156155

157156
- ``submit_read``: Submit any pending read requests. This function is
158157
optional.
@@ -361,6 +360,9 @@ The fields are as follows:
361360
delalloc reservations to avoid having delalloc reservations for
362361
clean pagecache.
363362
This function must be supplied by the filesystem.
363+
If this succeeds, iomap_finish_folio_write() must be called once writeback
364+
completes for the range, regardless of whether the writeback succeeded or
365+
failed.
364366

365367
- ``writeback_submit``: Submit the previous built writeback context.
366368
Block based file systems should use the iomap_ioend_writeback_submit

fs/fuse/file.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -922,21 +922,15 @@ static int fuse_iomap_read_folio_range_async(const struct iomap_iter *iter,
922922

923923
if (ctx->rac) {
924924
ret = fuse_handle_readahead(folio, ctx->rac, data, pos, len);
925-
/*
926-
* If fuse_handle_readahead was successful, fuse_readpages_end
927-
* will do the iomap_finish_folio_read, else we need to call it
928-
* here
929-
*/
930-
if (ret)
931-
iomap_finish_folio_read(folio, off, len, ret);
932925
} else {
933926
/*
934927
* for non-readahead read requests, do reads synchronously
935928
* since it's not guaranteed that the server can handle
936929
* out-of-order reads
937930
*/
938931
ret = fuse_do_readfolio(file, folio, off, len);
939-
iomap_finish_folio_read(folio, off, len, ret);
932+
if (!ret)
933+
iomap_finish_folio_read(folio, off, len, ret);
940934
}
941935
return ret;
942936
}
@@ -1885,7 +1879,8 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
18851879
* scope of the fi->lock alleviates xarray lock
18861880
* contention and noticeably improves performance.
18871881
*/
1888-
iomap_finish_folio_write(inode, ap->folios[i], 1);
1882+
iomap_finish_folio_write(inode, ap->folios[i],
1883+
ap->descs[i].length);
18891884

18901885
wake_up(&fi->page_waitq);
18911886
}
@@ -2221,7 +2216,6 @@ static ssize_t fuse_iomap_writeback_range(struct iomap_writepage_ctx *wpc,
22212216
ap = &wpa->ia.ap;
22222217
}
22232218

2224-
iomap_start_folio_write(inode, folio, 1);
22252219
fuse_writepage_args_page_fill(wpa, folio, ap->num_folios,
22262220
offset, len);
22272221
data->nr_bytes += len;

0 commit comments

Comments
 (0)