1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
15 #ifndef CEPH_MDS_SNAP_H
16 #define CEPH_MDS_SNAP_H
18 #include <string_view>
21 #include "common/snap_types.h"
23 #include "Capability.h"
26 * generic snap descriptor.
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
);
34 std::string_view
get_long_name() const;
41 mutable string long_name
; ///< cached _$ino_$name
43 WRITE_CLASS_ENCODER(SnapInfo
)
45 inline bool operator==(const SnapInfo
&l
, const SnapInfo
&r
)
47 return l
.snapid
== r
.snapid
&& l
.ino
== r
.ino
&&
48 l
.stamp
== r
.stamp
&& l
.name
== r
.name
;
51 ostream
& operator<<(ostream
& out
, const SnapInfo
&sn
);
54 * SnapRealm - a subtree that shares the same set of snapshots.
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
);
67 WRITE_CLASS_ENCODER(snaplink_t
)
69 ostream
& operator<<(ostream
& out
, const snaplink_t
&l
);
71 // carry data about a specific version of a SnapRealm
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
; }
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
);
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
;
93 PARENT_GLOBAL
= 1 << 0,
96 WRITE_CLASS_ENCODER(sr_t
)