]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: rewrite scatter_tempsync
authorSage Weil <sage@newdream.net>
Fri, 17 Apr 2009 18:28:28 +0000 (11:28 -0700)
committerSage Weil <sage@newdream.net>
Fri, 17 Apr 2009 18:28:28 +0000 (11:28 -0700)
Recall caps, among other things.

src/mds/Locker.cc

index 542982ff35690060fee7a87f5f0ddf7ed91b7f4f..83ce295f23c29884f425031327bb8f50a8b8a30b 100644 (file)
@@ -2884,57 +2884,54 @@ void Locker::scatter_tick()
 
 void Locker::scatter_tempsync(ScatterLock *lock, bool *need_issue)
 {
-
-#warning rewrite scatter_tempsync
-
   dout(10) << "scatter_tempsync " << *lock
           << " on " << *lock->get_parent() << dendl;
   assert(lock->get_parent()->is_auth());
   assert(lock->is_stable());
 
-  switch (lock->get_state()) {
-  case LOCK_SYNC:
-    assert(0);   // this shouldn't happen
-
-  case LOCK_LOCK:
-    if (lock->is_wrlocked() ||
-       lock->is_xlocked()) {
-      lock->set_state(LOCK_LOCK_TSYN);
-      lock->get_parent()->auth_pin(lock);
-      return;
-    }
-    break; // do it.
+  CInode *in = (CInode *)lock->get_parent();
 
-  case LOCK_MIX:
-    if (!lock->is_wrlocked() &&
-       !lock->get_parent()->is_replicated()) {
-      break; // do it.
-    }
-    
-    lock->set_state(LOCK_MIX_TSYN);
-    lock->get_parent()->auth_pin(lock);
+  switch (lock->get_state()) {
+  case LOCK_SYNC: assert(0);   // this shouldn't happen
+  case LOCK_LOCK: lock->set_state(LOCK_LOCK_TSYN); break;
+  case LOCK_MIX: lock->set_state(LOCK_MIX_TSYN); break;
+  default: assert(0);
+  }
 
-    if (lock->get_parent()->is_replicated()) {
-      lock->init_gather();
-      send_lock_message(lock, LOCK_AC_LOCK);
-    }
+  int gather = 0;
+  if (lock->is_wrlocked())
+    gather++;
+  if (lock->is_xlocked())
+    gather++;
 
-    return;
+  if (in->issued_caps_need_gather(lock)) {
+    if (need_issue)
+      *need_issue = true;
+    else
+      issue_caps(in);
+    gather++;
+  }
 
-  case LOCK_TSYN:
-    return; // done
+  if (lock->get_state() == LOCK_MIX_TSYN &&
+      in->is_replicated()) {
+    lock->init_gather();
+    send_lock_message(lock, LOCK_AC_LOCK);
+    gather++;
   }
-  
-  // do tempsync
-  ((CInode *)lock->get_parent())->try_drop_loner();
 
-  lock->set_state(LOCK_TSYN);
-  lock->finish_waiters(ScatterLock::WAIT_RD|ScatterLock::WAIT_STABLE);
+  if (gather) {
+    in->auth_pin(lock);
+  } else {
+    // do tempsync
+    in->try_drop_loner();
+    
+    lock->set_state(LOCK_TSYN);
+    lock->finish_waiters(ScatterLock::WAIT_RD|ScatterLock::WAIT_STABLE);
+  }
 }
 
 
 
-
 // ==========================================================================
 // local lock