mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] fuse: convert the readdir cache to use folios
@ 2026-09-24 23:42 Tal Zussman
  2026-09-24 23:42 ` [PATCH 1/2] fuse: convert fuse_add_dirent_to_cache() " Tal Zussman
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Tal Zussman @ 2026-09-24 23:42 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Tal Zussman

Convert the readdir cache lookups in fs/fuse/readdir.c to folios. This
removes the last caller of find_get_page_flags() and one of the last
callers of find_lock_page().

Based on fuse/for-next.

---
Tal Zussman (2):
      fuse: convert fuse_add_dirent_to_cache() to use folios
      fuse: convert fuse_readdir_cached() to use folios

 fs/fuse/readdir.c | 70 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 36 insertions(+), 34 deletions(-)
---
base-commit: 10bd6b32965265688fa277d166ab224de8e86eb2
change-id: 20260906-fuse-readdir-folio-009ae33a7854

Best regards,
--  
Tal Zussman <tz2294@columbia.edu>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] fuse: convert fuse_add_dirent_to_cache() to use folios
  2026-09-24 23:42 [PATCH 0/2] fuse: convert the readdir cache to use folios Tal Zussman
@ 2026-09-24 23:42 ` Tal Zussman
  2026-09-24 23:42 ` [PATCH 2/2] fuse: convert fuse_readdir_cached() " Tal Zussman
  2026-10-13 16:48 ` [PATCH 0/2] fuse: convert the readdir cache " Tal Zussman
  2 siblings, 0 replies; 8+ messages in thread
From: Tal Zussman @ 2026-09-24 23:42 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Tal Zussman

Replace find_lock_page() and find_or_create_page() with
filemap_lock_folio() and filemap_grab_folio(), and switch the remaining
page helpers to their folio equivalents.

Each index of the readdir cache holds one page of dirents. fuse does not
enable large folios, so these folios are always a single page.

Also write the dirent with folio_fill_tail() and memcpy_to_folio()
instead of open-coding it.

This removes two hidden calls to compound_head() and one of the last
callers of find_lock_page().

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 fs/fuse/readdir.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c
index 5ca87151d70d..e6b828eb41a5 100644
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -34,11 +34,11 @@ static void fuse_add_dirent_to_cache(struct file *file,
 	struct fuse_inode *fi = get_fuse_inode(file_inode(file));
 	size_t reclen = FUSE_DIRENT_SIZE(dirent);
 	pgoff_t index;
-	struct page *page;
+	struct folio *folio;
 	loff_t size;
 	u64 version;
 	unsigned int offset;
-	void *addr;
+	size_t folio_offset;
 
 	/* Dirent doesn't fit in readdir cache page?  Skip caching. */
 	if (reclen > PAGE_SIZE)
@@ -64,13 +64,11 @@ static void fuse_add_dirent_to_cache(struct file *file,
 	}
 	spin_unlock(&fi->rdc.lock);
 
-	if (offset) {
-		page = find_lock_page(file->f_mapping, index);
-	} else {
-		page = find_or_create_page(file->f_mapping, index,
-					   mapping_gfp_mask(file->f_mapping));
-	}
-	if (!page)
+	if (offset)
+		folio = filemap_lock_folio(file->f_mapping, index);
+	else
+		folio = filemap_grab_folio(file->f_mapping, index);
+	if (IS_ERR(folio))
 		return;
 
 	spin_lock(&fi->rdc.lock);
@@ -79,19 +77,21 @@ static void fuse_add_dirent_to_cache(struct file *file,
 	    WARN_ON(fi->rdc.pos != pos))
 		goto unlock;
 
-	addr = kmap_local_page(page);
+	folio_offset = offset_in_folio(folio, (index << PAGE_SHIFT) + offset);
 	if (!offset) {
-		clear_page(addr);
-		SetPageUptodate(page);
+		folio_fill_tail(folio, folio_offset, (const char *)dirent,
+				reclen);
+		folio_mark_uptodate(folio);
+	} else {
+		memcpy_to_folio(folio, folio_offset, (const char *)dirent,
+				reclen);
 	}
-	memcpy(addr + offset, dirent, reclen);
-	kunmap_local(addr);
 	fi->rdc.size = (index << PAGE_SHIFT) + offset + reclen;
 	fi->rdc.pos = dirent->off;
 unlock:
 	spin_unlock(&fi->rdc.lock);
-	unlock_page(page);
-	put_page(page);
+	folio_unlock(folio);
+	folio_put(folio);
 }
 
 static void fuse_readdir_cache_end(struct file *file, loff_t pos)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] fuse: convert fuse_readdir_cached() to use folios
  2026-09-24 23:42 [PATCH 0/2] fuse: convert the readdir cache to use folios Tal Zussman
  2026-09-24 23:42 ` [PATCH 1/2] fuse: convert fuse_add_dirent_to_cache() " Tal Zussman
@ 2026-09-24 23:42 ` Tal Zussman
  2026-10-13 16:48 ` [PATCH 0/2] fuse: convert the readdir cache " Tal Zussman
  2 siblings, 0 replies; 8+ messages in thread
From: Tal Zussman @ 2026-09-24 23:42 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Tal Zussman

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>
---
 fs/fuse/readdir.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c
index e6b828eb41a5..5e6b3f574e90 100644
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -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;

-- 
2.39.5


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] fuse: convert the readdir cache to use folios
  2026-09-24 23:42 [PATCH 0/2] fuse: convert the readdir cache to use folios Tal Zussman
  2026-09-24 23:42 ` [PATCH 1/2] fuse: convert fuse_add_dirent_to_cache() " Tal Zussman
  2026-09-24 23:42 ` [PATCH 2/2] fuse: convert fuse_readdir_cached() " Tal Zussman
@ 2026-10-13 16:48 ` Tal Zussman
  2026-10-13 17:38   ` Bernd Schubert
  2 siblings, 1 reply; 8+ messages in thread
From: Tal Zussman @ 2026-10-13 16:48 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel

On 9/24/26 7:42 PM, Tal Zussman wrote:
> Convert the readdir cache lookups in fs/fuse/readdir.c to folios. This
> removes the last caller of find_get_page_flags() and one of the last
> callers of find_lock_page().
> 
> Based on fuse/for-next.
> 

Hi,

Following up on this. It'd be great to get this in as it would allow us
to remove find_get_page_flags() and find_lock_page() next cycle.

Thanks,
Tal


> ---
> Tal Zussman (2):
>       fuse: convert fuse_add_dirent_to_cache() to use folios
>       fuse: convert fuse_readdir_cached() to use folios
> 
>  fs/fuse/readdir.c | 70 ++++++++++++++++++++++++++++---------------------------
>  1 file changed, 36 insertions(+), 34 deletions(-)
> ---
> base-commit: 10bd6b32965265688fa277d166ab224de8e86eb2
> change-id: 20260906-fuse-readdir-folio-009ae33a7854
> 
> Best regards,
> --  
> Tal Zussman <tz2294@columbia.edu>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] fuse: convert the readdir cache to use folios
  2026-10-13 16:48 ` [PATCH 0/2] fuse: convert the readdir cache " Tal Zussman
