From: Patrick Donnelly Date: Thu, 2 May 2024 00:51:59 +0000 (-0400) Subject: client: allow overriding client features X-Git-Tag: v19.1.1~326^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ddd2f044849c7fabd44fed6fb636bea8e9d11de9;p=ceph.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 0e7b0a34f9473..1428d83c0bafc 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 347446747b41e..765b8d3cafe23 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1936,6 +1936,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 1f7600dee510e..28912cdb129c7 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 21e17ca0e5bcd..fce09baef8111 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; @@ -444,7 +448,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(); @@ -463,6 +467,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 272ae76cac18d..694808890bcf0 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -296,6 +296,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; @@ -349,6 +350,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)