From: John Spray Date: Thu, 10 Mar 2016 10:57:38 +0000 (+0000) Subject: mds: make FSMap.get_filesystem return const X-Git-Tag: v10.1.0~144^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eb881010745c1697ee9c51ccce83ce67888d2fcd;p=ceph.git mds: make FSMap.get_filesystem return const To make it clearer that anyone modifying a filesystem should be using modify_filesystem() Note that FSMap is still a friend of MDSMonitor, as MDSMap was, so a larger refactor to provide the appropriate const accessors would also be nice in the future, but that's nothign to do with multi-filesystems. Signed-off-by: John Spray --- diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index ac067f3df4eb..214f7383adfc 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -374,7 +374,7 @@ void Filesystem::decode(bufferlist::iterator& p) int FSMap::parse_filesystem( std::string const &ns_str, - std::shared_ptr *result + std::shared_ptr *result ) const { std::string ns_err; @@ -382,7 +382,7 @@ int FSMap::parse_filesystem( if (!ns_err.empty() || filesystems.count(fscid) == 0) { for (auto fs : filesystems) { if (fs.second->mds_map.fs_name == ns_str) { - *result = fs.second; + *result = std::const_pointer_cast(fs.second); return 0; } } diff --git a/src/mds/FSMap.h b/src/mds/FSMap.h index f9320f049753..e14173f04baa 100644 --- a/src/mds/FSMap.h +++ b/src/mds/FSMap.h @@ -381,14 +381,14 @@ public: epoch_t get_epoch() const { return epoch; } void inc_epoch() { epoch++; } - std::shared_ptr get_filesystem(fs_cluster_id_t fscid) const + std::shared_ptr get_filesystem(fs_cluster_id_t fscid) const { - return filesystems.at(fscid); + return std::const_pointer_cast(filesystems.at(fscid)); } int parse_filesystem( std::string const &ns_str, - std::shared_ptr *result + std::shared_ptr *result ) const; int parse_role( diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index c0b38c79f8ec..314fe4ed9a15 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -482,10 +482,10 @@ public: return i->second.state; } - const mds_info_t& get_info(const mds_rank_t m) { + const mds_info_t& get_info(const mds_rank_t m) const { return mds_info.at(up.at(m)); } - const mds_info_t& get_info_gid(const mds_gid_t gid) { + const mds_info_t& get_info_gid(const mds_gid_t gid) const { return mds_info.at(gid); } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 8653b8c8ff45..a680be73c715 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -2235,10 +2235,13 @@ int MDSMonitor::filesystem_command( return -EINVAL; } - std::shared_ptr fs = pending_fsmap.get_filesystem(role.fscid); - assert(fs != nullptr); + pending_fsmap.modify_filesystem( + role.fscid, + [role](std::shared_ptr fs) + { + fs->mds_map.failed.erase(role.rank); + }); - fs->mds_map.failed.erase(role.rank); stringstream ss; ss << "removed failed mds." << role; return 0; @@ -2699,7 +2702,7 @@ void MDSMonitor::maybe_replace_gid(mds_gid_t gid, *osd_propose |= fail_mds_gid(gid); // Promote the replacement - const std::shared_ptr fs = pending_fsmap.get_filesystem(fscid); + auto fs = pending_fsmap.filesystems.at(fscid); pending_fsmap.promote(sgid, fs, info.rank); *mds_propose = true; diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index dc70ae6a6875..bf123a905fb4 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -90,7 +90,7 @@ bool DataScan::parse_kwarg( dout(10) << "Applying tag filter: '" << filter_tag << "'" << dendl; return true; } else if (arg == std::string("--filesystem")) { - std::shared_ptr fs; + std::shared_ptr fs; *r = fsmap->parse_filesystem(val, &fs); if (*r != 0) { std::cerr << "Invalid filesystem '" << val << "'" << std::endl; diff --git a/src/tools/cephfs/RoleSelector.cc b/src/tools/cephfs/RoleSelector.cc index b352c4cad9c2..d51f011a47de 100644 --- a/src/tools/cephfs/RoleSelector.cc +++ b/src/tools/cephfs/RoleSelector.cc @@ -46,7 +46,7 @@ int MDSRoleSelector::parse(const FSMap &fsmap, std::string const &str) } else { const std::string ns_str = str.substr(0, colon_pos); const std::string rank_str = str.substr(colon_pos + 1); - std::shared_ptr fs_ptr; + std::shared_ptr fs_ptr; int r = fsmap.parse_filesystem(ns_str, &fs_ptr); if (r != 0) { return r;