Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / client / ClientSnapRealm.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 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;
21   vector<snapid_t> prior_parent_snaps;  // snaps prior to parent_since
22   vector<snapid_t> my_snaps;
23
24   SnapRealm *pparent;
25   set<SnapRealm*> pchildren;
26
27 private:
28   SnapContext cached_snap_context;  // my_snaps + parent snaps + past_parent_snaps
29   friend ostream& operator<<(ostream& out, const SnapRealm& r);
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
52 inline ostream& operator<<(ostream& out, const SnapRealm& r) {
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