]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef CEPH_MDS_SNAP_H | |
16 | #define CEPH_MDS_SNAP_H | |
17 | ||
f67539c2 | 18 | #include <map> |
11fdf7f2 | 19 | #include <string_view> |
94b18763 | 20 | |
7c673cae FG |
21 | #include "mdstypes.h" |
22 | #include "common/snap_types.h" | |
23 | ||
9f95a23c TL |
24 | #include "Capability.h" |
25 | ||
7c673cae FG |
26 | /* |
27 | * generic snap descriptor. | |
28 | */ | |
29 | struct SnapInfo { | |
f67539c2 TL |
30 | void encode(ceph::buffer::list &bl) const; |
31 | void decode(ceph::buffer::list::const_iterator &bl); | |
32 | void dump(ceph::Formatter *f) const; | |
9f95a23c TL |
33 | static void generate_test_instances(std::list<SnapInfo*>& ls); |
34 | ||
35 | std::string_view get_long_name() const; | |
36 | ||
7c673cae FG |
37 | snapid_t snapid; |
38 | inodeno_t ino; | |
39 | utime_t stamp; | |
f67539c2 | 40 | std::string name; |
7c673cae | 41 | |
f67539c2 TL |
42 | mutable std::string long_name; ///< cached _$ino_$name |
43 | std::map<std::string,std::string> metadata; | |
7c673cae FG |
44 | }; |
45 | WRITE_CLASS_ENCODER(SnapInfo) | |
46 | ||
11fdf7f2 TL |
47 | inline bool operator==(const SnapInfo &l, const SnapInfo &r) |
48 | { | |
49 | return l.snapid == r.snapid && l.ino == r.ino && | |
50 | l.stamp == r.stamp && l.name == r.name; | |
51 | } | |
52 | ||
f67539c2 | 53 | std::ostream& operator<<(std::ostream& out, const SnapInfo &sn); |
7c673cae | 54 | |
7c673cae FG |
55 | /* |
56 | * SnapRealm - a subtree that shares the same set of snapshots. | |
57 | */ | |
58 | struct SnapRealm; | |
7c673cae FG |
59 | |
60 | struct snaplink_t { | |
f67539c2 TL |
61 | void encode(ceph::buffer::list &bl) const; |
62 | void decode(ceph::buffer::list::const_iterator &bl); | |
63 | void dump(ceph::Formatter *f) const; | |
9f95a23c TL |
64 | static void generate_test_instances(std::list<snaplink_t*>& ls); |
65 | ||
66 | inodeno_t ino; | |
67 | snapid_t first; | |
7c673cae FG |
68 | }; |
69 | WRITE_CLASS_ENCODER(snaplink_t) | |
70 | ||
f67539c2 | 71 | std::ostream& operator<<(std::ostream& out, const snaplink_t &l); |
7c673cae | 72 | |
7c673cae FG |
73 | // carry data about a specific version of a SnapRealm |
74 | struct sr_t { | |
11fdf7f2 TL |
75 | void mark_parent_global() { flags |= PARENT_GLOBAL; } |
76 | void clear_parent_global() { flags &= ~PARENT_GLOBAL; } | |
77 | bool is_parent_global() const { return flags & PARENT_GLOBAL; } | |
7c673cae | 78 | |
adb31ebb TL |
79 | void mark_subvolume() { flags |= SUBVOLUME; } |
80 | void clear_subvolume() { flags &= ~SUBVOLUME; } | |
81 | bool is_subvolume() const { return flags & SUBVOLUME; } | |
82 | ||
f67539c2 TL |
83 | void encode(ceph::buffer::list &bl) const; |
84 | void decode(ceph::buffer::list::const_iterator &bl); | |
85 | void dump(ceph::Formatter *f) const; | |
9f95a23c TL |
86 | static void generate_test_instances(std::list<sr_t*>& ls); |
87 | ||
88 | snapid_t seq = 0; // basically, a version/seq # for changes to _this_ realm. | |
89 | snapid_t created = 0; // when this realm was created. | |
90 | snapid_t last_created = 0; // last snap created in _this_ realm. | |
91 | snapid_t last_destroyed = 0; // seq for last removal | |
92 | snapid_t current_parent_since = 1; | |
f67539c2 TL |
93 | std::map<snapid_t, SnapInfo> snaps; |
94 | std::map<snapid_t, snaplink_t> past_parents; // key is "last" (or NOSNAP) | |
95 | std::set<snapid_t> past_parent_snaps; | |
1e59de90 TL |
96 | utime_t last_modified; // timestamp when this realm |
97 | // was last changed. | |
98 | uint64_t change_attr = 0; // tracks changes to snap | |
99 | // realm attrs. | |
9f95a23c TL |
100 | |
101 | __u32 flags = 0; | |
102 | enum { | |
adb31ebb TL |
103 | PARENT_GLOBAL = 1 << 0, |
104 | SUBVOLUME = 1 << 1, | |
9f95a23c | 105 | }; |
7c673cae FG |
106 | }; |
107 | WRITE_CLASS_ENCODER(sr_t) | |
108 | ||
9f95a23c | 109 | class MDCache; |
7c673cae | 110 | #endif |