]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: new FileLock lock->sync state
authorSage Weil <sage@newdream.net>
Wed, 17 Dec 2008 22:47:55 +0000 (14:47 -0800)
committerSage Weil <sage@newdream.net>
Tue, 23 Dec 2008 19:45:21 +0000 (11:45 -0800)
Previously this was avoided, more or less by accident.  ScatterLock
has it, so we'll presumably need it in FileLock to fold them
together.

src/mds/FileLock.h
src/mds/Locker.cc

index d9987c9eab12d0281ebc60a98e036e2f29819659..28781d8305e22e546f51ea522f88eb110de50ebe 100644 (file)
@@ -25,11 +25,16 @@ using namespace std;
 
 // states and such.
 //  C = cache reads, R = read, W = write, A = append, B = buffer writes, L = lazyio
+//
+// lower-case on a transition state means a 'trailing' rdlock or wrlock.. 
+// the old locks still there (from the prior state), but new locks aren't
+// allowed.
 
 //                               -----auth--------   ---replica-------
 #define LOCK_SYNC_        1  // AR   R . / C R . . . L   R . / C R . . . L   stat()
 #define LOCK_LONER_SYNC  -12 // A    . . / C r . . . L *                     loner -> sync
 #define LOCK_MIXED_SYNC  -13 // A    . . / . R . . . L
+#define LOCK_LOCK_SYNC   -14 // A    R w / C . . . b L
 
 #define LOCK_LOCK_        2  // AR   R W / C . . . B .   . . / C . . . . .   truncate()
 #define LOCK_SYNC_LOCK_  -3  // AR   R . / C . . . . .   . . / C . . . . .
@@ -37,11 +42,11 @@ using namespace std;
 #define LOCK_MIXED_LOCK  -5  // A    . . / . . . . . .
 
 #define LOCK_MIXED        6  // AR   . . / . R W A . L   . . / . R . . . L
-#define LOCK_SYNC_MIXED  -7  // AR   R . / . R . . . L   . . / . R . . . L 
+#define LOCK_SYNC_MIXED  -7  // AR   r . / . R . . . L   . . / . R . . . L 
 #define LOCK_LONER_MIXED -8  // A    . . / . r w a . L *                     loner -> mixed
 
 #define LOCK_LONER        9  // A    . . / c r w a b L *      (lock)      
-#define LOCK_SYNC_LONER  -10 // A    . . / . R . . . L 
+#define LOCK_SYNC_LONER  -10 // A    r . / . R . . . L 
 #define LOCK_MIXED_LONER -11 // A    . . / . R W A . L 
 #define LOCK_LOCK_LONER  -15 // A    . . / c . . . b . *
 
@@ -52,6 +57,7 @@ inline const char *get_filelock_state_name(int n) {
   case LOCK_SYNC: return "sync";
   case LOCK_LONER_SYNC: return "loner->sync";
   case LOCK_MIXED_SYNC: return "mixed->sync";
+  case LOCK_LOCK_SYNC: return "lock->sync";
   case LOCK_LOCK: return "lock";
   case LOCK_SYNC_LOCK: return "sync->lock";
   case LOCK_LONER_LOCK: return "loner->lock";
index dc599b382578ba0f8bea7332b5cffa3dbeb437bd..cd4ca2d16194cb12bfb3e9aa2bf5963823d92757 100644 (file)
@@ -3279,6 +3279,7 @@ void Locker::file_eval_gather(FileLock *lock)
       // to sync
     case LOCK_LONER_SYNC:
     case LOCK_MIXED_SYNC:
+    case LOCK_LOCK_SYNC:
       lock->set_state(LOCK_SYNC);
       in->loner_cap = -1;
       
@@ -3427,37 +3428,34 @@ bool Locker::file_sync(FileLock *lock)
   assert(in->is_auth());
   assert(lock->is_stable());
 
-  if (lock->get_state() != LOCK_LOCK) {
-    // gather?
-    switch (lock->get_state()) {
-    case LOCK_MIXED: lock->set_state(LOCK_MIXED_SYNC); break;
-    case LOCK_LONER: lock->set_state(LOCK_LONER_SYNC); break;
-    default: assert(0);
-    }
-
-    int gather = 0;
-    int loner_issued, other_issued;
-    in->get_caps_issued(&loner_issued, &other_issued);
-    if ((loner_issued & ~lock->caps_allowed(true)) ||
-       (other_issued & ~lock->caps_allowed(false))) {
-      issue_caps(in);
-      gather++;
-    }
-    if (lock->is_wrlocked())
-      gather++;
-    if (in->state_test(CInode::STATE_NEEDSRECOVER)) {
-      mds->mdcache->queue_file_recover(in);
-      mds->mdcache->do_file_recover();
-      gather++;
-    }
-
-    if (gather) {
-      lock->get_parent()->auth_pin(lock);
-      return false;
-    }
+  // gather?
+  switch (lock->get_state()) {
+  case LOCK_MIXED: lock->set_state(LOCK_MIXED_SYNC); break;
+  case LOCK_LONER: lock->set_state(LOCK_LONER_SYNC); break;
+  case LOCK_LOCK: lock->set_state(LOCK_LOCK_SYNC); break;
+  default: assert(0);
   }
 
-  assert(!lock->is_wrlocked());  // FIXME if we hit this we need a new gsynck state or somethin'
+  int gather = 0;
+  int loner_issued, other_issued;
+  in->get_caps_issued(&loner_issued, &other_issued);
+  if ((loner_issued & ~lock->caps_allowed(true)) ||
+      (other_issued & ~lock->caps_allowed(false))) {
+    issue_caps(in);
+    gather++;
+  }
+  if (lock->is_wrlocked())
+    gather++;
+  if (in->state_test(CInode::STATE_NEEDSRECOVER)) {
+    mds->mdcache->queue_file_recover(in);
+    mds->mdcache->do_file_recover();
+    gather++;
+  }
+  
+  if (gather) {
+    lock->get_parent()->auth_pin(lock);
+    return false;
+  }
 
   // ok
   if (in->is_replicated()) {