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