]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: handle "state == LOCK_LOCK_XLOCK" when cancelling xlock
authorYan, Zheng <zheng.z.yan@intel.com>
Wed, 17 Jul 2013 05:52:18 +0000 (13:52 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Mon, 5 Aug 2013 03:09:07 +0000 (11:09 +0800)
If we find lock state is LOCK_LOCK_XLOCK when cancelling xlock,
set lock state to LOCK_XLOCK_DONE and call Locker::eval_gather().
This makes sure the lock will eventually transit to a stable state.
(LOCK_XLOCK_DONE's next state is stable)

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/Locker.cc

index d2d47fbb55dbfdbf686f5e8f4b6ad32c2f6157c1..efb5a741362ef6f08ea0b58fafce23b6cc03d0f6 100644 (file)
@@ -544,8 +544,13 @@ void Locker::cancel_locking(Mutation *mut, set<CInode*> *pneed_issue)
 
   if (lock->get_parent()->is_auth()) {
     bool need_issue = false;
-    if (lock->get_state() == LOCK_PREXLOCK)
+    if (lock->get_state() == LOCK_PREXLOCK) {
       _finish_xlock(lock, -1, &need_issue);
+    } else if (lock->get_state() == LOCK_LOCK_XLOCK &&
+              lock->get_num_xlocks() == 0) {
+      lock->set_state(LOCK_XLOCKDONE);
+      eval_gather(lock, true, &need_issue);
+    }
     if (need_issue)
       pneed_issue->insert(static_cast<CInode *>(lock->get_parent()));
   }
@@ -1516,8 +1521,11 @@ void Locker::xlock_finish(SimpleLock *lock, Mutation *mut, bool *pneed_issue)
                         SimpleLock::WAIT_WR | 
                         SimpleLock::WAIT_RD, 0); 
   } else {
-    if (lock->get_num_xlocks() == 0)
+    if (lock->get_num_xlocks() == 0) {
+      if (lock->get_state() == LOCK_LOCK_XLOCK)
+       lock->set_state(LOCK_XLOCKDONE);
       _finish_xlock(lock, xlocker, &do_issue);
+    }
   }
   
   if (do_issue) {