]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fully encapsulate filesystems map
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 10 Oct 2016 21:06:52 +0000 (17:06 -0400)
committerLoic Dachary <ldachary@redhat.com>
Wed, 9 Nov 2016 14:14:49 +0000 (15:14 +0100)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit de6c36af022da9599b04b59e5300fbb6a3de938f)

src/mds/FSMap.h
src/mon/MDSMonitor.cc
src/mon/Monitor.cc
src/tools/cephfs/DataScan.cc
src/tools/cephfs/RoleSelector.cc

index d14e365a652a8406f131702673b06442266dc7c6..46614f69809bd15498f83277410f82f2d63bb34d 100644 (file)
@@ -375,21 +375,15 @@ public:
     });
   }
 
-  const std::map<fs_cluster_id_t, std::shared_ptr<Filesystem> > &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<const Filesystem> get_filesystem(fs_cluster_id_t fscid) const
-  {
-    return std::const_pointer_cast<const Filesystem>(filesystems.at(fscid));
-  }
+  std::shared_ptr<const Filesystem> get_filesystem(fs_cluster_id_t fscid) const {return std::const_pointer_cast<const Filesystem>(filesystems.at(fscid));}
+  std::shared_ptr<const Filesystem> get_filesystem(void) const {return std::const_pointer_cast<const Filesystem>(filesystems.begin()->second);}
 
   int parse_filesystem(
       std::string const &ns_str,
index b91e360e0f6d7a566f1bc5d8ad7943996f26ef6f..fc9c1d09b0853185e0c576523ef84e3cd098e0c4 100644 (file)
@@ -1555,7 +1555,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 "
@@ -2819,8 +2819,7 @@ bool MDSMonitor::maybe_promote_standby(std::shared_ptr<Filesystem> 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;
index 404735149809e6f123f3c7e87fd426940168a4b4..a90949fd0cce87c1cf922a3cffd8b26e93977375 100644 (file)
@@ -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";
     }
 
index bb0584a365da3a7e14acdb04ff70ea0d93cd6c26..7dc60194ed48c881231d2179a97d1a0e3d71f1aa 100644 (file)
@@ -212,8 +212,8 @@ int DataScan::main(const std::vector<const char*> &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;
index d51f011a47de1442f0d091ace4b1f7fc7ed28976..3c7932a5eb9e6fa50f1b97d39411ed2cb3be182d 100644 (file)
@@ -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;