@ 2026-10-13 17:38   ` Bernd Schubert
  2026-10-13 17:49     ` Tal Zussman
  0 siblings, 1 reply; 8+ messages in thread
From: Bernd Schubert @ 2026-10-13 17:38 UTC (permalink / raw)
  To: Tal Zussman, Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Joanne Koong



On 10/13/26 18:48, Tal Zussman wrote:
> On 9/24/26 7:42 PM, Tal Zussman wrote:
>> Convert the readdir cache lookups in fs/fuse/readdir.c to folios. This
>> removes the last caller of find_get_page_flags() and one of the last
>> callers of find_lock_page().
>>
>> Based on fuse/for-next.
>>
> 
> Hi,
> 
> Following up on this. It'd be great to get this in as it would allow us
> to remove find_get_page_flags() and find_lock_page() next cycle.


fuse has large folios enabled now - the patches need to handle that.
Even if it would not be enabled yet, Joanne had spend quite some effort
to enable large folios, any change that tried to rely on behavior would
have just increased her burden...


Thanks,
Bernd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] fuse: convert the readdir cache to use folios
  2026-10-13 17:38   ` Bernd Schubert
@ 2026-10-13 17:49     ` Tal Zussman
  2026-10-13 18:13       ` Bernd Schubert
  0 siblings, 1 reply; 8+ messages in thread
From: Tal Zussman @ 2026-10-13 17:49 UTC (permalink / raw)
  To: Bernd Schubert, Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Joanne Koong

On 10/13/26 1:38 PM, Bernd Schubert wrote:
> On 10/13/26 18:48, Tal Zussman wrote:
>> On 9/24/26 7:42 PM, Tal Zussman wrote:
>>> Convert the readdir cache lookups in fs/fuse/readdir.c to folios. This
>>> removes the last caller of find_get_page_flags() and one of the last
>>> callers of find_lock_page().
>>>
>>> Based on fuse/for-next.
>>>
>> 
>> Hi,
>> 
>> Following up on this. It'd be great to get this in as it would allow us
>> to remove find_get_page_flags() and find_lock_page() next cycle.
> 
> 
> fuse has large folios enabled now - the patches need to handle that.
> Even if it would not be enabled yet, Joanne had spend quite some effort
> to enable large folios, any change that tried to rely on behavior would
> have just increased her burden...
> 
Hi Bernd,

As far as I can see, Joanne's patches enable large folios for regular files.
Here we operate on directories, which are initialized through fuse_init_dir()
and so do not use large folios. In any case, these patches switch to using
the relevant folio helpers, which would get us closer to using large folios
in the readdir cache if that's eventually desired.

Thanks,
Tal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] fuse: convert the readdir cache to use folios
  2026-10-13 17:49     ` Tal Zussman
