From 4af1764667c70709da574ec6fcd36cddcc436101 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 2 Oct 2015 11:13:52 +0100 Subject: [PATCH] mds: add auth_name to session_info_t Record the name of the entity who's authorisation credentials were used during connection. This allows us to refer to it later when listing or evicting sessions, for the user's benefit. Signed-off-by: John Spray --- src/mds/MDSDaemon.cc | 1 + src/mds/mdstypes.cc | 8 ++++++-- src/mds/mdstypes.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 37869be782c1..9746559a9ecd 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -1255,6 +1255,7 @@ bool MDSDaemon::ms_verify_authorizer(Connection *con, int peer_type, // request to open a session (initial state of Session is `closed`) if (!s) { s = new Session; + s->info.auth_name = name; s->info.inst.addr = con->get_peer_addr(); s->info.inst.name = n; dout(10) << " new session " << s << " for " << s->info.inst << " con " << con << dendl; diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 3e3400ba7b33..77846c3cdae5 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -671,19 +671,20 @@ void old_rstat_t::generate_test_instances(list& ls) */ void session_info_t::encode(bufferlist& bl) const { - ENCODE_START(5, 3, bl); + ENCODE_START(6, 3, bl); ::encode(inst, bl); ::encode(completed_requests, bl); ::encode(prealloc_inos, bl); // hacky, see below. ::encode(used_inos, bl); ::encode(client_metadata, bl); ::encode(completed_flushes, bl); + ::encode(auth_name, bl); ENCODE_FINISH(bl); } void session_info_t::decode(bufferlist::iterator& p) { - DECODE_START_LEGACY_COMPAT_LEN(4, 2, 2, p); + DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, p); ::decode(inst, p); if (struct_v <= 2) { set s; @@ -705,6 +706,9 @@ void session_info_t::decode(bufferlist::iterator& p) if (struct_v >= 5) { ::decode(completed_flushes, p); } + if (struct_v >= 6) { + ::decode(auth_name, p); + } DECODE_FINISH(p); } diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 929d36207238..33bd67140010 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -13,6 +13,7 @@ #include "common/config.h" #include "common/Clock.h" #include "common/DecayCounter.h" +#include "common/entity_name.h" #include "MDSContext.h" #include "include/frag.h" @@ -645,6 +646,7 @@ struct session_info_t { interval_set used_inos; // journaling use std::map client_metadata; std::set completed_flushes; + EntityName auth_name; client_t get_client() const { return client_t(inst.name.num()); } -- 2.47.3