]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef __CEPH_SNAP_TYPES_H |
2 | #define __CEPH_SNAP_TYPES_H | |
3 | ||
4 | #include "include/types.h" | |
5 | #include "include/fs_types.h" | |
6 | ||
7 | namespace ceph { | |
7c673cae FG |
8 | class Formatter; |
9 | } | |
9f95a23c | 10 | |
7c673cae FG |
11 | struct SnapRealmInfo { |
12 | mutable ceph_mds_snap_realm h; | |
9f95a23c TL |
13 | std::vector<snapid_t> my_snaps; |
14 | std::vector<snapid_t> prior_parent_snaps; // before parent_since | |
7c673cae FG |
15 | |
16 | SnapRealmInfo() { | |
92f5a8d4 | 17 | // FIPS zeroization audit 20191115: this memset is not security related. |
7c673cae FG |
18 | memset(&h, 0, sizeof(h)); |
19 | } | |
20 | SnapRealmInfo(inodeno_t ino_, snapid_t created_, snapid_t seq_, snapid_t current_parent_since_) { | |
92f5a8d4 | 21 | // FIPS zeroization audit 20191115: this memset is not security related. |
7c673cae FG |
22 | memset(&h, 0, sizeof(h)); |
23 | h.ino = ino_; | |
24 | h.created = created_; | |
25 | h.seq = seq_; | |
26 | h.parent_since = current_parent_since_; | |
27 | } | |
28 | ||
29 | inodeno_t ino() const { return inodeno_t(h.ino); } | |
30 | inodeno_t parent() const { return inodeno_t(h.parent); } | |
31 | snapid_t seq() const { return snapid_t(h.seq); } | |
32 | snapid_t parent_since() const { return snapid_t(h.parent_since); } | |
33 | snapid_t created() const { return snapid_t(h.created); } | |
34 | ||
9f95a23c TL |
35 | void encode(ceph::buffer::list& bl) const; |
36 | void decode(ceph::buffer::list::const_iterator& bl); | |
37 | void dump(ceph::Formatter *f) const; | |
38 | static void generate_test_instances(std::list<SnapRealmInfo*>& o); | |
7c673cae FG |
39 | }; |
40 | WRITE_CLASS_ENCODER(SnapRealmInfo) | |
41 | ||
42 | ||
43 | struct SnapContext { | |
44 | snapid_t seq; // 'time' stamp | |
9f95a23c | 45 | std::vector<snapid_t> snaps; // existent snaps, in descending order |
7c673cae FG |
46 | |
47 | SnapContext() {} | |
9f95a23c | 48 | SnapContext(snapid_t s, const std::vector<snapid_t>& v) : seq(s), snaps(v) {} |
7c673cae FG |
49 | |
50 | bool is_valid() const; | |
51 | ||
52 | void clear() { | |
53 | seq = 0; | |
54 | snaps.clear(); | |
55 | } | |
f67539c2 | 56 | bool empty() const { return seq == 0; } |
7c673cae | 57 | |
9f95a23c | 58 | void encode(ceph::buffer::list& bl) const { |
11fdf7f2 TL |
59 | using ceph::encode; |
60 | encode(seq, bl); | |
61 | encode(snaps, bl); | |
7c673cae | 62 | } |
9f95a23c | 63 | void decode(ceph::buffer::list::const_iterator& bl) { |
11fdf7f2 TL |
64 | using ceph::decode; |
65 | decode(seq, bl); | |
66 | decode(snaps, bl); | |
7c673cae | 67 | } |
9f95a23c TL |
68 | void dump(ceph::Formatter *f) const; |
69 | static void generate_test_instances(std::list<SnapContext*>& o); | |
7c673cae FG |
70 | }; |
71 | WRITE_CLASS_ENCODER(SnapContext) | |
72 | ||
9f95a23c | 73 | inline std::ostream& operator<<(std::ostream& out, const SnapContext& snapc) { |
7c673cae FG |
74 | return out << snapc.seq << "=" << snapc.snaps; |
75 | } | |
76 | ||
77 | //} | |
78 | ||
79 | #endif |