Re: [PATCH v4] fuse: back uncached readdir buffers with pages

From: Matt Ochs

Date: Tue Jun 02 2026 - 10:57:32 EST


Hi Miklos,

Gentle ping on this v4.

I reworked it to keep the kernel change limited to backing uncached
readdir output with pages, and dropped the request-size cap as requested.

For context, the separate virtiofsd-side issue we discussed has now been
fixed upstream in virtiofsd:

https://gitlab.com/virtio-fs/virtiofsd/-/commit/d24cda8a325d2a9ae1adc5acda57515ed2e8e1d2

That should leave this patch only addressing the kernel-side argbuf
allocation path for uncached readdir.

Do you have any remaining concerns with this version?


-matt

> On May 26, 2026, at 10: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>
> ---
> v4:
> - Drop the fc->max_read/fc->max_write request-size cap.
> - Keep the existing uncached readdir buffer sizing logic unchanged.
> - Limit this patch to backing uncached readdir output with pages.
> - Update the commit message to describe only the kernel-side argbuf fix.
> - The remaining 4K-host/64K-guest ENOMEM was traced to virtiofsd rejecting
> READDIR sizes larger than its MAX_BUFFER_SIZE; a virtiofsd fix is being
> handled separately.
> - Link to v3: https://lore.kernel.org/all/20260519004746.3203156-1-mochs@xxxxxxxxxx/
>