summaryrefslogtreecommitdiffstats
path: root/src/mds/snap.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/mds/snap.h
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mds/snap.h')
-rw-r--r--src/mds/snap.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/mds/snap.h b/src/mds/snap.h
new file mode 100644
index 00000000..41f48d80
--- /dev/null
+++ b/src/mds/snap.h
@@ -0,0 +1,115 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#ifndef CEPH_MDS_SNAP_H
+#define CEPH_MDS_SNAP_H
+
+#include <string_view>
+
+#include "mdstypes.h"
+#include "common/snap_types.h"
+
+/*
+ * generic snap descriptor.
+ */
+struct SnapInfo {
+ snapid_t snapid;
+ inodeno_t ino;
+ utime_t stamp;
+ string name;
+
+ mutable string long_name; ///< cached _$ino_$name
+
+ void encode(bufferlist &bl) const;
+ void decode(bufferlist::const_iterator &bl);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<SnapInfo*>& ls);
+
+ std::string_view get_long_name() const;
+};
+WRITE_CLASS_ENCODER(SnapInfo)
+
+inline bool operator==(const SnapInfo &l, const SnapInfo &r)
+{
+ return l.snapid == r.snapid && l.ino == r.ino &&
+ l.stamp == r.stamp && l.name == r.name;
+}
+
+ostream& operator<<(ostream& out, const SnapInfo &sn);
+
+
+/*
+ * SnapRealm - a subtree that shares the same set of snapshots.
+ */
+struct SnapRealm;
+class CInode;
+class MDCache;
+
+
+
+#include "Capability.h"
+
+struct snaplink_t {
+ inodeno_t ino;
+ snapid_t first;
+
+ void encode(bufferlist &bl) const;
+ void decode(bufferlist::const_iterator &bl);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<snaplink_t*>& ls);
+};
+WRITE_CLASS_ENCODER(snaplink_t)
+
+ostream& operator<<(ostream& out, const snaplink_t &l);
+
+
+// carry data about a specific version of a SnapRealm
+struct sr_t {
+ snapid_t seq; // basically, a version/seq # for changes to _this_ realm.
+ snapid_t created; // when this realm was created.
+ snapid_t last_created; // last snap created in _this_ realm.
+ snapid_t last_destroyed; // seq for last removal
+ snapid_t current_parent_since;
+ map<snapid_t, SnapInfo> snaps;
+ map<snapid_t, snaplink_t> past_parents; // key is "last" (or NOSNAP)
+ set<snapid_t> past_parent_snaps;
+
+ __u32 flags;
+ enum {
+ PARENT_GLOBAL = 1 << 0,
+ SUBVOLUME = 1 << 1,
+ };
+
+ void mark_parent_global() { flags |= PARENT_GLOBAL; }
+ void clear_parent_global() { flags &= ~PARENT_GLOBAL; }
+ bool is_parent_global() const { return flags & PARENT_GLOBAL; }
+
+ void mark_subvolume() { flags |= SUBVOLUME; }
+ void clear_subvolume() { flags &= ~SUBVOLUME; }
+ bool is_subvolume() const { return flags & SUBVOLUME; }
+
+ sr_t()
+ : seq(0), created(0),
+ last_created(0), last_destroyed(0),
+ current_parent_since(1), flags(0)
+ {}
+
+ void encode(bufferlist &bl) const;
+ void decode(bufferlist::const_iterator &bl);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<sr_t*>& ls);
+};
+WRITE_CLASS_ENCODER(sr_t)
+
+#endif