]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix deadlock when wrlock and remote_wrlock the same lock
authorYan, Zheng <zyan@redhat.com>
Mon, 13 Feb 2017 01:30:43 +0000 (09:30 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 20 Feb 2017 08:12:36 +0000 (16:12 +0800)
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" <zyan@redhat.com>
src/mds/Locker.cc

index 8fc5c61e4f100ecbf6db9aa02aedc407a495dc19..8d3e34deb32271117fdb8d5e0a40dc67b640cd3c 100644 (file)
@@ -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;
       }