]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-mirror: introduce Filesystem type
authorVenky Shankar <vshankar@redhat.com>
Thu, 17 Sep 2020 04:27:12 +0000 (00:27 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 24 Sep 2020 12:18:11 +0000 (08:18 -0400)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/tools/cephfs_mirror/Types.cc
src/tools/cephfs_mirror/Types.h

index 1d2e2d1e5925923812107433542f51332c97fd4f..0049f9d79f787f0f787bc53adc1721fd37cf3241 100644 (file)
@@ -6,8 +6,13 @@
 namespace cephfs {
 namespace mirror {
 
+std::ostream& operator<<(std::ostream& out, const Filesystem &filesystem) {
+  out << "{fscid=" << filesystem.fscid << ", fs_name=" << filesystem.fs_name << "}";
+  return out;
+}
+
 std::ostream& operator<<(std::ostream& out, const FilesystemSpec &spec) {
-  out << "{fs_name=" << spec.fs_name << ", pool_id=" << spec.pool_id << "}";
+  out << "{filesystem=" << spec.filesystem << ", pool_id=" << spec.pool_id << "}";
   return out;
 }
 
index cf05891db6a6c2df8a3275534bbffc2d90636806..64dad1a9e5a10af927e6fc81a3862f3dfca5f1fd 100644 (file)
@@ -9,37 +9,66 @@
 #include <string_view>
 
 #include "include/rados/librados.hpp"
+#include "mds/mdstypes.h"
 
 namespace cephfs {
 namespace mirror {
 
 static const std::string CEPHFS_MIRROR_OBJECT("cephfs_mirror");
 
+// distinct filesystem identifier
+struct Filesystem {
+  fs_cluster_id_t fscid;
+  std::string fs_name;
+
+  bool operator==(const Filesystem &rhs) const {
+    return (fscid == rhs.fscid &&
+            fs_name == rhs.fs_name);
+  }
+
+  bool operator!=(const Filesystem &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator<(const Filesystem &rhs) const {
+    if (fscid != rhs.fscid) {
+      return fscid < rhs.fscid;
+    }
+
+    return fs_name < rhs.fs_name;
+  }
+};
+
 // specification of a filesystem -- pool id the metadata pool id.
 struct FilesystemSpec {
   FilesystemSpec() = default;
-  FilesystemSpec(std::string_view fs_name, uint64_t pool_id)
-    : fs_name(fs_name),
+  FilesystemSpec(const Filesystem &filesystem, uint64_t pool_id)
+    : filesystem(filesystem),
+      pool_id(pool_id) {
+  }
+  FilesystemSpec(fs_cluster_id_t fscid, std::string_view fs_name, uint64_t pool_id)
+    : filesystem(Filesystem{fscid, std::string(fs_name)}),
       pool_id(pool_id) {
   }
 
-  std::string fs_name;
+  Filesystem filesystem;
   uint64_t pool_id;
 
   bool operator==(const FilesystemSpec &rhs) const {
-    return (fs_name == rhs.fs_name &&
+    return (filesystem == rhs.filesystem &&
             pool_id == rhs.pool_id);
   }
 
   bool operator<(const FilesystemSpec &rhs) const {
-    if (fs_name != rhs.fs_name) {
-      return fs_name < rhs.fs_name;
+    if (filesystem != rhs.filesystem) {
+      return filesystem < rhs.filesystem;
     }
 
     return pool_id < rhs.pool_id;
   }
 };
 
+std::ostream& operator<<(std::ostream& out, const Filesystem &filesystem);
 std::ostream& operator<<(std::ostream& out, const FilesystemSpec &spec);
 
 typedef std::shared_ptr<librados::Rados> RadosRef;