From: Yan, Zheng Date: Mon, 13 Feb 2017 01:30:43 +0000 (+0800) Subject: mds: fix deadlock when wrlock and remote_wrlock the same lock X-Git-Tag: v12.0.1~266^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7fb8e011256a27161b89361c3e2d5a50796c115b;p=ceph.git mds: fix deadlock when wrlock and remote_wrlock the same lock When handling trans-authority rename, the master mds may ask slave mds to wrlock a lock, then try to wrlock the same lock locally. If the master can't wrlock the lock locally, it need to drop the remote wrlock and wait. Otherwise deadlock happens. The code does not handle a corner case: Lock::wrlock_start() can sleep even when SimpleLock::can_wrlock() return true. Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 8fc5c61e4f1..8d3e34deb32 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -539,7 +539,8 @@ bool Locker::acquire_locks(MDRequestRef& mdr, remote_wrlock_start(*p, (*remote_wrlocks)[*p], mdr); goto out; } - if (!wrlock_start(*p, mdr)) + // nowait if we have already gotten remote wrlock + if (!wrlock_start(*p, mdr, need_remote_wrlock)) goto out; dout(10) << " got wrlock on " << **p << " " << *(*p)->get_parent() << dendl; }