From 08f0e3e977b6a50e94c4d7dbcead23ebcc4efd48 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 2 Jan 2008 18:21:20 -0800 Subject: [PATCH] basic request_renewcaps and renewcaps session ops --- src/client/Client.cc | 8 ++++---- src/include/ceph_fs.h | 8 +++++--- src/mds/FileLock.h | 1 - src/mds/MDS.cc | 6 ++---- src/mds/MDS.h | 4 ++-- src/mds/Server.cc | 23 +++++++++++++++++------ src/mds/SessionMap.h | 3 ++- src/messages/MClientSession.h | 14 ++++++-------- 8 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 6c1dd5029e703..6f040c4351f3b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -697,7 +697,7 @@ MClientReply *Client::make_request(MClientRequest *req, if (waiting_for_session.count(mds) == 0) { dout(10) << "opening session to mds" << mds << dendl; - messenger->send_message(new MClientSession(MClientSession::OP_REQUEST_OPEN), + messenger->send_message(new MClientSession(CEPH_SESSION_REQUEST_OPEN), mdsmap->get_inst(mds)); } @@ -770,12 +770,12 @@ void Client::handle_client_session(MClientSession *m) int from = m->get_source().num(); switch (m->op) { - case MClientSession::OP_OPEN: + case CEPH_SESSION_OPEN: assert(mds_sessions.count(from) == 0); mds_sessions[from] = 0; break; - case MClientSession::OP_CLOSE: + case CEPH_SESSION_CLOSE: mds_sessions.erase(from); // FIXME: kick requests (hard) so that they are redirected. or fail. break; @@ -1579,7 +1579,7 @@ int Client::unmount() p != mds_sessions.end(); ++p) { dout(2) << "sending client_session close to mds" << p->first << " seq " << p->second << dendl; - messenger->send_message(new MClientSession(MClientSession::OP_REQUEST_CLOSE, + messenger->send_message(new MClientSession(CEPH_SESSION_REQUEST_CLOSE, p->second), mdsmap->get_inst(p->first)); } diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 5df1ea8fbaf22..dde40124c9c3b 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -59,10 +59,10 @@ struct ceph_timeval { */ typedef __u32 ceph_frag_t; -static inline __u32 frag_make(__u32 b, __u32 v) { return (b << 24) | (v & (0xffffffffull >> (32-b))); } +static inline __u32 frag_make(__u32 b, __u32 v) { return (b << 24) | (v & (0xffffffu >> (24-b))); } static inline __u32 frag_bits(__u32 f) { return f >> 24; } static inline __u32 frag_value(__u32 f) { return f & 0xffffffu; } -static inline __u32 frag_mask(__u32 f) { return 0xffffffffull >> (32-frag_bits(f)); } +static inline __u32 frag_mask(__u32 f) { return 0xffffffu >> (24-frag_bits(f)); } static inline __u32 frag_next(__u32 f) { return (frag_bits(f) << 24) | (frag_value(f)+1); } /* @@ -283,7 +283,9 @@ enum { CEPH_SESSION_REQUEST_OPEN, CEPH_SESSION_OPEN, CEPH_SESSION_REQUEST_CLOSE, - CEPH_SESSION_CLOSE + CEPH_SESSION_CLOSE, + CEPH_SESSION_REQUEST_RENEWCAPS, + CEPH_SESSION_RENEWCAPS }; /* client_request */ diff --git a/src/mds/FileLock.h b/src/mds/FileLock.h index b2e409198bf69..9fd86ae9be20c 100644 --- a/src/mds/FileLock.h +++ b/src/mds/FileLock.h @@ -23,7 +23,6 @@ using namespace std; #include "include/buffer.h" #include "SimpleLock.h" -#include "Capability.h" // states and such. // C = cache reads, R = read, W = write, A = append, B = buffer writes, L = lazyio diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index cabca2dd284a4..1ba878c87f6c5 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -47,8 +47,6 @@ #include "messages/MMDSMap.h" #include "messages/MMDSBeacon.h" -#include "messages/MPing.h" -#include "messages/MPingAck.h" #include "messages/MGenericMessage.h" #include "messages/MOSDMap.h" @@ -1033,13 +1031,13 @@ void MDS::suicide() void MDS::dispatch(Message *m) { mds_lock.Lock(); - my_dispatch(m); + _dispatch(m); mds_lock.Unlock(); } -void MDS::my_dispatch(Message *m) +void MDS::_dispatch(Message *m) { // from bad mds? if (m->get_source().is_mds()) { diff --git a/src/mds/MDS.h b/src/mds/MDS.h index 985e2d3da6948..3c3d63ac0e919 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -268,7 +268,7 @@ class MDS : public Dispatcher { // messages void proc_message(Message *m); virtual void dispatch(Message *m); - void my_dispatch(Message *m); + void _dispatch(Message *m); void ms_handle_failure(Message *m, const entity_inst_t& inst); @@ -291,7 +291,7 @@ public: this->mds = mds; } virtual void finish(int r) { - mds->my_dispatch(m); + mds->_dispatch(m); } }; diff --git a/src/mds/Server.cc b/src/mds/Server.cc index a4edca86400cb..1e5ddd225c1af 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -120,7 +120,6 @@ void Server::dispatch(Message *m) // ---------------------------------------------------------- // SESSION management - class C_MDS_session_finish : public Context { MDS *mds; Session *session; @@ -144,7 +143,19 @@ void Server::handle_client_session(MClientSession *m) assert(m->get_source().is_client()); // should _not_ come from an mds! switch (m->op) { - case MClientSession::OP_REQUEST_OPEN: + + case CEPH_SESSION_REQUEST_RENEWCAPS: + if (!session) { + dout(10) << "dne, dropping this req" << dendl; + delete m; + return; + } + mds->sessionmap.touch_session(session); + mds->messenger->send_message(new MClientSession(CEPH_SESSION_RENEWCAPS), session->inst); + delete m; + return; + + case CEPH_SESSION_REQUEST_OPEN: open = true; if (session && (session->is_opening() || session->is_open())) { dout(10) << "already open|opening, dropping this req" << dendl; @@ -157,7 +168,7 @@ void Server::handle_client_session(MClientSession *m) session->state = Session::STATE_OPENING; break; - case MClientSession::OP_REQUEST_CLOSE: + case CEPH_SESSION_REQUEST_CLOSE: if (!session || session->is_closing()) { dout(10) << "already closing|dne, dropping this req" << dendl; delete m; @@ -211,9 +222,9 @@ void Server::_session_logged(Session *session, bool open, version_t pv) // reply if (open) - mds->messenger->send_message(new MClientSession(MClientSession::OP_OPEN), session->inst); + mds->messenger->send_message(new MClientSession(CEPH_SESSION_OPEN), session->inst); else - mds->messenger->send_message(new MClientSession(MClientSession::OP_CLOSE), session->inst); + mds->messenger->send_message(new MClientSession(CEPH_SESSION_CLOSE), session->inst); } void Server::prepare_force_open_sessions(map& cm) @@ -245,7 +256,7 @@ void Server::finish_force_open_sessions(map& cm) if (session->is_opening()) { dout(10) << "force_open_sessions opening " << session->inst << dendl; session->state = Session::STATE_OPEN; - mds->messenger->send_message(new MClientSession(MClientSession::OP_OPEN), session->inst); + mds->messenger->send_message(new MClientSession(CEPH_SESSION_OPEN), session->inst); } } mds->sessionmap.version++; diff --git a/src/mds/SessionMap.h b/src/mds/SessionMap.h index f864e8f834287..33d86370a56a0 100644 --- a/src/mds/SessionMap.h +++ b/src/mds/SessionMap.h @@ -43,7 +43,6 @@ public: static const int STATE_RECONNECTING = 5; int state; - utime_t last_alive; // last alive entity_inst_t inst; xlist::item session_list_item; @@ -56,6 +55,7 @@ private: version_t cap_push_seq; // cap push seq # public: xlist caps; // inodes with caps; front=most recently used + utime_t last_renew; public: version_t inc_push_seq() { return ++cap_push_seq; } @@ -152,6 +152,7 @@ public: session_map.erase(s->inst.name); } void touch_session(Session *s) { + s->last_renew = g_clock.now(); session_list.push_back(&s->session_list_item); } diff --git a/src/messages/MClientSession.h b/src/messages/MClientSession.h index 65e36157a8867..73aa364827723 100644 --- a/src/messages/MClientSession.h +++ b/src/messages/MClientSession.h @@ -19,16 +19,14 @@ class MClientSession : public Message { public: - const static int OP_REQUEST_OPEN = CEPH_SESSION_REQUEST_OPEN; - const static int OP_OPEN = CEPH_SESSION_OPEN; - const static int OP_REQUEST_CLOSE = CEPH_SESSION_REQUEST_CLOSE; - const static int OP_CLOSE = CEPH_SESSION_CLOSE; static const char *get_opname(int o) { switch (o) { - case OP_REQUEST_OPEN: return "request_open"; - case OP_OPEN: return "open"; - case OP_REQUEST_CLOSE: return "request_close"; - case OP_CLOSE: return "close"; + case CEPH_SESSION_REQUEST_OPEN: return "request_open"; + case CEPH_SESSION_OPEN: return "open"; + case CEPH_SESSION_REQUEST_CLOSE: return "request_close"; + case CEPH_SESSION_CLOSE: return "close"; + case CEPH_SESSION_REQUEST_RENEWCAPS: return "request_renewcaps"; + case CEPH_SESSION_RENEWCAPS: return "renewcaps"; default: assert(0); return 0; } } -- 2.39.5