Skip to content

mds: expose multiversion hardlink inode changes in snapdiff - #70953

Merged
vshankar merged 1 commit into
ceph:mainfrom
LiShengG:wip-mds-snapdiff-hardlink-multiversion
Sep 7, 2026
Merged

vshankar merged 1 commit into
ceph:mainfrom
LiShengG:wip-mds-snapdiff-hardlink-multiversion

Conversation

@LiShengG

@LiShengG LiShengG commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CephFS snapdiff treats a non-directory dentry whose snapshot range spans both operands as unchanged. That is incorrect for multiversion hardlinks: inode COW can create a new inode version without COWing either dentry, so cephfs-mirror can report a successful sync while the destination snapshot retains stale file contents.

Compare the authoritative inode metadata visible at each snapshot before skipping an unchanged-span dentry. Because a replica's inode range and historical inode metadata are not authoritative, report the entry conservatively on replica ranks instead of risking a false negative. Add focused libcephfs and cephfs-mirror coverage, including a hardlink split across auth and replica MDS ranks.

Fixes: https://tracker.ceph.com/issues/79275

Tested with:

  • ceph_test_libcephfs_snapdiff --gtest_filter=LibCephFS.SnapDiffHardlinkReplicaInode
  • test_cephfs_mirror_hardlink_snapdiff_visibility
  • test_cephfs_mirror_hardlink_snapdiff_replica_inode

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

@github-actions github-actions Bot added cephfs Ceph File System tests labels Aug 10, 2026
@LiShengG
LiShengG marked this pull request as ready for review August 10, 2026 23:43
@vshankar
vshankar requested review from a team, ifed01 and sajibreadd August 12, 2026 05:04
@kotreshhr kotreshhr self-assigned this Aug 12, 2026
@vshankar

Copy link
Copy Markdown
Contributor

Thanks for the patch. I am reviewing it.

Comment thread src/mds/Server.cc
const bool inode_state_authoritative = head && head->is_auth();
bool inode_spans_both =
inode_state_authoritative &&
snapid_prev >= in->first && snapid <= in->last;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The MDS does treat the hardlink case by making the inode multiversioned while keeping the dentry unchanged.

build_snap_diff() skipped any dentry whose [first,last] range spanned
both compared snapshots, assuming such a dentry cannot have changed.
That does not hold for multiversion inodes: a hardlinked inode
(nlink > 1) is COWed on modification without necessarily COWing either
of its dentries, so the dentry range stays unchanged while the inode
itself gains a new version.

As a result snapdiff reported no change for every path of a modified
hardlink, and cephfs-mirror replicated the snapshot while leaving the
destination file contents stale.

Compare the inode versions visible at each snapshot instead of relying
on the dentry range alone. Historical metadata in old_inodes is
authoritative only on the inode auth MDS. When this rank holds a
replica, report the entry conservatively rather than silently dropping
an update.

Fixes: https://tracker.ceph.com/issues/79275
Signed-off-by: Li Sheng <[email protected]>
@LiShengG
LiShengG force-pushed the wip-mds-snapdiff-hardlink-multiversion branch from 30dae25 to 5a55a3f Compare August 14, 2026 12:05
@LiShengG

Copy link
Copy Markdown
Contributor Author

I found and fixed an issue in the new libcephfs test helper: the
ceph_mds_command() output pointers/lengths were left uninitialized on
the missing-rank error path, so the single-rank skip could hit UB.

I amended the commit to initialize the outputs. The production
Server.cc change is unchanged.

@vshankar

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by vshankar started 2026-08-31-13:37.

@vshankar

vshankar commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

jenkins retest this please

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vshankar
vshankar merged commit 8097d56 into ceph:main Sep 7, 2026
10 checks passed
kotreshhr added a commit to kotreshhr/ceph that referenced this pull request Sep 7, 2026
When a dentry spans both snapid_prev and snapid, build_snap_diff skips
it without comparing metadata.  If snapflush is still outstanding, that
skip can hide a real change.

Add snapflush_pending() using client_snap_caps on snap inodes and
client_need_snapflush on HEAD for snaps in [snapid_prev, snapid].
When snapflush is pending, rdlock the filelock first so metadata
comparisons run on flushed state, then apply the multiversion hardlink
and mtime checks from PR ceph#70953.

For the dentry pair compare path, only rdlock when snapflush is pending
instead of always rdlocking on equal unlocked metadata.

Fixes: https://tracker.ceph.com/issues/74984
Signed-off-by: Kotresh HR <[email protected]>
kotreshhr added a commit to kotreshhr/ceph that referenced this pull request Sep 7, 2026
When a dentry spans both snapid_prev and snapid, build_snap_diff skips
it without comparing metadata.  If snapflush is still outstanding, that
skip can hide a real change.

Add snapflush_pending() using client_snap_caps on snap inodes and
client_need_snapflush on HEAD for snaps in [snapid_prev, snapid].
When snapflush is pending, rdlock the filelock first so metadata
comparisons run on flushed state, then apply the multiversion hardlink
and mtime checks from PR ceph#70953.

For the dentry pair compare path, only rdlock when snapflush is pending
instead of always rdlocking on equal unlocked metadata.

Fixes: https://tracker.ceph.com/issues/74984
Signed-off-by: Kotresh HR <[email protected]>
kginonredhat pushed a commit to kginonredhat/ceph that referenced this pull request Sep 30, 2026
When a dentry spans both snapid_prev and snapid, build_snap_diff skips
it without comparing metadata.  If snapflush is still outstanding, that
skip can hide a real change.

Add snapflush_pending() using client_snap_caps on snap inodes and
client_need_snapflush on HEAD for snaps in [snapid_prev, snapid].
When snapflush is pending, rdlock the filelock first so metadata
comparisons run on flushed state, then apply the multiversion hardlink
and mtime checks from PR ceph#70953.

For the dentry pair compare path, only rdlock when snapflush is pending
instead of always rdlocking on equal unlocked metadata.

Fixes: https://tracker.ceph.com/issues/74984
Signed-off-by: Kotresh HR <[email protected]>
dparmar18 pushed a commit to dparmar18/ceph that referenced this pull request Oct 5, 2026
When a dentry spans both snapid_prev and snapid, build_snap_diff skips
it without comparing metadata.  If snapflush is still outstanding, that
skip can hide a real change.

Add snapflush_pending() using client_snap_caps on snap inodes and
client_need_snapflush on HEAD for snaps in [snapid_prev, snapid].
When snapflush is pending, rdlock the filelock first so metadata
comparisons run on flushed state, then apply the multiversion hardlink
and mtime checks from PR ceph#70953.

For the dentry pair compare path, only rdlock when snapflush is pending
instead of always rdlocking on equal unlocked metadata.

Fixes: https://tracker.ceph.com/issues/74984
Signed-off-by: Kotresh HR <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cephfs Ceph File System tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants