]> git.proxmox.com Git - ceph.git/blame - ceph/src/mds/Anchor.h
Import ceph 15.2.8
[ceph.git] / ceph / src / mds / Anchor.h
CommitLineData
11fdf7f2
TL
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) 2018 Red Hat
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_ANCHOR_H
16#define CEPH_ANCHOR_H
17
18#include <string>
19
20#include "include/types.h"
21#include "mdstypes.h"
22#include "include/buffer.h"
23
24/*
25 * Anchor represents primary linkage of an inode. When adding inode to an
26 * anchor table, MDS ensures that the table also contains inode's ancestor
27 * inodes. MDS can get inode's path by looking up anchor table recursively.
28 */
29class Anchor {
30public:
11fdf7f2
TL
31 Anchor() {}
32 Anchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp) :
33 ino(i), dirino(di), d_name(str), d_type(tp) {}
34
35 void encode(bufferlist &bl) const;
36 void decode(bufferlist::const_iterator &bl);
37 void dump(Formatter *f) const;
9f95a23c 38 static void generate_test_instances(std::list<Anchor*>& ls);
f91f0fd5 39 bool operator==(const Anchor &r) const {
9f95a23c 40 return ino == r.ino && dirino == r.dirino &&
f91f0fd5
TL
41 d_name == r.d_name && d_type == r.d_type &&
42 frags == r.frags;
9f95a23c 43 }
11fdf7f2 44
9f95a23c
TL
45 inodeno_t ino; // anchored ino
46 inodeno_t dirino;
47 std::string d_name;
48 __u8 d_type = 0;
f91f0fd5 49 std::set<frag_t> frags;
11fdf7f2 50
9f95a23c
TL
51 int omap_idx = -1; // stored in which omap object
52};
53WRITE_CLASS_ENCODER(Anchor)
11fdf7f2
TL
54
55class RecoveredAnchor : public Anchor {
56public:
57 RecoveredAnchor() {}
58
59 mds_rank_t auth = MDS_RANK_NONE; // auth hint
60};
61
62class OpenedAnchor : public Anchor {
63public:
64 OpenedAnchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp, int nr) :
65 Anchor(i, di, str, tp),
66 nref(nr)
67 {}
68
69 mutable int nref = 0; // how many children
70};
71
9f95a23c 72ostream& operator<<(ostream& out, const Anchor &a);
11fdf7f2 73#endif