]>
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 | ||
11fdf7f2 | 18 | #include <string_view> |
94b18763 | 19 | |
7c673cae FG |
20 | #include "mdstypes.h" |
21 | #include "common/snap_types.h" | |
22 | ||
9f95a23c TL |
23 | #include "Capability.h" |
24 | ||
7c673cae FG |
25 | /* |
26 | * generic snap descriptor. | |
27 | */ | |
28 | struct SnapInfo { | |
9f95a23c TL |
29 | void encode(bufferlist &bl) const; |
30 | void decode(bufferlist::const_iterator &bl); | |
31 | void dump(Formatter *f) const; | |
32 | static void generate_test_instances(std::list<SnapInfo*>& ls); | |
33 | ||
34 | std::string_view get_long_name() const; | |
35 | ||
7c673cae FG |
36 | snapid_t snapid; |
37 | inodeno_t ino; | |
38 | utime_t stamp; | |
39 | string name; | |
40 | ||
11fdf7f2 | 41 | mutable string long_name; ///< cached _$ino_$name |
7c673cae FG |
42 | }; |
43 | WRITE_CLASS_ENCODER(SnapInfo) | |
44 | ||
11fdf7f2 TL |
45 | inline bool operator==(const SnapInfo &l, const SnapInfo &r) |
46 | { | |
47 | return l.snapid == r.snapid && l.ino == r.ino && | |
48 | l.stamp == r.stamp && l.name == r.name; | |
49 | } | |
50 | ||
7c673cae FG |
51 | ostream& operator<<(ostream& out, const SnapInfo &sn); |
52 | ||
7c673cae FG |
53 | /* |
54 | * SnapRealm - a subtree that shares the same set of snapshots. | |
55 | */ | |
56 | struct SnapRealm; | |
7c673cae FG |
57 | |
58 | struct snaplink_t { | |
7c673cae | 59 | void encode(bufferlist &bl) const; |
11fdf7f2 | 60 | void decode(bufferlist::const_iterator &bl); |
7c673cae | 61 | void dump(Formatter *f) const; |
9f95a23c TL |
62 | static void generate_test_instances(std::list<snaplink_t*>& ls); |
63 | ||
64 | inodeno_t ino; | |
65 | snapid_t first; | |
7c673cae FG |
66 | }; |
67 | WRITE_CLASS_ENCODER(snaplink_t) | |
68 | ||
69 | ostream& operator<<(ostream& out, const snaplink_t &l); | |
70 | ||
7c673cae FG |
71 | // carry data about a specific version of a SnapRealm |
72 | struct sr_t { | |
11fdf7f2 TL |
73 | void mark_parent_global() { flags |= PARENT_GLOBAL; } |
74 | void clear_parent_global() { flags &= ~PARENT_GLOBAL; } | |
75 | bool is_parent_global() const { return flags & PARENT_GLOBAL; } | |
7c673cae | 76 | |
7c673cae | 77 | void encode(bufferlist &bl) const; |
11fdf7f2 | 78 | void decode(bufferlist::const_iterator &bl); |
7c673cae | 79 | void dump(Formatter *f) const; |
9f95a23c TL |
80 | static void generate_test_instances(std::list<sr_t*>& ls); |
81 | ||
82 | snapid_t seq = 0; // basically, a version/seq # for changes to _this_ realm. | |
83 | snapid_t created = 0; // when this realm was created. | |
84 | snapid_t last_created = 0; // last snap created in _this_ realm. | |
85 | snapid_t last_destroyed = 0; // seq for last removal | |
86 | snapid_t current_parent_since = 1; | |
87 | map<snapid_t, SnapInfo> snaps; | |
88 | map<snapid_t, snaplink_t> past_parents; // key is "last" (or NOSNAP) | |
89 | set<snapid_t> past_parent_snaps; | |
90 | ||
91 | __u32 flags = 0; | |
92 | enum { | |
93 | PARENT_GLOBAL = 1 << 0, | |
94 | }; | |
7c673cae FG |
95 | }; |
96 | WRITE_CLASS_ENCODER(sr_t) | |
97 | ||
9f95a23c | 98 | class MDCache; |
7c673cae | 99 | #endif |