From: Venky Shankar Date: Thu, 17 Sep 2020 04:27:12 +0000 (-0400) Subject: cephfs-mirror: introduce Filesystem type X-Git-Tag: v16.1.0~786^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=894e28c9cbc803d666d82d90e572ed8b41d0eb66;p=ceph.git cephfs-mirror: introduce Filesystem type Signed-off-by: Venky Shankar --- diff --git a/src/tools/cephfs_mirror/Types.cc b/src/tools/cephfs_mirror/Types.cc index 1d2e2d1e5925..0049f9d79f78 100644 --- a/src/tools/cephfs_mirror/Types.cc +++ b/src/tools/cephfs_mirror/Types.cc @@ -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; } diff --git a/src/tools/cephfs_mirror/Types.h b/src/tools/cephfs_mirror/Types.h index cf05891db6a6..64dad1a9e5a1 100644 --- a/src/tools/cephfs_mirror/Types.h +++ b/src/tools/cephfs_mirror/Types.h @@ -9,37 +9,66 @@ #include #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 RadosRef;