From: Patrick Donnelly Date: Mon, 10 Oct 2016 21:06:52 +0000 (-0400) Subject: mds: fully encapsulate filesystems map X-Git-Tag: v11.1.0~645^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de6c36af022da9599b04b59e5300fbb6a3de938f;p=ceph.git mds: fully encapsulate filesystems map Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/FSMap.h b/src/mds/FSMap.h index 854eeca767b1..94635bf25a13 100644 --- a/src/mds/FSMap.h +++ b/src/mds/FSMap.h @@ -380,21 +380,15 @@ public: }); } - const std::map > &get_filesystems() const - { - return filesystems; - } - bool any_filesystems() const {return !filesystems.empty(); } + size_t filesystem_count() const {return filesystems.size();} bool filesystem_exists(fs_cluster_id_t fscid) const {return filesystems.count(fscid) > 0;} epoch_t get_epoch() const { return epoch; } void inc_epoch() { epoch++; } - std::shared_ptr get_filesystem(fs_cluster_id_t fscid) const - { - return std::const_pointer_cast(filesystems.at(fscid)); - } + std::shared_ptr get_filesystem(fs_cluster_id_t fscid) const {return std::const_pointer_cast(filesystems.at(fscid));} + std::shared_ptr get_filesystem(void) const {return std::const_pointer_cast(filesystems.begin()->second);} int parse_filesystem( std::string const &ns_str, diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 39eb55f60b99..e5cd558b042f 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1627,7 +1627,7 @@ int MDSMonitor::management_command( } } - if (pending_fsmap.any_filesystems() + if (pending_fsmap.filesystem_count() > 0 && !pending_fsmap.get_enable_multiple()) { ss << "Creation of multiple filesystems is disabled. To enable " "this experimental feature, use 'ceph fs flag set enable_multiple " @@ -2906,8 +2906,7 @@ bool MDSMonitor::maybe_promote_standby(std::shared_ptr fs) // that doesn't correspond to an existing filesystem, especially // if we loaded from a version with a bug (#17466) if (info.standby_for_fscid != FS_CLUSTER_ID_NONE - && pending_fsmap.get_filesystems().count( - info.standby_for_fscid) == 0) { + && !pending_fsmap.filesystem_exists(info.standby_for_fscid)) { derr << "gid " << gid << " has invalid standby_for_fscid " << info.standby_for_fscid << dendl; continue; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 4a0c1ac3dfaf..493b57c84b35 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2478,7 +2478,7 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f) ss << " monmap " << *monmap << "\n"; ss << " election epoch " << get_epoch() << ", quorum " << get_quorum() << " " << get_quorum_names() << "\n"; - if (mdsmon()->fsmap.any_filesystems()) { + if (mdsmon()->fsmap.filesystem_count() > 0) { ss << " fsmap " << mdsmon()->fsmap << "\n"; } if (mgrmon()->in_use()) { diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index bbb8e366fccf..c7a843c076dd 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -172,8 +172,8 @@ int DataScan::main(const std::vector &args) // If caller didn't specify a namespace, try to pick // one if only one exists if (fscid == FS_CLUSTER_ID_NONE) { - if (fsmap->get_filesystems().size() == 1) { - fscid = fsmap->get_filesystems().begin()->first; + if (fsmap->filesystem_count() == 1) { + fscid = fsmap->get_filesystem()->fscid; } else { std::cerr << "Specify a filesystem with --filesystem" << std::endl; return -EINVAL; diff --git a/src/tools/cephfs/RoleSelector.cc b/src/tools/cephfs/RoleSelector.cc index d51f011a47de..3c7932a5eb9e 100644 --- a/src/tools/cephfs/RoleSelector.cc +++ b/src/tools/cephfs/RoleSelector.cc @@ -35,8 +35,8 @@ int MDSRoleSelector::parse(const FSMap &fsmap, std::string const &str) if (colon_pos == std::string::npos) { // An unqualified rank. Only valid if there is only one // namespace. - if (fsmap.get_filesystems().size() == 1) { - fscid = fsmap.get_filesystems().begin()->first; + if (fsmap.filesystem_count() == 1) { + fscid = fsmap.get_filesystem()->fscid; return parse_rank(fsmap, str); } else { return -EINVAL;