]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
some lock bits
authorSage Weil <sage@newdream.net>
Mon, 24 Mar 2008 20:02:02 +0000 (13:02 -0700)
committerSage Weil <sage@newdream.net>
Mon, 24 Mar 2008 20:02:02 +0000 (13:02 -0700)
src/include/ceph_fs.h
src/mds/Locker.cc
src/mds/SimpleLock.h

index 3d6b707e6e538a072da6edf977ac5e23bea00bd3..4a237f9d2694e7eaae0639202d4dc4ce036343ce 100644 (file)
@@ -268,6 +268,8 @@ struct ceph_msg_header {
 #define CEPH_MSG_CLIENT_REPLY           26
 #define CEPH_MSG_CLIENT_FILECAPS        0x310
 
+#define CEPH_MSG_CLIENT_LOCK            28
+
 /* osd */
 #define CEPH_MSG_OSD_GETMAP       40
 #define CEPH_MSG_OSD_MAP          41
index 138dbfd5b82f572bf4836fabc73b3ff2f18369b2..c9413a9c96ea0fd05050419bc5ae03f194576bb1 100644 (file)
@@ -1243,8 +1243,9 @@ void Locker::simple_lock(SimpleLock *lock)
   if (lock->get_state() == LOCK_LOCK) return;
   assert(lock->get_state() == LOCK_SYNC);
   
-  if (lock->get_parent()->is_replicated()) {
-    // bcast to replicas
+  if (lock->get_parent()->is_replicated() ||
+      lock->get_num_clients()) {
+    // bcast to mds replicas
     send_lock_message(lock, LOCK_AC_LOCK);
     
     // change lock
index e785e2c36d50cf83a4b11b614c77028bfc85fc8b..76e9481fda91b15343b733f1fd21c5466741ca88 100644 (file)
@@ -50,6 +50,7 @@ inline const char *get_lock_type_name(int t) {
 #define LOCK_LOCK     2  // AR   R W    . .
 #define LOCK_GLOCKR  -3  // AR   R .    . .
 #define LOCK_REMOTEXLOCK  -50    // on NON-auth
+#define LOCK_CLIENTDEL -60
 
 inline const char *get_simplelock_state_name(int n) {
   switch (n) {
@@ -58,10 +59,26 @@ inline const char *get_simplelock_state_name(int n) {
   case LOCK_LOCK: return "lock";
   case LOCK_GLOCKR: return "glockr";
   case LOCK_REMOTEXLOCK: return "remote_xlock";
+  case LOCK_CLIENTDEL: return "clientdel";
   default: assert(0); return 0;
   }
 }
 
+/*
+
+
+          glockr
+       <-/      ^--
+  lock      -->    sync
+       
+    | ^-- glockc
+    v
+          ^
+  clientdel
+         
+
+ */
+
 class MDRequest;
 
 class SimpleLock {
@@ -82,7 +99,8 @@ protected:
 
   // lock state
   int state;
-  set<int> gather_set;  // auth
+  set<int> gather_set;  // auth+rep.  >= 0 is mds, < 0 is client
+  set<int> client_set;  // auth+rep
 
   // local state
   int num_rdlock;
@@ -155,6 +173,10 @@ public:
         p != parent->replicas_end(); 
         ++p)
       gather_set.insert(p->first);
+    for (set<in>::const_iterator p = client_set.begin();
+        p != client_set.end();
+        p++)
+      gather_set.insert(-1-*p);
   }
   bool is_gathering() { return !gather_set.empty(); }
   bool is_gathering(int i) {
@@ -196,8 +218,11 @@ public:
     return is_xlocked() && xlock_by != mdr;
   }
   MDRequest *get_xlocked_by() { return xlock_by; }
+  
+  int get_num_clients() { return client_set.size(); }
+
   bool is_used() {
-    return is_xlocked() || is_rdlocked();
+    return is_xlocked() || is_rdlocked() || !client_set.empty();
   }
 
   // encode/decode
@@ -283,6 +308,8 @@ public:
     out << get_lock_type_name(get_type()) << " ";
     out << get_simplelock_state_name(get_state());
     if (!get_gather_set().empty()) out << " g=" << get_gather_set();
+    if (!client_set.empty())
+      out << " c=" << client_set;
     if (is_rdlocked()) 
       out << " r=" << get_num_rdlocks();
     if (is_xlocked())