Subject: bug#60455: Missing fallback if copy_file_range returns ENOENT?

From: Sam James <[email-masked]>
Date: Sat, 7 Jan 2023 07:34:06 +0000

> On 31 Dec 2022, at 18:51, Pádraig Brady <[email-masked]> wrote:
> 
> On 31/12/2022 17:00, Sam James wrote:
>> Hi folks,
>> Originally reported in Gentoo at https://bugs.gentoo.org/885793.
>> Frank Limpert reported that when copying large files across CIFS shares,
>> cp may abort because copy_file_range returns ENOENT sometimes.
>> This sounds like a suspicious kernel bug if CIFS interactions are sometimes
>> spuriously giving ENOENT, but I'm wondering if coreutils needs to do
>> anything to handle this as well.
>> strace output from his cp invocation: https://bugs.gentoo.org/attachment.cgi?id=842497
> 
> We may be able to fallback, but it depends if the errno
> is possible to be returned at a partial copy or not.
> If partial then there is not much we can do.
> Now ENOENT is not a documented errno for copy_file_range()
> so I'm not sure what we should do with it.
> I didn't see on the bug above if any data was copied.
> Could we get more info about that?

Frank got back to me and said an empty file gets created:
```
# cp /mnt/Backup/EAV/data-eav-eav-aktiv-20221207.dump.xz /mnt/OldBackup/EAV/1
cp: error copying '/mnt/Backup/EAV/data-eav-eav-aktiv-20221207.dump.xz' to '/mnt/OldBackup/EAV/1/data-eav-eav-aktiv-20221207.dump.xz': No such file or directory
# stat /mnt/OldBackup/EAV/1/data-eav-eav-aktiv-20221207.dump.xz
File: /mnt/OldBackup/EAV/1/data-eav-eav-aktiv-20221207.dump.xz
Size: 0 Blocks: 8 IO Block: 1048576 regular empty file
Device: 0,36 Inode: 81611419679 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 16/ cron)
Access: 2023-01-06 21:45:57.070743000 +0100
Modify: 2023-01-06 21:45:57.070743000 +0100
Change: 2023-01-06 21:45:57.070743000 +0100
Birth: 2023-01-06 21:45:57.070743000 +0100
```