]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/snap.h
9ebadb1255bb380d0810c3bbf47b91dc135521ef
[ceph.git] / 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 <string_view>
19
20 #include "mdstypes.h"
21 #include "common/snap_types.h"
22
23 #include "Capability.h"
24
25 /*
26 * generic snap descriptor.
27 */
28 struct SnapInfo {
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
36 snapid_t snapid;
37 inodeno_t ino;
38 utime_t stamp;
39 string name;
40
41 mutable string long_name; ///< cached _$ino_$name
42 };
43 WRITE_CLASS_ENCODER(SnapInfo)
44
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
51 ostream& operator<<(ostream& out, const SnapInfo &sn);
52
53 /*
54 * SnapRealm - a subtree that shares the same set of snapshots.
55 */
56 struct SnapRealm;
57
58 struct snaplink_t {
59 void encode(bufferlist &bl) const;
60 void decode(bufferlist::const_iterator &bl);
61 void dump(Formatter *f) const;
62 static void generate_test_instances(std::list<snaplink_t*>& ls);
63
64 inodeno_t ino;
65 snapid_t first;
66 };
67 WRITE_CLASS_ENCODER(snaplink_t)
68
69 ostream& operator<<(ostream& out, const snaplink_t &l);
70
71 // carry data about a specific version of a SnapRealm
72 struct sr_t {
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; }
76
77 void encode(bufferlist &bl) const;
78 void decode(bufferlist::const_iterator &bl);
79 void dump(Formatter *f) const;
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 };
95 };
96 WRITE_CLASS_ENCODER(sr_t)
97
98 class MDCache;
99 #endif