btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

3 duplicates of the file MEGAsync.cfg.bak in the same directory

Open Zesko opened this issue 3 years ago • 5 comments

I noticed there are 3 same file MEGAsync.cfg.bak, every file has the same checksum. These duplicates were detected by restic backup process

find ~/ -name "*MEGAsync.cfg.bak*"
/home/zesko/.local/share/data/Mega Limited/MEGAsync/MEGAsync.cfg.bak
/home/zesko/.local/share/data/Mega Limited/MEGAsync/MEGAsync.cfg.bak
/home/zesko/.local/share/data/Mega Limited/MEGAsync/MEGAsync.cfg.bak

I deleted these duplicates, then restart of MEGAsync, but these same duplicates appear. I deleted all BTRFS snapshots of home directory. That does not help, still 3 duplicates.

OS: Manjaro KDE (Latest version) Linux Kernel: 5.18.15

megasync --version 
MEGAsync v4.6.7 (c4d241d)

Filesystem: Btrfs: btrfs-progs v5.18.1

Zesko avatar Jul 30 '22 15:07 Zesko

Solution:

  1. I stopped MEGAsync process.
  2. I tried to move this directory /MEGAsync to the other partition EXT4. I got the error message:
$ mv "Mega Limited"/MEGAsync /Ext4/test
mv: cannot remove 'Mega Limited/MEGAsync/MEGAsync.cfg.bak': No such file or directory
mv: cannot remove 'Mega Limited/MEGAsync/MEGAsync.cfg.bak': No such file or directory
  1. Then I check with ls -al MEGAsync
$ ls -al "Mega Limited"/MEGAsync/
lsd: Mega Limited/MEGAsync/MEGAsync.cfg.bak: No such file or directory (os error 2).
lsd: Mega Limited/MEGAsync/MEGAsync.cfg.bak: No such file or directory (os error 2).
  1. I tried to delete the broken directory
$ sudo rm -rf MEGAsync
  1. Then I moved the directory back, then start MEGAsync process, the issue is gone. No duplicate.

Perhaps you can investigate why these duplicates had appeared?

Zesko avatar Jul 30 '22 17:07 Zesko

Is there some other layer involved? Like FUSE or overlayfs. Creating a file on regular filesystem is not supposed to work, it's serialized, a bug possibility is always there but there's not enough data to analyze why. If you see this again, please save output of mount, and ls -li. You can also check if the files exist when the service is not running.

kdave avatar Aug 16 '22 14:08 kdave

@kdave

This duplicate of MEGA config file was in home directory in home subvolume that never uses other layer, e.g Overlayfs.

Home subvolume and root subvolume are separated in the same btrfs filesystem.

The root directory / is on Btrfs filesystem. I chose a read-only root-snapshot in GRUB to boot into Overlayfs, then restore this root-snapshot, but it has nothing to do with home subvolume.

Only this MEGA config file happened only once. Rest all fine, no duplicate.

I think that I first installed Linux Kernel 5.10 on my device using Btrfs, maybe it could cause this duplicate before upgrade many Linux Kernels ... to 5.18.

Zesko avatar Aug 16 '22 16:08 Zesko

In 5.14 there was a change that made duplicate dirents frequently during log tree replay, which was fixed in 5.16-rc1 (9a35fc9542fa btrfs: change error handling for btrfs_delete_*_in_log). The repro recipe is something like "do a lot of renames while the filesystem is busy flushing, then crash and run log tree replay on the next mount." Kernels before 5.14 could also produce duplicate dirents, but much less often.

If the machine has been running 5.14 at any point, then this is almost certainly the cause. If it was running earlier kernels then it's less likely, but still possible. The duplicate entries can be removed by deleting all other entries in the directory, then removing the directory.

Zygo avatar Aug 16 '22 17:08 Zygo

If you want to know when it happened in the past

It happened in Linux Kernel 5.10 https://forum.manjaro.org/t/more-than-18-files-xorg-0-log-with-same-timestamp/91252

Linux Kernel 5.10.36 https://forum.manjaro.org/t/btrfs-kernel-bug-duplicate-file-names/68260

Zesko avatar Aug 16 '22 17:08 Zesko