Skip to content

umbrella: mds: do not replicate an xlocked dentry whose linkage is projected - #73625

Merged
batrick merged 2 commits into
ceph:umbrellafrom
anthonyeleven:wip-82862-umbrella
Nov 23, 2026
Merged

batrick merged 2 commits into
ceph:umbrellafrom
anthonyeleven:wip-82862-umbrella

Conversation

@anthonyeleven

Copy link
Copy Markdown
Contributor

backport tracker: https://tracker.ceph.com/issues/82862


backport of #72790
parent tracker: https://tracker.ceph.com/issues/81730

handle_discover lets a path_locked discover replicate an xlocked dentry. The exception is meant for the xlocker's own witnesses, but MDiscover carries no request id, so a peer working on another request gets it too, for example handle_peer_rename_prep opening a remote dentry's inode. If the dentry belongs to a rename that has already projected its new linkage, such as an early-replied rename waiting on its journal entry, the new replica gets the old linkage and is not a witness. When the rename commits, _rename_finish sends MDentryLink to that replica, and the peer fails ceph_assert(dnl->is_null()) in MDCache::handle_dentry_link.

This change allows the exception only while the dentry has no projected linkage. Otherwise the discover blocks on the xlock as a normal discover does, and the log is nudged so an early-replied xlocker does not hold it until the next tick. The xlocker's own witnesses all traverse before it projects, so they are unaffected.

Testing: reproduced deterministically on v18.2.7 with two active ranks, one kernel client and mds_log_pause on the rename leader. The reproducer script, debug_mds 20 logs from both ranks and the sequence are on the tracker. Without this change the peer rank aborted in 2 of 2 runs. With it, cherry-picked onto v18.2.7, it aborted in 0 of 2: the auth rank logs handle_discover blocking on xlocked, and the second rename completes once the first commits. The diff is identical on main.

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.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Signed-off-by: Anthony D'Atri [email protected]
Assisted by Claude Opus-5.5

Clean cherry-pick of 2 commits, with the same line changes as on main.

anthonyeleven and others added 2 commits November 7, 2026 18:06
handle_discover lets a path_locked discover replicate an xlocked
dentry. The exception exists for the xlocker's own witnesses, which
traverse the paths before the xlocker projects anything: a rename leader
sends rename_prep only after it holds all locks, and calls
_rename_prepare only after every witness has acked. MDiscover does not
carry a request id, though, so any peer that traverses with
MDS_TRAVERSE_PATH_LOCKED gets the exception, including one working for an
unrelated request. open_remote_dentry with want_xlocked, as used by
handle_peer_rename_prep and handle_peer_rmdir_prep, discovers the primary
dentry of the inode it is opening that way.

If that dentry belongs to a rename that has already projected its new
linkage and is waiting for its journal entry, the new replica gets the
old linkage and is not a witness. When the rename commits,
_rename_finish sends MDentryLink for destdn to every replica that did not
witness it, on the assumption that such a replica is null. A replica of a
rename-over destdn is not null, so handle_dentry_link fails its assertion
that the replica is null. A late replica of srcdn is never told that the
name became null, which can trip the same assert the next time the name
is linked.

early_reply already relies on this not happening. It leaves a rename's
dentry xlocks undone for exactly this reason:

    // so do not set xlocks on dentries "done", the xlocks prevent dentries
    // that have projected linkages from getting new replica.

The path_locked exception bypasses that.

One way to get there: a client renames over the primary link of a hard
linked inode. The rename has no journaled peers, so it gets an early
reply. Its inode xlocks become xlockdone, and the same client can take
them over at once; without the early reply the two renames would
serialize on those xlocks. The client then renames over another link of
the same inode. A rank that witnesses this second rename and does not
have the inode in cache opens it, discovers the primary dentry, still
xlocked by the first rename, and receives its pre-rename linkage. A
moment later the first rename commits and sends that rank MDentryLink.

