Skip to content

Commit

Permalink
client: allow overriding client features
Browse files Browse the repository at this point in the history
For testing purposes.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit d9239f9)
  • Loading branch information
batrick committed May 9, 2024
1 parent bb42425 commit e552cfc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ Client::Client(Messenger *m, MonClient *mc, Objecter *objecter_)
if (cct->_conf->client_acl_type == "posix_acl")
acl_type = POSIX_ACL;

if (auto str = cct->_conf->client_debug_inject_features; !str.empty()) {
myfeatures = feature_bitset_t(str);
} else {
myfeatures = feature_bitset_t(CEPHFS_FEATURES_CLIENT_SUPPORTED);
}

lru.lru_set_midpoint(cct->_conf->client_cache_mid);

// file handles
Expand Down Expand Up @@ -2354,7 +2360,7 @@ MetaSessionRef Client::_open_mds_session(mds_rank_t mds)

auto m = make_message<MClientSession>(CEPH_SESSION_REQUEST_OPEN);
m->metadata = metadata;
m->supported_features = feature_bitset_t(CEPHFS_FEATURES_CLIENT_SUPPORTED);
m->supported_features = myfeatures;
m->metric_spec = feature_bitset_t(CEPHFS_METRIC_FEATURES_ALL);
session->con->send_message2(std::move(m));
return session;
Expand Down
2 changes: 2 additions & 0 deletions src/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,8 @@ class Client : public Dispatcher, public md_config_obs_t {
uint64_t nr_write_request = 0;

std::vector<MDSCapAuth> cap_auths;

feature_bitset_t myfeatures;
};

/**
Expand Down
8 changes: 8 additions & 0 deletions src/common/options/mds-client.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ options:
default: 0
services:
- mds_client
- name: client_debug_inject_features
type: str
level: dev
services:
- mds_client
flags:
- startup
with_legacy: true
- name: client_max_inline_size
type: size
level: dev
Expand Down
26 changes: 25 additions & 1 deletion src/mds/mdstypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "common/Formatter.h"
#include "common/StackStringStream.h"

#include <iostream>
#include <sstream>
#include <string>

const mds_gid_t MDS_GID_NONE = mds_gid_t(0);

using std::list;
Expand Down Expand Up @@ -429,7 +433,7 @@ feature_bitset_t::feature_bitset_t(unsigned long value)
}
}

feature_bitset_t::feature_bitset_t(const vector<size_t>& array)
void feature_bitset_t::init_array(const vector<size_t>& array)
{
if (!array.empty()) {
size_t n = array.back();
Expand All @@ -448,6 +452,26 @@ feature_bitset_t::feature_bitset_t(const vector<size_t>& array)
}
}

feature_bitset_t::feature_bitset_t(std::string_view str)
{
std::stringstream ss;
std::vector<size_t> v;
std::string atom;

ss << str;
while (std::getline(ss, atom, ',')) {
v.push_back(std::stoul(atom));
}
std::sort(v.begin(), v.end());

init_array(v);
}

feature_bitset_t::feature_bitset_t(const vector<size_t>& array)
{
init_array(array);
}

feature_bitset_t& feature_bitset_t::operator-=(const feature_bitset_t& other)
{
for (size_t i = 0; i < _vec.size(); ++i) {
Expand Down
3 changes: 3 additions & 0 deletions src/mds/mdstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class feature_bitset_t {
feature_bitset_t(const feature_bitset_t& other) : _vec(other._vec) {}
feature_bitset_t(feature_bitset_t&& other) : _vec(std::move(other._vec)) {}
feature_bitset_t(unsigned long value = 0);
feature_bitset_t(std::string_view);
feature_bitset_t(const std::vector<size_t>& array);
feature_bitset_t& operator=(const feature_bitset_t& other) {
_vec = other._vec;
Expand Down Expand Up @@ -347,6 +348,8 @@ class feature_bitset_t {
void dump(ceph::Formatter *f) const;
void print(std::ostream& out) const;
private:
void init_array(const std::vector<size_t>& v);

std::vector<block_type> _vec;
};
WRITE_CLASS_ENCODER(feature_bitset_t)
Expand Down

0 comments on commit e552cfc

Please sign in to comment.