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

From: Matt Ochs

Date: Thu May 14 2026 - 17:36:23 EST


Hi Miklos,

> On Apr 30, 2026, at 14:24, Matt Ochs <mochs@xxxxxxxxxx> wrote:
>
>>
>> On Apr 29, 2026, at 02:27, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
>>
>> On Wed, 29 Apr 2026 at 01:30, Matthew R. Ochs <mochs@xxxxxxxxxx> wrote:
>>
>>> The larger buffer is also 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 readdir buffer can
>>> therefore require a multi-megabyte contiguous atomic allocation and fail
>>> with -ENOMEM.
>>
>> Shouldn't this be max_read? Here "read" and "write" refer to
>> direction of I/O on the filesystem, not on the fuse device (see
>> fuse/file.c)
>
> Thanks, the read/write direction point makes sense.
>
> I tested changing the cap to fc->max_read only, but that reproduces the
> original virtiofs failure on the 4K-host/64K-guest setup. The runtime
> values for the failing READDIR are:
>
> PAGE_SIZE=65536
> fc->max_pages=124
> fc->max_read=4294967295
> fc->max_write=1048576
> max_bufsize=8126464
> nr_pages=124
>
> So for this virtiofs mount, fc->max_read is effectively unlimited, while
> virtiofsd advertises its 1 MiB MAX_BUFFER_SIZE through max_write and
> rejects READDIR sizes above that limit.
>
> Do you prefer handling this locally in fuse_readdir_uncached(), for
> example by capping the request with all available limits:
>
> min3_t(size_t, fc->max_pages << PAGE_SHIFT, fc->max_read, fc->max_write)
>
> Or should virtiofs/FUSE instead make fc->max_read reflect this byte-sized
> buffer limit before readdir uses it?
>
> I will address the other cleanup comments in v3: drop the cast, keep the
> clamp-style sizing, use release_pages(), and remove the nomem double jump.
>

Checking in if you have a preference on how this is handled?


-matt