From 75c1c754d14ea300c7123995680a864212104b8c Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Tue, 18 May 2021 01:00:29 -0400 Subject: [PATCH] mds: remove 'fs_name' from MDSRank There isn't a need to store a file system's name in a MDSRank object. The MDSRank has a pointer to a MDSMap object, which already stores the name. Also, there isn't a need to pass the file system name in the MMDSMap message. It should be sufficient to pass the MDSMap in the MMDSMap message as the the file system name is stored in the MDSMap. Pass a empty string as map_fs_name in the MMDSMap message. It is simpler than removing map_fs_name from the message payload altogether. Fixes: https://tracker.ceph.com/issues/50852 Signed-off-by: Ramana Raja --- src/mds/MDSDaemon.cc | 2 +- src/mds/MDSRank.cc | 11 ++++------- src/mds/MDSRank.h | 4 ---- src/mds/Server.cc | 4 ++-- src/messages/MMDSMap.h | 9 +++++---- src/mon/MDSMonitor.cc | 3 +-- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 729902a878e..8b82385a2d2 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -759,7 +759,7 @@ void MDSDaemon::handle_mds_map(const cref_t &m) // Did I previously not hold a rank? Initialize! if (mds_rank == NULL) { - mds_rank = new MDSRankDispatcher(whoami, m->map_fs_name, mds_lock, clog, + mds_rank = new MDSRankDispatcher(whoami, mds_lock, clog, timer, beacon, mdsmap, messenger, monc, &mgrc, new LambdaContext([this](int r){respawn();}), new LambdaContext([this](int r){suicide();}), diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index f085e266979..2baa37698dc 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -476,7 +476,6 @@ private: MDSRank::MDSRank( mds_rank_t whoami_, - std::string fs_name_, ceph::mutex &mds_lock_, LogChannelRef &clog_, SafeTimer &timer_, @@ -494,7 +493,7 @@ MDSRank::MDSRank( damage_table(whoami_), sessionmap(this), op_tracker(g_ceph_context, g_conf()->mds_enable_op_tracker, g_conf()->osd_num_op_tracker_shard), - progress_thread(this), whoami(whoami_), fs_name(fs_name_), + progress_thread(this), whoami(whoami_), purge_queue(g_ceph_context, whoami_, mdsmap_->get_metadata_pool(), objecter, new LambdaContext([this](int r) { @@ -1429,8 +1428,7 @@ void MDSRank::send_message_mds(const ref_t& m, mds_rank_t mds) // send mdsmap first? auto addrs = mdsmap->get_addrs(mds); if (mds != whoami && peer_mdsmap_epoch[mds] < mdsmap->get_epoch()) { - auto _m = make_message(monc->get_fsid(), *mdsmap, - std::string(mdsmap->get_fs_name())); + auto _m = make_message(monc->get_fsid(), *mdsmap); send_message_mds(_m, addrs); peer_mdsmap_epoch[mds] = mdsmap->get_epoch(); } @@ -3219,7 +3217,7 @@ void MDSRank::command_dump_inode(Formatter *f, const cmdmap_t &cmdmap, std::ostr void MDSRank::dump_status(Formatter *f) const { - f->dump_string("fs_name", fs_name); + f->dump_string("fs_name", std::string(mdsmap->get_fs_name())); if (state == MDSMap::STATE_REPLAY || state == MDSMap::STATE_STANDBY_REPLAY) { mdlog->dump_replay_status(f); @@ -3611,7 +3609,6 @@ bool MDSRank::evict_client(int64_t session_id, MDSRankDispatcher::MDSRankDispatcher( mds_rank_t whoami_, - std::string fs_name_, ceph::mutex &mds_lock_, LogChannelRef &clog_, SafeTimer &timer_, @@ -3623,7 +3620,7 @@ MDSRankDispatcher::MDSRankDispatcher( Context *respawn_hook_, Context *suicide_hook_, boost::asio::io_context& ioc) - : MDSRank(whoami_, fs_name_, mds_lock_, clog_, timer_, beacon_, mdsmap_, + : MDSRank(whoami_, mds_lock_, clog_, timer_, beacon_, mdsmap_, msgr, monc_, mgrc, respawn_hook_, suicide_hook_, ioc) { g_conf().add_observer(this); diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index 7ec785c14ff..a67f6f1c6b9 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -164,7 +164,6 @@ class MDSRank { MDSRank( mds_rank_t whoami_, - std::string fs_name_, ceph::mutex &mds_lock_, LogChannelRef &clog_, SafeTimer &timer_, @@ -178,7 +177,6 @@ class MDSRank { boost::asio::io_context& ioc); mds_rank_t get_nodeid() const { return whoami; } - std::string_view get_fs_name() const { return fs_name; } int64_t get_metadata_pool() const { return metadata_pool; @@ -443,7 +441,6 @@ class MDSRank { friend class C_MDS_MonCommand; const mds_rank_t whoami; - std::string fs_name; ~MDSRank(); @@ -660,7 +657,6 @@ class MDSRankDispatcher : public MDSRank, public md_config_obs_t public: MDSRankDispatcher( mds_rank_t whoami_, - std::string fs_name, ceph::mutex &mds_lock_, LogChannelRef &clog_, SafeTimer &timer_, diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 63ebc303a04..605e1af1dd7 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -508,7 +508,7 @@ void Server::handle_client_reclaim(const cref_t &m) return; } - std::string_view fs_name = mds->get_fs_name(); + std::string_view fs_name = mds->mdsmap->get_fs_name(); if (!fs_name.empty() && !session->fs_name_capable(fs_name, MAY_READ)) { dout(0) << " dropping message not allowed for this fs_name: " << *m << dendl; return; @@ -542,7 +542,7 @@ void Server::handle_client_session(const cref_t &m) return; } - std::string_view fs_name = mds->get_fs_name(); + std::string_view fs_name = mds->mdsmap->get_fs_name(); if (!fs_name.empty() && !session->fs_name_capable(fs_name, MAY_READ)) { dout(0) << " dropping message not allowed for this fs_name: " << *m << dendl; auto reply = make_message(CEPH_SESSION_REJECT); diff --git a/src/messages/MMDSMap.h b/src/messages/MMDSMap.h index 9ea18131127..700cd2121bd 100644 --- a/src/messages/MMDSMap.h +++ b/src/messages/MMDSMap.h @@ -28,7 +28,9 @@ public: uuid_d fsid; epoch_t epoch = 0; ceph::buffer::list encoded; - std::string map_fs_name; + // don't really need map_fs_name. it was accidentally added in 51af2346fdf + // set it to empty string. + std::string map_fs_name = std::string(); version_t get_epoch() const { return epoch; } const ceph::buffer::list& get_encoded() const { return encoded; } @@ -37,10 +39,9 @@ protected: MMDSMap() : SafeMessage{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION} {} - MMDSMap(const uuid_d &f, const MDSMap &mm, - const std::string mf = std::string()) : + MMDSMap(const uuid_d &f, const MDSMap &mm) : SafeMessage{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION}, - fsid(f), map_fs_name(mf) { + fsid(f) { epoch = mm.get_epoch(); mm.encode(encoded, -1); // we will reencode with fewer features as necessary } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 4af783ba93f..82b6843264c 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1808,8 +1808,7 @@ void MDSMonitor::check_sub(Subscription *sub) if (sub->next > mds_map->epoch) { return; } - auto msg = make_message(mon.monmap->fsid, *mds_map, - mds_map->fs_name); + auto msg = make_message(mon.monmap->fsid, *mds_map); sub->session->con->send_message(msg.detach()); if (sub->onetime) { -- 2.39.5