]> git.proxmox.com Git - ceph.git/blame - ceph/src/mds/cephfs_features.cc
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / mds / cephfs_features.cc
CommitLineData
f67539c2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#include <array>
5#include "cephfs_features.h"
6#include "mdstypes.h"
7
1e59de90
TL
8#include <fmt/format.h>
9
f67539c2
TL
10static const std::array feature_names
11{
12 "reserved",
13 "reserved",
14 "reserved",
15 "reserved",
16 "reserved",
17 "jewel",
18 "kraken",
19 "luminous",
20 "mimic",
21 "reply_encoding",
22 "reclaim_client",
23 "lazy_caps_wanted",
24 "multi_reconnect",
25 "deleg_ino",
26 "metric_collect",
27 "alternate_name",
39ae355f
TL
28 "notify_session_state",
29 "op_getvxattr",
1e59de90
TL
30 "32bits_retry_fwd",
31 "new_snaprealm_info",
aee94f69 32 "has_owner_uidgid",
f67539c2
TL
33};
34static_assert(feature_names.size() == CEPHFS_FEATURE_MAX + 1);
35
36std::string_view cephfs_feature_name(size_t id)
37{
38 if (id > feature_names.size())
20effc67 39 return "unknown";
f67539c2
TL
40 return feature_names[id];
41}
42
43int cephfs_feature_from_name(std::string_view name)
44{
20effc67 45 if (name == "reserved") {
f67539c2
TL
46 return -1;
47 }
48 for (size_t i = 0; i < feature_names.size(); ++i) {
49 if (name == feature_names[i])
50 return i;
51 }
52 return -1;
53}
54
55std::string cephfs_stringify_features(const feature_bitset_t& features)
56{
57 CachedStackStringStream css;
58 bool first = true;
59 *css << "{";
60 for (size_t i = 0; i < feature_names.size(); ++i) {
61 if (!features.test(i))
62 continue;
63 if (!first)
64 *css << ",";
65 *css << i << "=" << cephfs_feature_name(i);
66 first = false;
67 }
68 *css << "}";
69 return css->str();
70}
71
72void cephfs_dump_features(ceph::Formatter *f, const feature_bitset_t& features)
73{
74 for (size_t i = 0; i < feature_names.size(); ++i) {
75 if (!features.test(i))
76 continue;
1e59de90
TL
77 f->dump_string(fmt::format("feature_{}", i),
78 cephfs_feature_name(i));
f67539c2
TL
79 }
80}