Re: [PATCH] fuse: skip destination updates for zero-byte copy
Niels de Vos <[email protected]> Thu, 23 Jul 2026 12:33:38 +0200
| Newsgroups | dev.linux.lists.fuse-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 2026-07-23 at 18:07 +0800, Yichong Chen wrote:
> __fuse_copy_file_range() may receive a successful copy reply with
> zero
> bytes copied.=C2=A0 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.
>=20
> In that case no data was written to the destination.=C2=A0 Do not
> invalidate
> the destination page cache or update the destination timestamps and
> cached
> size state for a zero-byte copy result.
>=20
> Fixes: 88bc7d5097a1 ("fuse: add support for copy_file_range()")
> Signed-off-by: Yichong Chen <[email protected]>
> ---
> =C2=A0fs/fuse/file.c | 4 ++++
> =C2=A01 file changed, 4 insertions(+)
>=20
> 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,
> =C2=A0=09=09err =3D -EIO;
> =C2=A0=09=09goto out;
> =C2=A0=09}
> +=09if (!bytes_copied) {
> +=09=09err =3D 0;
> +=09=09goto out;
> +=09}
> =C2=A0
> =C2=A0=09truncate_inode_pages_range(inode_out->i_mapping,
> =C2=A0=09=09=09=09=C2=A0=C2=A0 ALIGN_DOWN(pos_out, PAGE_SIZE),
Thanks, this looks good to me.
My style preference would be to make it an "else if" because bytes_copied i=
s
used in the if-statement above already too. I don't think it is required to
adjust this, the functioning will remain the same.
Acked-by: Niels de Vos <[email protected]>