Bug #76059
closedcrash and shutdown hang in hash_into_rank_bucket() when ephemeral pins active and max_mds drops to 0
0%
Description
Summary¶
Two related bugs manifest when a CephFS filesystem is paused (max_mds set to 0) while one or more inodes have ephemeral directory pins (distributed or random ephemeral pins) active:
- Crash -- the MDS daemon aborts with a failed assertion inside
hash_into_rank_bucket(). - Shutdown hang -- after the crash is fixed, a secondary issue causes
shutdown_pass()to loop indefinitely, preventing the MDS from completing its shutdown sequence.
How to Reproduce¶
Prerequisites:- A multi-MDS CephFS cluster.
- At least one directory with an ephemeral pin set, e.g.:
setfattr -n ceph.dir.pin.distributed -v 1 /mnt/cephfs/some_dir
Steps to trigger the crash:
- With ephemerally-pinned directories present, pause the filesystem (which sets max_mds to 0):
ceph fs set <fs_name> down true
- The MDS daemon receives the new MDSMap with max_mds 0, detects the max_mds change, and immediately calls
maybe_export_pin()on all ephemerally-pinned inodes to redistribute them. This path reacheshash_into_rank_bucket()with max_mds 0 and aborts.
Steps to trigger the shutdown hang (second bug):
After applying the crash fix alone, hash_into_rank_bucket() now returns MDS_RANK_NONE when max_mds 0. The hang then appears:
- As above, pause the filesystem while ephemeral pins are active.
- The MDS enters
shutdown_pass(), which iterates over auth subtrees to export them to rank 0. - Ephemerally-pinned dirs are unconditionally skipped because
shutdown_pass()expectshandle_export_pins()to place them. handle_export_pins()callshash_into_rank_bucket(), receivesMDS_RANK_NONE, and cannot schedule any export.- The ephemerally-pinned dirs are never exported;
shutdown_pass()loops forever.
Root cause¶
Bug 1 -- crash in hash_into_rank_bucket()¶
hash_into_rank_bucket() implements a jump-consistent hash to map an inode number to an MDS rank in [0, max_mds). The loop condition is j < max_mds, so when max_mds 0 the loop body never runs and b stays at its initial value of -1. The assertion at the end of the function then fails:
// src/mds/MDCache.cc
mds_rank_t MDCache::hash_into_rank_bucket(inodeno_t ino, frag_t fg)
{
const mds_rank_t max_mds = mds->mdsmap->get_max_mds();
uint64_t hash = rjhash64(ino);
...
int64_t b = -1, j = 0;
while (j < max_mds) { // never executes when max_mds == 0
b = j;
...
}
auto result = mds_rank_t(b);
ceph_assert(result >= 0 && result < max_mds); // -1 >= 0 is false -> ABORT
return result;
}
Bug 2 -- shutdown hang in shutdown_pass()¶
shutdown_pass() intentionally skips ephemerally-pinned dirs, delegating their export to handle_export_pins(). This design assumes handle_export_pins() can always compute a valid target rank. When max_mds == 0, hash_into_rank_bucket() returns MDS_RANK_NONE, so no export is ever queued. The ephemerally-pinned dirs remain in the cache indefinitely and the shutdown loop never drains them:
// src/mds/MDCache.cc -- shutdown_pass()
if (dir->is_frozen() || ... ||
dir->get_inode()->is_ephemerally_pinned()) { // always true for pinned dirs
continue; // dir is never added to ls
}
ls.push_back(dir); // never reached for ephemerally-pinned dirs
Code Flow¶
Crash path (Bug 1)¶
ceph fs set <fs> down true -> max_mds set to 0 in MDSMap | v MDSDaemon::handle_mds_map() [MDSDaemon.cc] | v MDSRankDispatcher::handle_mds_map() [MDSRank.cc] | v MDCache::handle_mdsmap(new_map, old_map) [MDCache.cc] | detects max_mds changed -> iterates export_ephemeral_pins v CInode::maybe_export_pin() [CInode.cc] | v CInode::queue_export_pin(MDS_RANK_EPHEMERAL_*) [CInode.cc] | v MDCache::hash_into_rank_bucket(ino, fg) [MDCache.cc] | max_mds == 0, loop never runs, b == -1 v ceph_assert(result >= 0 && result < max_mds) <- ABORT / CRASH
Shutdown hang path (Bug 2, after crash fix applied)¶
ceph fs set <fs> down true -> max_mds == 0 | v MDCache::shutdown_pass() [MDCache.cc] | iterates auth subtrees | for each ephemerally-pinned dir: | is_ephemerally_pinned() == true -> skip (continue) | dir never added to export list | v mds->balancer->handle_export_pins() | for each queued pin: | hash_into_rank_bucket() returns MDS_RANK_NONE (max_mds == 0) | no export scheduled | v shutdown_pass() loops again -- no progress
CZ Updated by chung feng zheng 8 months ago
- Pull request ID set to 68413
VS Updated by Venky Shankar 8 months ago
- Category set to Correctness/Safety
- Status changed from New to Fix Under Review
- Target version set to v21.0.0
- Source set to Community (dev)
- Backport set to tentacle,squid
VS Updated by Venky Shankar 7 months ago
- Component(FS) MDS added
VS Updated by Venky Shankar 6 months ago
- Assignee set to Dhairya Parmar
@Dhairya Parmar - please do the relevant backports.
UB Updated by Upkeep Bot 6 months ago
- Status changed from Fix Under Review to Pending Backport
- Merge Commit set to aed8065a545733548a6b4a22c12a8ec9104c5cf3
- Fixed In set to v21.0.0-2118-gaed8065a54
- Upkeep Timestamp set to 2026-06-09T01:33:51+00:00
UB Updated by Upkeep Bot 6 months ago
- Copied to Backport #77259: squid: crash and shutdown hang in hash_into_rank_bucket() when ephemeral pins active and max_mds drops to 0 added
UB Updated by Upkeep Bot 6 months ago
- Copied to Backport #77260: tentacle: crash and shutdown hang in hash_into_rank_bucket() when ephemeral pins active and max_mds drops to 0 added
UB Updated by Upkeep Bot 6 months ago
- Tags (freeform) set to backport_processed
VS Updated by Venky Shankar 6 months ago
- Assignee changed from Dhairya Parmar to Venky Shankar
I am taking this one.
UB Updated by Upkeep Bot 3 months ago
- Status changed from Pending Backport to Backporting
- Tags (freeform) deleted (
backport_processed) - Upkeep Timestamp changed from 2026-06-09T01:33:51+00:00 to 2026-08-27T18:33:54+00:00
UB Updated by Upkeep Bot about 1 month ago
- Released In set to v21.2.0~251
- Upkeep Timestamp changed from 2026-08-27T18:33:54+00:00 to 2026-10-24T01:18:19+00:00
UB Updated by Upkeep Bot about 1 month ago
- Status changed from Backporting to Resolved
- Upkeep Timestamp changed from 2026-10-24T01:18:19+00:00 to 2026-10-28T01:10:01+00:00