]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: make FSMap.get_filesystem return const
authorJohn Spray <john.spray@redhat.com>
Thu, 10 Mar 2016 10:57:38 +0000 (10:57 +0000)
committerJohn Spray <john.spray@redhat.com>
Thu, 10 Mar 2016 12:11:23 +0000 (12:11 +0000)
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 <john.spray@redhat.com>
src/mds/FSMap.cc
src/mds/FSMap.h
src/mds/MDSMap.h
src/mon/MDSMonitor.cc
src/tools/cephfs/DataScan.cc
src/tools/cephfs/RoleSelector.cc

index ac067f3df4eba7308f5840adf4ee5fb2417bafef..214f7383adfc650f1710604147d1e50b6987a618 100644 (file)
@@ -374,7 +374,7 @@ void Filesystem::decode(bufferlist::iterator& p)
 
 int FSMap::parse_filesystem(
       std::string const &ns_str,
-      std::shared_ptr<Filesystem> *result
+      std::shared_ptr<const Filesystem> *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<const Filesystem>(fs.second);
         return 0;
       }
     }
index f9320f04975372401980b0e705422621c3367571..e14173f04baa0f4976893386536e079022c60b14 100644 (file)
@@ -381,14 +381,14 @@ public:
   epoch_t get_epoch() const { return epoch; }
   void inc_epoch() { epoch++; }
 
-  std::shared_ptr<Filesystem> get_filesystem(fs_cluster_id_t fscid) const
+  std::shared_ptr<const Filesystem> get_filesystem(fs_cluster_id_t fscid) const
   {
-    return filesystems.at(fscid);
+    return std::const_pointer_cast<const Filesystem>(filesystems.at(fscid));
   }
 
   int parse_filesystem(
       std::string const &ns_str,
-      std::shared_ptr<Filesystem> *result
+      std::shared_ptr<const Filesystem> *result
       ) const;
 
   int parse_role(
index c0b38c79f8ec7e0067fce3abb46ee96e05bdd8fc..314fe4ed9a15c801d69520db87ababebfaaeda61 100644 (file)
@@ -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);
   }
 
index 8653b8c8ff45c737b99c55857b3109910a80cd56..a680be73c71550f61dd0d1198f44ec482a6fe2bc 100644 (file)
@@ -2235,10 +2235,13 @@ int MDSMonitor::filesystem_command(
       return -EINVAL;
     }
 
-    std::shared_ptr<Filesystem> fs = pending_fsmap.get_filesystem(role.fscid);
-    assert(fs != nullptr);
+    pending_fsmap.modify_filesystem(
+        role.fscid,
+        [role](std::shared_ptr<Filesystem> 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<Filesystem> fs = pending_fsmap.get_filesystem(fscid);
+    auto fs = pending_fsmap.filesystems.at(fscid);
     pending_fsmap.promote(sgid, fs, info.rank);
 
     *mds_propose = true;
index dc70ae6a68751124fb3db6ceaef015a5e8ecc2d8..bf123a905fb472db83bd994ddd471bd575dc8e7d 100644 (file)
@@ -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<Filesystem> fs;
+    std::shared_ptr<const Filesystem> fs;
     *r = fsmap->parse_filesystem(val, &fs);
     if (*r != 0) {
       std::cerr << "Invalid filesystem '" << val << "'" << std::endl;
index b352c4cad9c2bdbb2f8f003034b887ec14f8b893..d51f011a47de1442f0d091ace4b1f7fc7ed28976 100644 (file)
@@ -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<Filesystem> fs_ptr;
+    std::shared_ptr<const Filesystem> fs_ptr;
     int r = fsmap.parse_filesystem(ns_str, &fs_ptr);
     if (r != 0) {
       return r;