Re: Re: [PATCH RFC v2 1/2] fuse: add compound command to combine multiple requests
From: Horst Birthelmer
Date: Wed Jan 07 2026 - 09:03:50 EST
On Tue, Jan 06, 2026 at 05:40:52PM -0800, Joanne Koong wrote:
> On Tue, Dec 23, 2025 at 2:13 PM Horst Birthelmer
> <hbirthelmer@xxxxxxxxxxxxxx> wrote:
> >
> > For a FUSE_COMPOUND we add a header that contains information
> > about how many commands there are in the compound and about the
> > size of the expected result. This will make the interpretation
> > in libfuse easier, since we can preallocate the whole result.
> > Then we append the requests that belong to this compound.
> >
> > The API for the compound command has:
> > fuse_compound_alloc()
> > fuse_compound_add()
> > fuse_compound_request()
> > fuse_compound_free()
> >
...
> > +
> > + if (compound->buffer_pos + needed_size > compound->buffer_size) {
> > + size_t new_size = max(compound->buffer_size * 2,
> > + compound->buffer_pos + needed_size);
> > + char *new_buffer;
> > +
> > + new_size = round_up(new_size, PAGE_SIZE);
> > + new_buffer = kvrealloc(compound->buffer, new_size,
> > + GFP_KERNEL);
> > + if (!new_buffer)
> > + return -ENOMEM;
> > + compound->buffer = new_buffer;
> > + compound->buffer_size = new_size;
>
> Hmm... when we're setting up a compound request, we already know the
> size that will be needed to hold all the requests, right? Do you think
> it makes sense to allocate that from the get-go in
> fuse_compound_alloc() and then not have to do any buffer reallocation?
> I think that also gets rid of fuse_compound_req->total_size, as that
> would just be the same as fuse_compound_req->buffer_size.
>
After looking at this again, I realized it would be more efficient to not do any allocation
in fuse_compound_alloc() at all except for the fuse_compound_req, of course, and then
do all the work in fuse_compound_send().
We keep pointers to the fuse_args given to the compound command anyway since we need
to fill out the result, so why not keep just the fuse args and don't copy anything
except when actually sending it out?
I will test this version a bit and make a simplified v3.
...
>
> Thanks,
> Joanne
Thanks,
Horst