Re: Re: [PATCH] fuse: skip destination updates for zero-byte copy
From: Horst Birthelmer
Date: Fri Jul 24 2026 - 07:32:44 EST
On Thu, Jul 23, 2026 at 12:43:29PM +0200, Amir Goldstein wrote:
> On Thu, Jul 23, 2026 at 12:15 PM Yichong Chen <chenyichong@xxxxxxxxxxxxx> wrote:
> >
> > __fuse_copy_file_range() may receive a successful copy reply with zero
> > bytes copied. This can happen even though the VFS only calls the file
> > operation with a non-zero length, for example if the FUSE daemon reaches
> > EOF while the kernel has stale source size information.
> >
> > In that case no data was written to the destination. Do not invalidate
> > the destination page cache or update the destination timestamps and cached
> > size state for a zero-byte copy result.
>
> Why not?
> If the FUSE daemon reaches EOF and VFS thinks that there is still something
> to read then obviously the cached size is incorrect.
> Also invalidating the last page cache in this case does not seem like a terrible
> idea in any case.
>
> Are you proposing this "fix" because an application encountered a problem
> or unexpected behavior or why?
I agree with Amir, but I think it is worse.
There is no check in that function for len not to be zero.
So if something calls this with len set to zero, we expect it to either do it
and call all the updates.
Calling the write and react on the result without knowing if this was intended doesn't
look right to me.
Someone might actually call this with len zero.
>
> Thanks,
> Amir.
>
Thanks,
Horst