Re: [PATCH] fuse: skip destination updates for zero-byte copy
Amir Goldstein <[email protected]> Thu, 23 Jul 2026 12:43:29 +0200
| Newsgroups | dev.linux.lists.fuse-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAOQ4uxjys+yENYgjROu3Ui-athFjdY0E4fGhR4qsb2ed04wqkw@mail.gmail.com> |
On Thu, Jul 23, 2026 at 12:15=E2=80=AFPM Yichong Chen <chenyichong@uniontec=
h.com> 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 cache=
d
> 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 ter=
rible
idea in any case.
Are you proposing this "fix" because an application encountered a problem
or unexpected behavior or why?
Thanks,
Amir.
>
> Fixes: 88bc7d5097a1 ("fuse: add support for copy_file_range()")
> Signed-off-by: Yichong Chen <[email protected]>
> ---
> fs/fuse/file.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index ceada75310b8..75eb97b26912 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -3040,6 +3040,10 @@ static ssize_t __fuse_copy_file_range(struct file =
*file_in, loff_t pos_in,
> err =3D -EIO;
> goto out;
> }
> + if (!bytes_copied) {
> + err =3D 0;
> + goto out;
> + }
>
> truncate_inode_pages_range(inode_out->i_mapping,
> ALIGN_DOWN(pos_out, PAGE_SIZE),
> --
> 2.51.0
>
>