@ 2026-10-13 18:13       ` Bernd Schubert
  2026-10-13 19:20         ` Tal Zussman
  0 siblings, 1 reply; 8+ messages in thread
From: Bernd Schubert @ 2026-10-13 18:13 UTC (permalink / raw)
  To: Tal Zussman, Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Joanne Koong



On 10/13/26 19:49, Tal Zussman wrote:
> On 10/13/26 1:38 PM, Bernd Schubert wrote:
>> On 10/13/26 18:48, Tal Zussman wrote:
>>> On 9/24/26 7:42 PM, Tal Zussman wrote:
>>>> Convert the readdir cache lookups in fs/fuse/readdir.c to folios. This
>>>> removes the last caller of find_get_page_flags() and one of the last
>>>> callers of find_lock_page().
>>>>
>>>> Based on fuse/for-next.
>>>>
>>>
>>> Hi,
>>>
>>> Following up on this. It'd be great to get this in as it would allow us
>>> to remove find_get_page_flags() and find_lock_page() next cycle.
>>
>>
>> fuse has large folios enabled now - the patches need to handle that.
>> Even if it would not be enabled yet, Joanne had spend quite some effort
>> to enable large folios, any change that tried to rely on behavior would
>> have just increased her burden...
>>
> Hi Bernd,
> 
> As far as I can see, Joanne's patches enable large folios for regular files.
> Here we operate on directories, which are initialized through fuse_init_dir()
> and so do not use large folios. In any case, these patches switch to using
> the relevant folio helpers, which would get us closer to using large folios
> in the readdir cache if that's eventually desired.

Hi Tal,

oops, sorry, I was bailing out when I read it as "this introduces
another stop gap for large folios". I quickly scanned over it, but don't
have much time right now - will review tomorrow morning.


Sorry again,
Bernd

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] fuse: convert the readdir cache to use folios
  2026-10-13 18:13       ` Bernd Schubert
@ 2026-10-13 19:20         ` Tal Zussman
  0 siblings, 0 replies; 8+ messages in thread
From: Tal Zussman @ 2026-10-13 19:20 UTC (permalink / raw)
  To: Bernd Schubert, Miklos Szeredi
  Cc: Matthew Wilcox (Oracle), fuse-devel, linux-kernel, Joanne Koong

On 10/13/26 2:13 PM, Bernd Schubert wrote:
> On 10/13/26 19:49, Tal Zussman wrote:
>> On 10/13/26 1:38 PM, Bernd Schubert wrote:
>>> On 10/13/26 18:48, Tal Zussman wrote:
>>>> On 9/24/26 7:42 PM, Tal Zussman wrote:
>>>>> Convert the readdir cache lookups in fs/fuse/readdir.c to folios. This
>>>>> removes the last caller of find_get_page_flags() and one of the last
>>>>> callers of find_lock_page().
>>>>>
>>>>> Based on fuse/for-next.
>>>>>
>>>>
>>>> Hi,
>>>>
>>>> Following up on this. It'd be great to get this in as it would allow us
>>>> to remove find_get_page_flags() and find_lock_page() next cycle.
>>>
>>>
>>> fuse has large folios enabled now - the patches need to handle that.
>>> Even if it would not be enabled yet, Joanne had spend quite some effort
>>> to enable large folios, any change that tried to rely on behavior would
>>> have just increased her burden...
>>>
>> Hi Bernd,
>> 
>> As far as I can see, Joanne's patches enable large folios for regular files.
>> Here we operate on directories, which are initialized through fuse_init_dir()
>> and so do not use large folios. In any case, these patches switch to using
>> the relevant folio helpers, which would get us closer to using large folios
>> in the readdir cache if that's eventually desired.
> 
> Hi Tal,
> 
> oops, sorry, I was bailing out when I read it as "this introduces
> another stop gap for large folios". I quickly scanned over it, but don't
> have much time right now - will review tomorrow morning.
> 
> 
> Sorry again,
> Bernd
> 

No problem, thanks!



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-13 19:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 23:42 [PATCH 0/2] fuse: convert the readdir cache to use folios Tal Zussman
2026-09-24 23:42 ` [PATCH 1/2] fuse: convert fuse_add_dirent_to_cache() " Tal Zussman
2026-09-24 23:42 ` [PATCH 2/2] fuse: convert fuse_readdir_cached() " Tal Zussman
2026-10-13 16:48 ` [PATCH 0/2] fuse: convert the readdir cache " Tal Zussman
2026-10-13 17:38   ` Bernd Schubert
2026-10-13 17:49     ` Tal Zussman
2026-10-13 18:13       ` Bernd Schubert
2026-10-13 19:20         ` Tal Zussman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®