]>
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 | #ifndef CEPH_CLIENT_SNAPREALM_H | |
5 | #define CEPH_CLIENT_SNAPREALM_H | |
6 | ||
7 | #include "include/types.h" | |
8 | #include "common/snap_types.h" | |
9 | #include "include/xlist.h" | |
10 | ||
11 | struct Inode; | |
12 | ||
13 | struct SnapRealm { | |
14 | inodeno_t ino; | |
15 | int nref; | |
16 | snapid_t created; | |
17 | snapid_t seq; | |
18 | ||
19 | inodeno_t parent; | |
20 | snapid_t parent_since; | |
20effc67 TL |
21 | std::vector<snapid_t> prior_parent_snaps; // snaps prior to parent_since |
22 | std::vector<snapid_t> my_snaps; | |
7c673cae FG |
23 | |
24 | SnapRealm *pparent; | |
20effc67 | 25 | std::set<SnapRealm*> pchildren; |
7c673cae FG |
26 | |
27 | private: | |
28 | SnapContext cached_snap_context; // my_snaps + parent snaps + past_parent_snaps | |
20effc67 | 29 | friend std::ostream& operator<<(std::ostream& out, const SnapRealm& r); |
7c673cae FG |
30 | |
31 | public: | |
32 | xlist<Inode*> inodes_with_caps; | |
33 | ||
34 | explicit SnapRealm(inodeno_t i) : | |
35 | ino(i), nref(0), created(0), seq(0), | |
36 | pparent(NULL) { } | |
37 | ||
38 | void build_snap_context(); | |
39 | void invalidate_cache() { | |
40 | cached_snap_context.clear(); | |
41 | } | |
42 | ||
43 | const SnapContext& get_snap_context() { | |
44 | if (cached_snap_context.seq == 0) | |
45 | build_snap_context(); | |
46 | return cached_snap_context; | |
47 | } | |
48 | ||
49 | void dump(Formatter *f) const; | |
50 | }; | |
51 | ||
20effc67 | 52 | inline std::ostream& operator<<(std::ostream& out, const SnapRealm& r) { |
7c673cae FG |
53 | return out << "snaprealm(" << r.ino << " nref=" << r.nref << " c=" << r.created << " seq=" << r.seq |
54 | << " parent=" << r.parent | |
55 | << " my_snaps=" << r.my_snaps | |
56 | << " cached_snapc=" << r.cached_snap_context | |
57 | << ")"; | |
58 | } | |
59 | ||
60 | #endif |