From 9044e954aedd96fed518d1b59a68bce2c29d4570 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 24 Mar 2008 13:02:02 -0700 Subject: [PATCH] some lock bits --- src/include/ceph_fs.h | 2 ++ src/mds/Locker.cc | 5 +++-- src/mds/SimpleLock.h | 31 +++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 3d6b707e6e538..4a237f9d2694e 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -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 diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 138dbfd5b82f5..c9413a9c96ea0 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -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 diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index e785e2c36d50c..76e9481fda91b 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -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 gather_set; // auth + set gather_set; // auth+rep. >= 0 is mds, < 0 is client + set 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::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()) -- 2.39.5