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
19 #include <string_view>
22 #include "common/snap_types.h"
24 #include "Capability.h"
27 * generic snap descriptor.
30 void encode(ceph::buffer::list
&bl
) const;
31 void decode(ceph::buffer::list::const_iterator
&bl
);
32 void dump(ceph::Formatter
*f
) const;
33 static void generate_test_instances(std::list
<SnapInfo
*>& ls
);
35 std::string_view
get_long_name() const;
42 mutable std::string long_name
; ///< cached _$ino_$name
43 std::map
<std::string
,std::string
> metadata
;
45 WRITE_CLASS_ENCODER(SnapInfo
)
47 inline bool operator==(const SnapInfo
&l
, const SnapInfo
&r
)
49 return l
.snapid
== r
.snapid
&& l
.ino
== r
.ino
&&
50 l
.stamp
== r
.stamp
&& l
.name
== r
.name
;
53 std::ostream
& operator<<(std::ostream
& out
, const SnapInfo
&sn
);
56 * SnapRealm - a subtree that shares the same set of snapshots.
61 void encode(ceph::buffer::list
&bl
) const;
62 void decode(ceph::buffer::list::const_iterator
&bl
);
63 void dump(ceph::Formatter
*f
) const;
64 static void generate_test_instances(std::list
<snaplink_t
*>& ls
);
69 WRITE_CLASS_ENCODER(snaplink_t
)
71 std::ostream
& operator<<(std::ostream
& out
, const snaplink_t
&l
);
73 // carry data about a specific version of a SnapRealm
75 void mark_parent_global() { flags
|= PARENT_GLOBAL
; }
76 void clear_parent_global() { flags
&= ~PARENT_GLOBAL
; }
77 bool is_parent_global() const { return flags
& PARENT_GLOBAL
; }
79 void mark_subvolume() { flags
|= SUBVOLUME
; }
80 void clear_subvolume() { flags
&= ~SUBVOLUME
; }
81 bool is_subvolume() const { return flags
& SUBVOLUME
; }
83 void encode(ceph::buffer::list
&bl
) const;
84 void decode(ceph::buffer::list::const_iterator
&bl
);
85 void dump(ceph::Formatter
*f
) const;
86 static void generate_test_instances(std::list
<sr_t
*>& ls
);
88 snapid_t seq
= 0; // basically, a version/seq # for changes to _this_ realm.
89 snapid_t created
= 0; // when this realm was created.
90 snapid_t last_created
= 0; // last snap created in _this_ realm.
91 snapid_t last_destroyed
= 0; // seq for last removal
92 snapid_t current_parent_since
= 1;
93 std::map
<snapid_t
, SnapInfo
> snaps
;
94 std::map
<snapid_t
, snaplink_t
> past_parents
; // key is "last" (or NOSNAP)
95 std::set
<snapid_t
> past_parent_snaps
;
96 utime_t last_modified
; // timestamp when this realm
98 uint64_t change_attr
= 0; // tracks changes to snap
103 PARENT_GLOBAL
= 1 << 0,
107 WRITE_CLASS_ENCODER(sr_t
)