Re: [PATCH v3] fuse: back uncached readdir buffers with pages
From: Matt Ochs
Date: Thu May 21 2026 - 21:34:21 EST
Hi Miklos,
> On May 19, 2026, at 10:41, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
>
> On Tue, 19 May 2026 at 17:34, Matt Ochs <mochs@xxxxxxxxxx> wrote:
>
>> With out_pages but without the byte-size cap, fuse_simple_request()
>> still returned -ENOMEM. Capping the request to 1048576 bytes / 16 pages
>> made the same test pass.
>
> Can you tell why is it failing now?
I tracked down where the remaining -ENOMEM comes from.
For the failing READDIR request, kernel-side instrumentation shows:
READDIR out_size=8126464 num_folios=124 total_sgs=127
copy_args_to_argbuf: num_in=1 num_out=0 len=40
virtqueue_add_sgs: ok
completion: out_error=-12 out_len=16
So the output is page backed, the argbuf only contains the 40-byte input
argument, and the virtqueue submission succeeds. The -ENOMEM is coming back
from virtiofsd.
The remaining failure is the virtiofsd READDIR/READDIRPLUS range check.
Virtiofsd advertises:
max_write = MAX_BUFFER_SIZE
max_pages = ceil(MAX_BUFFER_SIZE / host_page_size)
and then rejects READDIR/READDIRPLUS if the requested size is larger than
MAX_BUFFER_SIZE.
On the failing setup the host is 4K and the guest is 64K. The guest ends up
with fc->max_pages=124 after the virtqueue-size cap, so uncached READDIR asks
for:
124 * 65536 = 8126464 bytes
That exceeds virtiofsd's MAX_BUFFER_SIZE of 1048576 bytes, so virtiofsd
returns ENOMEM before doing the directory read. On a 64K host this is masked
because virtiofsd advertises max_pages=16, keeping the guest request at 1MiB.
Given that, I agree the generic FUSE patch should not include the max_write
cap. I'll send a v4 that only backs uncached readdir with output pages.
For the remaining virtiofsd issue, does capping the local READDIR response
size in virtiofsd sound like the right direction? READDIR can return less
than requested, so treating MAX_BUFFER_SIZE as the maximum chunk to produce
seems preferable to rejecting an otherwise valid request.
-matt