Repository navigation
create: back up automounted directories, fixes #6652 - #10509
Open
ThomasWaldmann wants to merge 2 commits into
Open
ThomasWaldmann wants to merge 2 commits into
ThomasWaldmann wants to merge 2 commits into
Conversation
stat() does not trigger an automount (autofs, systemd automount units, ZFS .zfs/snapshot/*), but opening the directory does. borg then saw a different inode in fstat() than in the stat() before and skipped the whole tree as a race condition. Now, if a directory turns into another directory on a different mount than its parent directory, we accept that as an automount, use the fstat() result and redo the skip_inodes and --one-file-system decisions. platform.on_different_mounts() compares the mount ids on Linux (st_dev is not good enough there, e.g. for btrfs subvolumes) and st_dev elsewhere. Recursion roots and --paths-from-stdin directories are opened before taking their stat, so --one-file-system uses the device number of the mounted filesystem (this also fixes incomplete -x backups of a ZFS snapshot directory given as a recursion root). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10509 +/- ##
==========================================
- Coverage 89.12% 89.10% -0.02%
==========================================
Files 103 103
Lines 19783 19818 +35
Branches 3099 3105 +6
==========================================
+ Hits 17631 17659 +28
- Misses 1490 1496 +6
- Partials 662 663 +1 ☔ View full report in Codecov by Harness. |
…#6652 OpenBSD has no /proc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6652.
Problem
stat()/lstat()do not trigger an automount (on Linux, they act as ifAT_NO_AUTOMOUNTwas given), but opening the directory does.borg createstats a directory, then opens it and compares withfstat(): for an automount point that is not mounted yet, the first stat is the automount point and thefstat()is the root directory of the filesystem that just got mounted there. borg considered that a race condition ("file type or inode changed") and skipped the whole tree.This affects autofs (indirect and direct maps), systemd
.automountunits and ZFS.zfs/snapshot/*on Linux.Fix
platform.on_different_mounts(fd1, fd2): Linux compares the mount ids (from/proc/self/fdinfo/<fd>, Linux >= 3.15), asst_devis not good enough there (btrfs subvolumes have their ownst_devwithout being a mount). Other platforms comparest_dev. If it can not be determined, the answer isNone, which is handled like "no".archive.is_automount(): accepts the change only if it is a directory before and after and the opened directory is on a different mount than its parent directory. Everything else still raisesBackupRaceConditionError.fstat()result and redo theskip_inodesand--one-file-systemdecisions, so an automounted filesystem is handled like an already mounted one.--paths-from-stdindirectories are opened before taking their stat, so the mount happens early and--one-file-systemuses the device number of the mounted filesystem.Testing
Unit tests (
is_automount,on_different_mounts) and aborg createtest that simulates an automount point (with and without a mount, with and without--one-file-system).Manual tests on Debian 13 (kernel 6.12), comparing 2.0.0b25 with this branch:
-x-xonly the mountpoint dir.automountunit (direct autofs mount)-xon.zfs/snapshot/<snap>as recursion rootst_devcomparison would say "different")ZFS 2.3.9 keeps the inode number of the snapshot root (only
st_devchanges), so the original error does not appear there anymore, but the-xdecision was based on the automount point'sst_dev.FreeBSD 15 and NetBSD 11 autofs do not mount when the directory is opened (only on the first lookup inside it), so
stat()andfstat()agree there and this change makes no difference. FreeBSD ZFS mounts snapshots on lookup, so it is not affected either.🤖 Generated with Claude Code