]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/Anchor.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / mds / Anchor.h
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 */
29 class Anchor {
30 public:
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;
38 static void generate_test_instances(std::list<Anchor*>& ls);
39 bool operator==(const Anchor &r) const {
40 return ino == r.ino && dirino == r.dirino &&
41 d_name == r.d_name && d_type == r.d_type &&
42 frags == r.frags;
43 }
44
45 inodeno_t ino; // anchored ino
46 inodeno_t dirino;
47 std::string d_name;
48 __u8 d_type = 0;
49 std::set<frag_t> frags;
50
51 int omap_idx = -1; // stored in which omap object
52 };
53 WRITE_CLASS_ENCODER(Anchor)
54
55 class RecoveredAnchor : public Anchor {
56 public:
57 RecoveredAnchor() {}
58
59 mds_rank_t auth = MDS_RANK_NONE; // auth hint
60 };
61
62 class OpenedAnchor : public Anchor {
63 public:
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
72 std::ostream& operator<<(std::ostream& out, const Anchor &a);
73 #endif