]> git-server-git.apps.pok.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)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 11 Oct 2016 18:24:46 +0000 (14:24 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/FSMap.h
src/mon/MDSMonitor.cc
src/mon/Monitor.cc
src/tools/cephfs/DataScan.cc
src/tools/cephfs/RoleSelector.cc

index 854eeca767b16c0cf4e60d2c83904923deaca833..94635bf25a135836007bd724218b3b301058d120 100644 (file)
@@ -380,21 +380,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 39eb55f60b995aa2e6ad9090d8cf169019db3038..e5cd558b042f39db7810ba88e8221d5e26d0f24a 100644 (file)
@@ -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<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 4a0c1ac3dfaf31af9da59e7fd122193a9b3e3596..493b57c84b35cba456c4c4e9396c619938a6968c 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";
     }
     if (mgrmon()->in_use()) {
index bbb8e366fccf7de15a5baebdcac5335bca710f82..c7a843c076ddc5be8d690a352d0247060530b92f 100644 (file)
@@ -172,8 +172,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;