From 1b606639e16776599945605e42fcdce845067317 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Oct 2019 07:31:33 -0500 Subject: [PATCH] mds: get rid of unused send_command_reply helpers Signed-off-by: Sage Weil --- src/mds/MDSDaemon.cc | 49 +++++++++++++++++--------------------------- src/mds/MDSDaemon.h | 2 -- src/mds/MDSRank.cc | 23 --------------------- src/mds/MDSRank.h | 1 - 4 files changed, 19 insertions(+), 56 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index a2b519cdb67..16722b584a4 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -579,35 +579,6 @@ void MDSDaemon::tick() } } -void MDSDaemon::send_command_reply(const cref_t &m, MDSRank *mds_rank, - int r, bufferlist outbl, - std::string_view outs) -{ - auto priv = m->get_connection()->get_priv(); - auto session = static_cast(priv.get()); - ceph_assert(session != NULL); - // If someone is using a closed session for sending commands (e.g. - // the ceph CLI) then we should feel free to clean up this connection - // as soon as we've sent them a response. - const bool live_session = - session->get_state_seq() > 0 && - mds_rank && - mds_rank->sessionmap.get_session(session->info.inst.name); - - if (!live_session) { - // This session only existed to issue commands, so terminate it - // as soon as we can. - ceph_assert(session->is_closed()); - session->get_connection()->mark_disposable(); - } - priv.reset(); - - auto reply = make_message(r, outs); - reply->set_tid(m->get_tid()); - reply->set_data(outbl); - m->get_connection()->send_message2(reply); -} - void MDSDaemon::handle_command(const cref_t &m) { auto priv = m->get_connection()->get_priv(); @@ -638,9 +609,27 @@ void MDSDaemon::handle_command(const cref_t &m) cct->get_admin_socket()->queue_tell_command(m); return; } + + // If someone is using a closed session for sending commands (e.g. + // the ceph CLI) then we should feel free to clean up this connection + // as soon as we've sent them a response. + const bool live_session = + session->get_state_seq() > 0 && + mds_rank && + mds_rank->sessionmap.get_session(session->info.inst.name); + + if (!live_session) { + // This session only existed to issue commands, so terminate it + // as soon as we can. + ceph_assert(session->is_closed()); + session->get_connection()->mark_disposable(); + } priv.reset(); - send_command_reply(m, mds_rank, r, outbl, outs); + auto reply = make_message(r, outs); + reply->set_tid(m->get_tid()); + reply->set_data(outbl); + m->get_connection()->send_message2(reply); } const std::vector& MDSDaemon::get_commands() diff --git a/src/mds/MDSDaemon.h b/src/mds/MDSDaemon.h index b511e9f1698..265a82f6515 100644 --- a/src/mds/MDSDaemon.h +++ b/src/mds/MDSDaemon.h @@ -120,8 +120,6 @@ class MDSDaemon : public Dispatcher { bool handle_core_message(const cref_t &m); - static void send_command_reply(const cref_t &m, MDSRank* mds_rank, int r, - bufferlist outbl, std::string_view outs); void handle_command(const cref_t &m); void handle_mds_map(const cref_t &m); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 6a311120db4..ad8fccfd455 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -2683,29 +2683,6 @@ out: on_finish(r, ss.str(), outbl); } -class C_MDS_Send_Command_Reply : public MDSInternalContext { -protected: - cref_t m; -public: - C_MDS_Send_Command_Reply(MDSRank *_mds, const cref_t &_m) : - MDSInternalContext(_mds), m(_m) {} - - void send(int r, std::string_view ss) { - std::stringstream ds; - send(r, ss, ds); - } - - void send(int r, std::string_view ss, std::stringstream &ds) { - bufferlist bl; - bl.append(ds); - MDSDaemon::send_command_reply(m, mds, r, bl, ss); - } - - void finish(int r) override { - send(r, ""); - } -}; - /** * This function drops the mds_lock, so don't do anything with * MDSRank after calling it (we could have gone into shutdown): just diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index ea89c1102cc..d9bd1dbe5b3 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -122,7 +122,6 @@ class MonClient; class MgrClient; class Finisher; class ScrubStack; -class C_MDS_Send_Command_Reply; class C_ExecAndReply; /** -- 2.39.5