]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/cephfs_mirror/Types.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / tools / cephfs_mirror / Types.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPHFS_MIRROR_TYPES_H
5 #define CEPHFS_MIRROR_TYPES_H
6
7 #include <set>
8 #include <iostream>
9 #include <string_view>
10
11 #include "include/rados/librados.hpp"
12 #include "include/cephfs/libcephfs.h"
13 #include "mds/mdstypes.h"
14
15 namespace cephfs {
16 namespace mirror {
17
18 static const std::string CEPHFS_MIRROR_OBJECT("cephfs_mirror");
19
20 typedef boost::variant<bool, uint64_t, std::string> AttributeValue;
21 typedef std::map<std::string, AttributeValue> Attributes;
22
23 // distinct filesystem identifier
24 struct Filesystem {
25 fs_cluster_id_t fscid;
26 std::string fs_name;
27
28 bool operator==(const Filesystem &rhs) const {
29 return (fscid == rhs.fscid &&
30 fs_name == rhs.fs_name);
31 }
32
33 bool operator!=(const Filesystem &rhs) const {
34 return !(*this == rhs);
35 }
36
37 bool operator<(const Filesystem &rhs) const {
38 if (fscid != rhs.fscid) {
39 return fscid < rhs.fscid;
40 }
41
42 return fs_name < rhs.fs_name;
43 }
44 };
45
46 // specification of a filesystem -- pool id the metadata pool id.
47 struct FilesystemSpec {
48 FilesystemSpec() = default;
49 FilesystemSpec(const Filesystem &filesystem, uint64_t pool_id)
50 : filesystem(filesystem),
51 pool_id(pool_id) {
52 }
53 FilesystemSpec(fs_cluster_id_t fscid, std::string_view fs_name, uint64_t pool_id)
54 : filesystem(Filesystem{fscid, std::string(fs_name)}),
55 pool_id(pool_id) {
56 }
57
58 Filesystem filesystem;
59 uint64_t pool_id;
60
61 bool operator==(const FilesystemSpec &rhs) const {
62 return (filesystem == rhs.filesystem &&
63 pool_id == rhs.pool_id);
64 }
65
66 bool operator<(const FilesystemSpec &rhs) const {
67 if (filesystem != rhs.filesystem) {
68 return filesystem < rhs.filesystem;
69 }
70
71 return pool_id < rhs.pool_id;
72 }
73 };
74
75 std::ostream& operator<<(std::ostream& out, const Filesystem &filesystem);
76 std::ostream& operator<<(std::ostream& out, const FilesystemSpec &spec);
77
78 typedef std::shared_ptr<librados::Rados> RadosRef;
79 typedef std::shared_ptr<librados::IoCtx> IoCtxRef;
80
81 // not a shared_ptr since the type is incomplete
82 typedef ceph_mount_info *MountRef;
83
84 } // namespace mirror
85 } // namespace cephfs
86
87 #endif // CEPHFS_MIRROR_TYPES_H