fuse: convert fuse_readdir_cached() to use folios

Replace find_get_page_flags() with __filemap_get_folio(), and switch the
remaining page helpers to their folio equivalents.

This removes seven hidden calls to compound_head() and the last caller of
find_get_page_flags().

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Tal Zussman 2026-09-24 19:42:17 -04:00 committed by Miklos Szeredi
parent b8ada80b9d
commit 294de5bbbc

View File

@ -502,7 +502,7 @@ static int fuse_readdir_cached(struct file *file, struct dir_context *ctx)
enum fuse_parse_result res;
pgoff_t index;
unsigned int size;
struct page *page;
struct folio *folio;
void *addr;
/* Seeked? If so, reset the cache stream */
@ -580,42 +580,44 @@ static int fuse_readdir_cached(struct file *file, struct dir_context *ctx)
if (offset_in_page(ff->readdir.cache_off) == size)
return 0;
page = find_get_page_flags(file->f_mapping, index,
FGP_ACCESSED | FGP_LOCK);
/* Page gone missing, then re-added to cache, but not initialized? */
if (page && !PageUptodate(page)) {
unlock_page(page);
put_page(page);
page = NULL;
folio = __filemap_get_folio(file->f_mapping, index,
FGP_ACCESSED | FGP_LOCK, 0);
if (IS_ERR(folio))
folio = NULL;
/* Folio gone missing, then re-added to cache, but not initialized? */
if (folio && !folio_test_uptodate(folio)) {
folio_unlock(folio);
folio_put(folio);
folio = NULL;
}
spin_lock(&fi->rdc.lock);
if (!page) {
if (!folio) {
/*
* Uh-oh: page gone missing, cache is useless
* Uh-oh: folio gone missing, cache is useless
*/
if (fi->rdc.version == ff->readdir.version)
fuse_rdc_reset(inode);
goto retry_locked;
}
/* Make sure it's still the same version after getting the page. */
/* Make sure it's still the same version after getting the folio. */
if (ff->readdir.version != fi->rdc.version) {
spin_unlock(&fi->rdc.lock);
unlock_page(page);
put_page(page);
folio_unlock(folio);
folio_put(folio);
goto retry;
}
spin_unlock(&fi->rdc.lock);
/*
* Contents of the page are now protected against changing by holding
* the page lock.
* Contents of the folio are now protected against changing by holding
* the folio lock.
*/
addr = kmap_local_page(page);
addr = kmap_local_folio(folio, 0);
res = fuse_parse_cache(ff, addr, size, ctx);
kunmap_local(addr);
unlock_page(page);
put_page(page);
folio_unlock(folio);
folio_put(folio);
if (res == FOUND_ERR)
return -EIO;