Re: Possible readdir regression with BTRFS

Evangelos Foutras
2023-09-09T11:52:26Z

Hi Filipe,

Please be aware that this bug might not be as harmless as it seems. I'm
not sure if the fix you're preparing would also fix an issue we saw at
Arch Linux but I thought I'd mention it here.

We have a package repository server with 4x10 TB drives in RAID10 (btrfs
only, no mdadm). On multiple mirrors syncing from it we have seen rsync
occasionally delete ~4 small (<10 MB) files that get frequently updated
by renaming temporary files into them. This only happened with 6.4.12
and went away after going back to 6.4.10 (the former had the commit Ian
mentioned).

Unfortunately I don't have a reproducer for this. I can only describe
what our repo-add script does and how rsync behaves during problematic
syncs.

Our repo-add script frequently adds packages to the extra repo by doing:

ln -f extra.db.tar.gz extra.db.tar.gz.old
mv .tmp.extra.db.tar.gz extra.db.tar.gz

And the same for extra.files.tar.gz:

ln -f extra.files.tar.gz extra.files.tar.gz.old
mv .tmp.extra.files.tar.gz extra.files.tar.gz

While the server was running Linux 6.4.12, rsync on some mirrors would
occasionally (3-4 times in the day) delete these files:

deleting extra/os/x86_64/extra.files.tar.gz.old
deleting extra/os/x86_64/extra.files.tar.gz
deleting extra/os/x86_64/extra.db.tar.gz.old
deleting extra/os/x86_64/extra.db.tar.gz

Since renames are atomic, I would expect this scenario to never happen.

Again, sorry for not being able to provide a proper reproducer like Ian;
there is probably some timing interaction with how rsync does directory
scanning and repo-add updating the directory entry during this time.

[1]