Repository navigation
cephfs_mirror: fix incremental sync after directory rename - #70757
Conversation
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
16 similar comments
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
560710c to
8df6e82
Compare
|
Good catch! |
|
Triggered teuthology test against main to validate if the added test fails without the fix |
|
The only down side is that the rename directory would re-sync all the children freshly. If it's a deep directory, it would take a lot of time. But detecting as a rename and syncing it as remote rename doesn't work in all the cases with snapdiff e.g, cross directory renames, swaps (snap1: dir1 (ino1) dir2(ino2) , snap2: dir2(ino1) dir1 (ino2)) etc But there should be a way detect at least the simple cases and do remote rename in such cases. But I wouldn't block this PR for that and do it as an optimisation. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
Recursive snapdiff can return no entries for a directory that is new at its current path. This omits unchanged descendants from the remote snapshot. Use a full traversal when the path is absent from the previous snapshot. Also detect same-name directory replacements by inode and purge stale remote contents before traversing them in full. The inode check is defense in depth. Normal same-name replacements are reported delete-before-create, so m_deleted selects a full traversal before the inode comparison is reached. Fixes: https://tracker.ceph.com/issues/78910 Signed-off-by: Li Sheng <[email protected]>
Add coverage for unchanged nested descendants across same-parent and cross-parent directory renames, and for same-name directory replacement. Sync pending writes before every snapshot. This prevents delayed writeback from turning a baseline file into a later snapdiff change and masking the regression. Fixes: https://tracker.ceph.com/issues/78910 Signed-off-by: Li Sheng <[email protected]>
8df6e82 to
86be138
Compare
|
Rebased onto latest main and resolved the test insertion conflict, preserving both tests. No changes to the fix logic. Thanks for the review! |
|
The added test does fail without the fix. |
Created the tracker - https://tracker.ceph.com/issues/80957 |
|
This PR has been added to main integration testing by khiremat started 2026-09-28-12:15. |
vshankar
left a comment
There was a problem hiding this comment.
Looks good. Nice catch!
Incremental (snapdiff-based) sync silently loses every unmodified descendant of
a renamed directory. The remote copy is left with the old name deleted and the
new name present but incomplete, the sync is reported as successful, and no
later snapshot repairs it.
Reproduced deterministically on main (
9b679b22366) with a two-cluster vstartsetup:
Control cases behave correctly, which isolates the defect to directory rename:
modifying a child after the rename syncs it, and a file-level rename copies the
file under its new name.
Root cause
Three layers combine into a silent hole:
dentry; the renamed directory keeps its inode and its children's dentries see
no version split, so the recursive diff for the new path is empty.
ceph_open_snapdiff()tolerates the path being absent in the older snapshotand falls back to opening only the current side (
src/libcephfs.cc:888-897).That is intended for genuinely new directories, but after a rename it turns
the empty diff into a successful, empty result instead of an error.
PeerReplayertherefore purges the old name on the remote, creates the newname, and recurses with a diff that reports nothing.
dirty_snap_idstillmatches the synced snapshot, so there is no remote-scan fallback either.
SnapDiffSync's existingpic(purged_or_itype_changed) machinery does notcover this: a rename appears as "old name deleted, new name created", and the
new name is not in
m_deleted[parent], sopicstays false.Fix
Before trusting snapdiff for a directory, stat the same path in the previous
snapshot:
and new contents cannot merge on the target), then traverse in full.
The decision propagates to descendants through
SyncEntry::set_purged_or_itype_changed(), and files below such a subtree arequeued with
sync_check=falseso they are copied whole.Both stat calls go through the same mount:
SnapDiffSyncis only used whenfh.p_mnt == m_local_mount, sostx_inofrom the two snapshots is directlycomparable. The inode comparison is defense in depth; normal same-name
replacements are reported delete-before-create and are already selected for full
traversal by
m_deleted.Cost is one extra
statxat()per changed directory, and none inside a subtreethat is already being traversed in full.
Tests
src/test/libcephfs/snapdiff.ccandqa/tasks/cephfs/test_mirroring.pycurrently have no directory-rename coverage at all, which is why this went
unnoticed. The new integration test covers, against the same mirrored directory:
(
dirB/sub/deeper/unchanged), which also exercises propagation of the fulltraversal decision to descendants;
d1/X->d2/Y);rm -rf replace/B; mv replace/A replace/B),asserting that the previously replicated
replace/B/old-onlydoes not surviveon the target.
Every round compares full source/target snapshot checksums, so the test fails
without the fix. Pending writes are synced before each snapshot: otherwise
delayed writeback can move a baseline file into a later snapdiff change set and
mask the regression.
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
Checklist