]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mds/MDSDaemon: unlock `mds_lock` while shutting down Beacon and others 64885/head
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 11 Oct 2024 22:35:13 +0000 (00:35 +0200)
committerVenky Shankar <vshankar@redhat.com>
Thu, 7 Aug 2025 10:28:06 +0000 (15:58 +0530)
commitb40e7c9dc435d2d52fe6a77ecfce88156785771b
tree567cce26efa35b47d7eb037c9aac28cbbb498bdc
parent7f9b3df2a051fbe8a0b4e0016898443a27817670
mds/MDSDaemon: unlock `mds_lock` while shutting down Beacon and others

This fixes a deadlock bug during MDS shutdown:

- the "signal_handler" thread receives the shutdown signal and invokes
  MDSDaemon::suicide() while holding `mds_lock`

- MDSDaemon::suicide() invokes Beacon::send_and_wait() while still
  holding `mds_lock`

- meanwhile, all "ms_dispatch" threads get stuck waiting for
  `mds_lock`, for example in MDCache::upkeep_main() or
  MDSDaemon::ms_dispatch2()

- Beacon::send_and_wait() waits for a `MSG_MDS_BEACON` packet to be
  dispatched (via `cvar` with a timeout)

At this point, even if a `MSG_MDS_BEACON` packet is received by one of
the worker threads, they will put it in the `DispatchQueue`, but no
dispatcher thread will be able to handle it because they are all
stuck.  The cvar.wait_for() call in Beacon::send_and_wait() will
therefore time out and the `MSG_MDS_BEACON` will never be processed.

The proper solution is to unlock `mds_lock` to avoid the dispatchers
from getting stuck.  And in general, we should be holding a lock
strictly only when it is needed and never do blocking calls while
holding a lock.

Fixes: https://tracker.ceph.com/issues/68760
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
(cherry picked from commit c0fedb52fa61cd4a847f5be7eb66629f9b7b6ab7)
src/mds/MDSDaemon.cc