From: John Spray Date: Wed, 20 Aug 2014 16:56:16 +0000 (+0100) Subject: mds: logging in SessionMap X-Git-Tag: v0.86~192^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dcf8c03794c0cd18d168938045a2b700e4ed414f;p=ceph.git mds: logging in SessionMap (move definitions to .cc to get it) Signed-off-by: John Spray --- diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index 8b797f763c97..15fc25854c76 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -290,3 +290,39 @@ size_t Session::get_request_count() return result; } +void SessionMap::add_session(Session *s) +{ + dout(10) << __func__ << " s=" << s << " name=" << s->info.inst.name << dendl; + + assert(session_map.count(s->info.inst.name) == 0); + session_map[s->info.inst.name] = s; + if (by_state.count(s->state) == 0) + by_state[s->state] = new xlist; + by_state[s->state]->push_back(&s->item_session_list); + s->get(); +} + +void SessionMap::remove_session(Session *s) +{ + dout(10) << __func__ << " s=" << s << " name=" << s->info.inst.name << dendl; + + s->trim_completed_requests(0); + s->item_session_list.remove_myself(); + session_map.erase(s->info.inst.name); + s->put(); +} + +void SessionMap::touch_session(Session *session) +{ + dout(10) << __func__ << " s=" << session << " name=" << session->info.inst.name << dendl; + + // Move to the back of the session list for this state (should + // already be on a list courtesy of add_session and set_state) + assert(session->item_session_list.is_on_list()); + if (by_state.count(session->state) == 0) + by_state[session->state] = new xlist; + by_state[session->state]->push_back(&session->item_session_list); + + session->last_cap_renew = ceph_clock_now(g_ceph_context); +} + diff --git a/src/mds/SessionMap.h b/src/mds/SessionMap.h index fefda91fdd22..9c395e190fe1 100644 --- a/src/mds/SessionMap.h +++ b/src/mds/SessionMap.h @@ -294,30 +294,10 @@ public: } return s; } - void add_session(Session *s) { - assert(session_map.count(s->info.inst.name) == 0); - session_map[s->info.inst.name] = s; - if (by_state.count(s->state) == 0) - by_state[s->state] = new xlist; - by_state[s->state]->push_back(&s->item_session_list); - s->get(); - } - void remove_session(Session *s) { - s->trim_completed_requests(0); - s->item_session_list.remove_myself(); - session_map.erase(s->info.inst.name); - s->put(); - } - void touch_session(Session *session) { - if (session->item_session_list.is_on_list()) { - if (by_state.count(session->state) == 0) - by_state[session->state] = new xlist; - by_state[session->state]->push_back(&session->item_session_list); - session->last_cap_renew = ceph_clock_now(g_ceph_context); - } else { - assert(0); // hrm, should happen? - } - } + void add_session(Session *s); + void remove_session(Session *s); + void touch_session(Session *session); + Session *get_oldest_session(int state) { if (by_state.count(state) == 0 || by_state[state]->empty()) return 0;