It's a function of lock type.
};
// -- wait --
- static const int WAIT_LOCK_OFFSET = 8;
+ //static const int WAIT_LOCK_OFFSET = 8;
void add_waiter(__u64 tag, Context *c);
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++;
}
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;
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
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++;
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.
}
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() {
// 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;
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) {
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());
}