If both renames move links of one source inode, as when a tool replaces
every link of a set with links to a new inode, that witness is not the
source inode's auth: such a witness journals, so the first rename would
not have been early-replied. It is a witness because it still holds a
replica of srcdn or destdn, for example one left behind after the
directory's subtree was exported, while it no longer has the inode
itself in cache.

Reproduced on v18.2.7 with two active ranks and one client. /d is
pinned to rank 1 and /d/C to rank 0; /d/A/f is the primary link of
inode O, /d/B/f1 a remote link to O, /d/C/u the primary link of U and
/d/B/.stg1 a remote link to U. With mds_log_pause set on rank 1,
renaming /d/A/T over /d/A/f gets an early reply, and renaming
/d/B/.stg1 over /d/B/f1 makes rank 0, the auth of U, a witness. Its
rename_prep opens O, and rank 1 logs "handle_discover allowing discovery of xlocked
[dentry #0x1/d/A/f ... pv=16 v=8 ...]". When the log is unpaused,
_rename_finish sends MDentryLink for /d/A/f, and rank 0 fails the
assertion in handle_dentry_link. With this change, rank 1 logs
"handle_discover blocking on xlocked" for /d/A/f, the second rename
completes once the first commits, and neither rank aborts.

Allow the path_locked exception only while the dentry has no projected
linkage. After that, block on the xlock the same way a normal discover
does. The xlocker no longer depends on any peer, so it will finish and
drop the xlock, and the discover is retried against the committed
linkage. The xlocker's own witnesses are unaffected because they never
discover after it projects. Nudge the log when blocking: an
early-replied xlocker defers its journal flush, and the discover, and
any peer request waiting behind it, should not wait for the next tick.

Also drop the comments about tail items. They have been stale since
commit cac3c01, "mds: change MDCache::discover_path()'s
wants_xlocked semantic", made the exception apply at every depth.

Signed-off-by: Anthony D'Atri <[email protected]>
Assisted by Claude Opus-5.5
(cherry picked from commit d0a7454)
With two active ranks, rename a file over the primary link of a hard
linked inode on rank 1 while rank 1's journal is paused, so the rename
gets an early reply and keeps its new linkage projected. Then rename a
remote link of an inode on rank 0 over another link of the same inode.
Rank 0 is a witness of that rename, and its rename_prep discovers the
primary dentry still xlocked by the first rename.

Check that rank 0 is still running, with the same gid, after the
journal is unpaused, and that both renames took effect. Without the
fix, the discover returns the pre-rename linkage, and the first
rename's MDentryLink fails ceph_assert(dnl->is_null()) on rank 0.

Fixes: https://tracker.ceph.com/issues/81730
Assisted-by: LLM
Signed-off-by: Xiubo Li <[email protected]>
(cherry picked from commit 14fcfe1)
@anthonyeleven anthonyeleven added this to the umbrella milestone Nov 8, 2026
@github-actions github-actions Bot added cephfs Ceph File System tests releng-audit-pass Release engineering: passed backport verification audit. labels Nov 8, 2026
@yuriw

yuriw commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri6-testing-20261111.163544-umbrella.

@batrick

batrick commented Nov 21, 2026

Copy link
Copy Markdown
Member

@batrick
batrick merged commit c1c108a into ceph:umbrella Nov 23, 2026
24 checks passed
yuriw added a commit that referenced this pull request Nov 30, 2026
Pick up 10 PRs merged since the last changelog generation
(#73625 #73464 #72913 #72967 #72345 #74280 #73453 #73259 #73261 #72691).

Signed-off-by: Yuri Weinstein <[email protected]>
yuriw added a commit that referenced this pull request Nov 30, 2026
Pick up 10 PRs merged since the last changelog generation
(#73625 #73464 #72913 #72967 #72345 #74280 #73453 #73259 #73261 #72691).

Assisted-by: Claude-v2.1.332:claude-sonnet-5
Signed-off-by: Yuri Weinstein <[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 needs-qa releng-audit-pass Release engineering: passed backport verification audit. tests wip-pdonnell-testing6 wip-yuri6-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants