]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: kill SimpleLock::wait_shift
authorSage Weil <sage@newdream.net>
Mon, 24 Aug 2009 19:45:48 +0000 (12:45 -0700)
committerSage Weil <sage@newdream.net>
Mon, 24 Aug 2009 19:45:48 +0000 (12:45 -0700)
It's a function of lock type.

src/mds/CDentry.h
src/mds/CInode.h
src/mds/LocalLock.h
src/mds/ScatterLock.h
src/mds/SimpleLock.h

index 5c2bdb9a41794f12a325d86b0a9cad61a921aa68..6ac1c828a947a751d4f354f85f5da78903d5deef 100644 (file)
@@ -80,7 +80,7 @@ public:
   };
 
   // -- wait --
-  static const int WAIT_LOCK_OFFSET = 8;
+  //static const int WAIT_LOCK_OFFSET = 8;
 
   void add_waiter(__u64 tag, Context *c);
 
@@ -161,7 +161,7 @@ public:
     version(0), projected_version(0),
     xlist_dirty(this),
     auth_pins(0), nested_auth_pins(0), nested_anchors(0),
-    lock(this, CEPH_LOCK_DN, WAIT_LOCK_OFFSET) {
+    lock(this, CEPH_LOCK_DN) {
     g_num_dn++;
     g_num_dna++;
   }
@@ -173,7 +173,7 @@ public:
     version(0), projected_version(0),
     xlist_dirty(this),
     auth_pins(0), nested_auth_pins(0), nested_anchors(0),
-    lock(this, CEPH_LOCK_DN, WAIT_LOCK_OFFSET) {
+    lock(this, CEPH_LOCK_DN) {
     g_num_dn++;
     g_num_dna++;
     linkage.remote_ino = ino;
index aa2bff20bb511d47292a306704ef8efbaf9e1afd..bc32776ff15e4a63b5db819f1fff9c0400f0bb5f 100644 (file)
@@ -131,15 +131,6 @@ public:
   static const __u64 WAIT_FROZEN      = (1<<3);
   static const __u64 WAIT_TRUNC       = (1<<4);
   
-  static const int WAIT_AUTHLOCK_OFFSET        = 5;
-  static const int WAIT_LINKLOCK_OFFSET        = 5 +   SimpleLock::WAIT_BITS;
-  static const int WAIT_DIRFRAGTREELOCK_OFFSET = 5 + 2*SimpleLock::WAIT_BITS;
-  static const int WAIT_FILELOCK_OFFSET        = 5 + 3*SimpleLock::WAIT_BITS;
-  static const int WAIT_VERSIONLOCK_OFFSET     = 5 + 4*SimpleLock::WAIT_BITS;
-  static const int WAIT_XATTRLOCK_OFFSET       = 5 + 5*SimpleLock::WAIT_BITS;
-  static const int WAIT_SNAPLOCK_OFFSET        = 5 + 6*SimpleLock::WAIT_BITS;
-  static const int WAIT_NESTLOCK_OFFSET        = 5 + 7*SimpleLock::WAIT_BITS;
-
   static const __u64 WAIT_ANY_MASK     = (__u64)(-1);
 
   // misc
@@ -326,14 +317,14 @@ private:
     xlist_dirty_dirfrag_dirfragtree(this), 
     auth_pins(0), nested_auth_pins(0),
     nested_anchors(0),
-    versionlock(this, CEPH_LOCK_IVERSION, WAIT_VERSIONLOCK_OFFSET),
-    authlock(this, CEPH_LOCK_IAUTH, WAIT_AUTHLOCK_OFFSET),
-    linklock(this, CEPH_LOCK_ILINK, WAIT_LINKLOCK_OFFSET),
-    dirfragtreelock(this, CEPH_LOCK_IDFT, WAIT_DIRFRAGTREELOCK_OFFSET),
-    filelock(this, CEPH_LOCK_IFILE, WAIT_FILELOCK_OFFSET),
-    xattrlock(this, CEPH_LOCK_IXATTR, WAIT_XATTRLOCK_OFFSET),
-    snaplock(this, CEPH_LOCK_ISNAP, WAIT_SNAPLOCK_OFFSET),
-    nestlock(this, CEPH_LOCK_INEST, WAIT_NESTLOCK_OFFSET),
+    versionlock(this, CEPH_LOCK_IVERSION),
+    authlock(this, CEPH_LOCK_IAUTH),
+    linklock(this, CEPH_LOCK_ILINK),
+    dirfragtreelock(this, CEPH_LOCK_IDFT),
+    filelock(this, CEPH_LOCK_IFILE),
+    xattrlock(this, CEPH_LOCK_IXATTR),
+    snaplock(this, CEPH_LOCK_ISNAP),
+    nestlock(this, CEPH_LOCK_INEST),
     loner_cap(-1), want_loner_cap(-1)
   {
     g_num_ino++;
index f5cf2106443d3d5ff0be8d2f0b160a7a53dbf299..e21b5001b984a39d8d6ea8e5d8c63e0ba08b07e6 100644 (file)
@@ -20,8 +20,8 @@
 
 class LocalLock : public SimpleLock {
 public:
-  LocalLock(MDSCacheObject *o, int t, int ws) : 
-    SimpleLock(o, t, ws) {
+  LocalLock(MDSCacheObject *o, int t) : 
+    SimpleLock(o, t) {
     set_state(LOCK_LOCK); // always.
   }
 
index d31bf72752c9c4f6461cf98a10d6010d1982a9e3..aff5a1d5f3d658963a6e04d0343da8e6474fcd79 100644 (file)
@@ -27,8 +27,8 @@ public:
   xlist<ScatterLock*>::item xlistitem_updated;
   utime_t update_stamp;
 
-  ScatterLock(MDSCacheObject *o, int t, int ws) : 
-    SimpleLock(o, t, ws),
+  ScatterLock(MDSCacheObject *o, int t) : 
+    SimpleLock(o, t),
     dirty(false), flushing(false), scatter_wanted(false),
     xlistitem_updated(this) {}
   ~ScatterLock() {
index a1e66eafc539c3e0b7c4f9d18582ee10e8226fe6..e7c2496ec0e71e8bdb86a9fdd8516cf5641c0c56 100644 (file)
@@ -111,7 +111,22 @@ protected:
   // parent (what i lock)
   MDSCacheObject *parent;
   int type;
-  int wait_shift;
+
+  int get_wait_shift() {
+    switch (type) {
+    case CEPH_LOCK_DN:       return 8;
+    case CEPH_LOCK_IAUTH:    return 5 +   SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_ILINK:    return 5 +   SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_IDFT:     return 5 + 2*SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_IFILE:    return 5 + 3*SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_IVERSION: return 5 + 4*SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_IXATTR:   return 5 + 5*SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_ISNAP:    return 5 + 6*SimpleLock::WAIT_BITS;
+    case CEPH_LOCK_INEST:    return 5 + 7*SimpleLock::WAIT_BITS;
+    default:
+      assert(0);
+    }
+  }
 
   // lock state
   __s32 state;
@@ -127,8 +142,8 @@ public:
 
 
 public:
-  SimpleLock(MDSCacheObject *o, int t, int ws) :
-    parent(o), type(t), wait_shift(ws),
+  SimpleLock(MDSCacheObject *o, int t) :
+    parent(o), type(t),
     state(LOCK_SYNC), num_client_lease(0),
     num_rdlock(0), num_wrlock(0), num_xlock(0),
     xlock_by(0), xlock_by_client(-1), excl_client(-1) {
@@ -196,16 +211,16 @@ public:
     parent->encode_lock_state(type, bl);
   }
   void finish_waiters(__u64 mask, int r=0) {
-    parent->finish_waiting(mask << wait_shift, r);
+    parent->finish_waiting(mask << get_wait_shift(), r);
   }
   void take_waiting(__u64 mask, list<Context*>& ls) {
-    parent->take_waiting(mask << wait_shift, ls);
+    parent->take_waiting(mask << get_wait_shift(), ls);
   }
   void add_waiter(__u64 mask, Context *c) {
-    parent->add_waiter(mask << wait_shift, c);
+    parent->add_waiter(mask << get_wait_shift(), c);
   }
   bool is_waiter_for(__u64 mask) {
-    return parent->is_waiter_for(mask << wait_shift);
+    return parent->is_waiter_for(mask << get_wait_shift());
   }