From: Patrick Donnelly Date: Thu, 2 May 2024 00:51:59 +0000 (-0400) Subject: client: allow overriding client features X-Git-Tag: testing/wip-pdonnell-testing-20240509.131158-reef-debug^2~13 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e552cfc893e5cd1f89dfa5fe6f0280286d356333;p=ceph-ci.git client: allow overriding client features For testing purposes. Signed-off-by: Patrick Donnelly (cherry picked from commit d9239f9375c1ae92a4990950f40078766bd912e8) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ba41e9dd084..ec97e36fb2d 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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 @@ -2354,7 +2360,7 @@ MetaSessionRef Client::_open_mds_session(mds_rank_t mds) auto m = make_message(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; diff --git a/src/client/Client.h b/src/client/Client.h index beeef0803ca..dc9e31aa8f2 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1639,6 +1639,8 @@ private: uint64_t nr_write_request = 0; std::vector cap_auths; + + feature_bitset_t myfeatures; }; /** diff --git a/src/common/options/mds-client.yaml.in b/src/common/options/mds-client.yaml.in index 1f7600dee51..28912cdb129 100644 --- a/src/common/options/mds-client.yaml.in +++ b/src/common/options/mds-client.yaml.in @@ -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 diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 044c3345960..114ca137bc4 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -7,6 +7,10 @@ #include "common/Formatter.h" #include "common/StackStringStream.h" +#include +#include +#include + const mds_gid_t MDS_GID_NONE = mds_gid_t(0); using std::list; @@ -429,7 +433,7 @@ feature_bitset_t::feature_bitset_t(unsigned long value) } } -feature_bitset_t::feature_bitset_t(const vector& array) +void feature_bitset_t::init_array(const vector& array) { if (!array.empty()) { size_t n = array.back(); @@ -448,6 +452,26 @@ feature_bitset_t::feature_bitset_t(const vector& array) } } +feature_bitset_t::feature_bitset_t(std::string_view str) +{ + std::stringstream ss; + std::vector 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& 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) { diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 3381d44c95f..8e7b16761e0 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -294,6 +294,7 @@ public: 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& array); feature_bitset_t& operator=(const feature_bitset_t& other) { _vec = other._vec; @@ -347,6 +348,8 @@ public: void dump(ceph::Formatter *f) const; void print(std::ostream& out) const; private: + void init_array(const std::vector& v); + std::vector _vec; }; WRITE_CLASS_ENCODER(feature_bitset_t)