From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/mds/Anchor.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/mds/Anchor.h (limited to 'src/mds/Anchor.h') diff --git a/src/mds/Anchor.h b/src/mds/Anchor.h new file mode 100644 index 00000000..49b592b9 --- /dev/null +++ b/src/mds/Anchor.h @@ -0,0 +1,73 @@ +// -*- 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) 2018 Red Hat + * + * 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_ANCHOR_H +#define CEPH_ANCHOR_H + +#include + +#include "include/types.h" +#include "mdstypes.h" +#include "include/buffer.h" + +/* + * Anchor represents primary linkage of an inode. When adding inode to an + * anchor table, MDS ensures that the table also contains inode's ancestor + * inodes. MDS can get inode's path by looking up anchor table recursively. + */ +class Anchor { +public: + inodeno_t ino; // anchored ino + inodeno_t dirino; + std::string d_name; + __u8 d_type = 0; + + int omap_idx = -1; // stored in which omap object + + Anchor() {} + Anchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp) : + ino(i), dirino(di), d_name(str), d_type(tp) {} + + void encode(bufferlist &bl) const; + void decode(bufferlist::const_iterator &bl); + void dump(Formatter *f) const; + static void generate_test_instances(list& ls); +}; +WRITE_CLASS_ENCODER(Anchor) + +inline bool operator==(const Anchor &l, const Anchor &r) { + return l.ino == r.ino && l.dirino == r.dirino && + l.d_name == r.d_name && l.d_type == r.d_type; +} + +ostream& operator<<(ostream& out, const Anchor &a); + +class RecoveredAnchor : public Anchor { +public: + RecoveredAnchor() {} + + mds_rank_t auth = MDS_RANK_NONE; // auth hint +}; + +class OpenedAnchor : public Anchor { +public: + OpenedAnchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp, int nr) : + Anchor(i, di, str, tp), + nref(nr) + {} + + mutable int nref = 0; // how many children +}; + +#endif -- cgit v1.2.3