From 9114e6fccbe42837a33688b9d7a1f65af596c370 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 24 Aug 2009 12:45:48 -0700 Subject: [PATCH] mds: kill SimpleLock::wait_shift It's a function of lock type. --- src/mds/CDentry.h | 6 +++--- src/mds/CInode.h | 25 ++++++++----------------- src/mds/LocalLock.h | 4 ++-- src/mds/ScatterLock.h | 4 ++-- src/mds/SimpleLock.h | 29 ++++++++++++++++++++++------- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index 5c2bdb9a41794..6ac1c828a947a 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -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; diff --git a/src/mds/CInode.h b/src/mds/CInode.h index aa2bff20bb511..bc32776ff15e4 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -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++; diff --git a/src/mds/LocalLock.h b/src/mds/LocalLock.h index f5cf2106443d3..e21b5001b984a 100644 --- a/src/mds/LocalLock.h +++ b/src/mds/LocalLock.h @@ -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. } diff --git a/src/mds/ScatterLock.h b/src/mds/ScatterLock.h index d31bf72752c9c..aff5a1d5f3d65 100644 --- a/src/mds/ScatterLock.h +++ b/src/mds/ScatterLock.h @@ -27,8 +27,8 @@ public: xlist::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() { diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index a1e66eafc539c..e7c2496ec0e71 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -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& 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()); } -- 2.39.5