Skip to content

Commit b8d975e

Browse files
committed
Merge tag 'fuse-fixes-6.14-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse fixes from Miklos Szeredi: This contains a fix for fuse readahead. * tag 'fuse-fixes-6.14-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: revert back to __readahead_folio() for readahead Link: https://lore.kernel.org/r/CAJfpegv=+M4hy=hfBKEgBN8vfWULWT9ApbQzCnPopnMqyjpkzA@mail.gmail.com Signed-off-by: Christian Brauner <[email protected]>
2 parents 2408a80 + 0c67c37 commit b8d975e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

fs/fuse/dev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,12 @@ static int fuse_check_folio(struct folio *folio)
838838
return 0;
839839
}
840840

841+
/*
842+
* Attempt to steal a page from the splice() pipe and move it into the
843+
* pagecache. If successful, the pointer in @pagep will be updated. The
844+
* folio that was originally in @pagep will lose a reference and the new
845+
* folio returned in @pagep will carry a reference.
846+
*/
841847
static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
842848
{
843849
int err;

fs/fuse/file.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,10 @@ static void fuse_readpages_end(struct fuse_mount *fm, struct fuse_args *args,
955955
fuse_invalidate_atime(inode);
956956
}
957957

958-
for (i = 0; i < ap->num_folios; i++)
958+
for (i = 0; i < ap->num_folios; i++) {
959959
folio_end_read(ap->folios[i], !err);
960+
folio_put(ap->folios[i]);
961+
}
960962
if (ia->ff)
961963
fuse_file_put(ia->ff, false);
962964

@@ -1048,7 +1050,14 @@ static void fuse_readahead(struct readahead_control *rac)
10481050
ap = &ia->ap;
10491051

10501052
while (ap->num_folios < cur_pages) {
1051-
folio = readahead_folio(rac);
1053+
/*
1054+
* This returns a folio with a ref held on it.
1055+
* The ref needs to be held until the request is
1056+
* completed, since the splice case (see
1057+
* fuse_try_move_page()) drops the ref after it's
1058+
* replaced in the page cache.
1059+
*/
1060+
folio = __readahead_folio(rac);
10521061
ap->folios[ap->num_folios] = folio;
10531062
ap->descs[ap->num_folios].length = folio_size(folio);
10541063
ap->num_folios++;

0 commit comments

Comments
 (0)