Re: [PATCH v4] fuse: back uncached readdir buffers with pages
From: Miklos Szeredi
Date: Thu Jun 11 2026 - 09:19:53 EST
On Tue, 26 May 2026 at 17:20, Matthew R. Ochs <mochs@xxxxxxxxxx> wrote:
>
> Commit dabb90391028 ("fuse: increase readdir buffer size") changed
> fuse_readdir_uncached() to size its temporary buffer from ctx->count.
> This is useful for overlayfs and other in-kernel callers that use
> INT_MAX to indicate an unlimited directory read.
>
> The larger buffer is currently supplied as a kvec output argument. For
> virtiofs, kvec arguments are copied through req->argbuf, which is
> allocated with kmalloc(..., GFP_ATOMIC). A large uncached readdir buffer
> can therefore require a multi-megabyte contiguous atomic allocation
> before the request is queued.
>
> Avoid the large bounce-buffer allocation by backing uncached readdir
> output with pages and setting out_pages. Transports such as virtiofs can
> then pass the pages as scatter-gather entries instead of copying the
> output through argbuf.
>
> Map the pages with vm_map_ram() only while parsing the returned dirents.
> The existing parser can then continue to use a linear kernel mapping.
>
> Fixes: dabb90391028 ("fuse: increase readdir buffer size")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Matthew R. Ochs <mochs@xxxxxxxxxx>
Applied with cleanups. Please verify:
https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git/commit/?h=for-next&id=2fcb1dd15faba5657b825cc5d54423251c70e79a
Thanks,
Miklos