On Wed, Sep 3, 2025 at 2:17 PM Darrick J. Wong <djwong@xxxxxxxxxx> wrote: > > On Fri, Aug 29, 2025 at 04:56:26PM -0700, Joanne Koong wrote: > > Do readahead in fuse using iomap. This gives us granular uptodate > > tracking for large folios, which optimizes how much data needs to be > > read in. If some portions of the folio are already uptodate (eg through > > a prior write), we only need to read in the non-uptodate portions. > > > > Signed-off-by: Joanne Koong <joannelkoong@xxxxxxxxx> > > --- > > fs/fuse/file.c | 214 +++++++++++++++++++++++++++---------------------- > > 1 file changed, 118 insertions(+), 96 deletions(-) > > > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > > index bdfb13cdee4b..1659603f4cb6 100644 > > --- a/fs/fuse/file.c > > +++ b/fs/fuse/file.c > > @@ -2176,10 +2187,21 @@ static ssize_t fuse_iomap_writeback_range(struct iomap_writepage_ctx *wpc, > > return -EIO; > > } > > > > - if (wpa && fuse_writepage_need_send(fc, pos, len, ap, data)) { > > - fuse_writepages_send(inode, data); > > - data->wpa = NULL; > > - data->nr_bytes = 0; > > + if (wpa) { > > + bool send = fuse_folios_need_send(fc, pos, len, ap, data->nr_bytes, > > + true); > > + > > + if (!send) { > > + /* Need to grow the pages array? If so, did the expansion fail? */ > > + send = (ap->num_folios == data->max_folios) && > > + !fuse_pages_realloc(data, fc->max_pages); > > + } > > What purpose this code relocation serve? I gather the idea here is that > writes need to reallocate the pages array, whereas readahead can simply > constrain to whatever's already allocated? > I think it's more that for readahead there's more guiding info about what size array is needed (eg looking at readahead_count(rac)) whereas that's more uncertain for writeback, especially since the folios can only be part of the same request if they're contiguous. The writeback array gets reallocated exponentially up on a per-need basis starting at 1. imo it seems better to start the writeback array at 2 or 4 folios but I also don't really have empirical data to back this theory up. Thanks, Joanne > --D >