]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/cephfs_features.cc
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / mds / cephfs_features.cc
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
8 #include <fmt/format.h>
9
10 static 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",
28 "notify_session_state",
29 "op_getvxattr",
30 "32bits_retry_fwd",
31 "new_snaprealm_info",
32 };
33 static_assert(feature_names.size() == CEPHFS_FEATURE_MAX + 1);
34
35 std::string_view cephfs_feature_name(size_t id)
36 {
37 if (id > feature_names.size())
38 return "unknown";
39 return feature_names[id];
40 }
41
42 int cephfs_feature_from_name(std::string_view name)
43 {
44 if (name == "reserved") {
45 return -1;
46 }
47 for (size_t i = 0; i < feature_names.size(); ++i) {
48 if (name == feature_names[i])
49 return i;
50 }
51 return -1;
52 }
53
54 std::string cephfs_stringify_features(const feature_bitset_t& features)
55 {
56 CachedStackStringStream css;
57 bool first = true;
58 *css << "{";
59 for (size_t i = 0; i < feature_names.size(); ++i) {
60 if (!features.test(i))
61 continue;
62 if (!first)
63 *css << ",";
64 *css << i << "=" << cephfs_feature_name(i);
65 first = false;
66 }
67 *css << "}";
68 return css->str();
69 }
70
71 void cephfs_dump_features(ceph::Formatter *f, const feature_bitset_t& features)
72 {
73 for (size_t i = 0; i < feature_names.size(); ++i) {
74 if (!features.test(i))
75 continue;
76 f->dump_string(fmt::format("feature_{}", i),
77 cephfs_feature_name(i));
78 }
79 }