From f51d2a6352aff78d30862d5c4b51bdfce948ff3c Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 27 Jun 2025 14:38:17 -0400 Subject: [PATCH] mds: allow disabling batch ops To address a bug and future ones where batching lookup/getattr does not help "kick" the MDS in switching state more quickly (e.g. flushing the MDS journal). Signed-off-by: Patrick Donnelly (cherry picked from commit 0201f86e6939a3d787bea755a48cb4b4254d2f9c) --- src/common/options/mds.yaml.in | 15 +++++++++++++++ src/mds/MDSRank.cc | 1 + src/mds/Server.cc | 6 +++++- src/mds/Server.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/common/options/mds.yaml.in b/src/common/options/mds.yaml.in index aacdadd858f..ca4fc1f67aa 100644 --- a/src/common/options/mds.yaml.in +++ b/src/common/options/mds.yaml.in @@ -780,6 +780,21 @@ options: services: - mds with_legacy: true +- name: mds_allow_batched_ops + type: bool + level: advanced + desc: allow MDS to batch lookup/getattr RPCs + long_desc: > + The MDS will batch a lookup or getattr RPC on the same inode when + possible to avoid repetitive locks on metadata and to bypass other + requests acquiring write locks. Generally, this should only + improve performance but this switch exists to provide a means to + turn this behavior off for comparison. + default: true + services: + - mds + flags: + - runtime # multiple of size_max that triggers immediate split - name: mds_bal_fragment_fast_factor type: float diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 85bc8e260e7..e9b9b40c845 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -4066,6 +4066,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const "clog_to_syslog_level", "fsid", "host", + "mds_allow_batched_ops", "mds_alternate_name_max", "mds_bal_fragment_dirs", "mds_bal_fragment_interval", diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 49d5fdd7efa..6f05cefc9d4 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -266,6 +266,7 @@ Server::Server(MDSRank *m, MetricsHandler *metrics_handler) : { forward_all_requests_to_auth = g_conf().get_val("mds_forward_all_requests_to_auth"); replay_unsafe_with_closed_session = g_conf().get_val("mds_replay_unsafe_with_closed_session"); + allow_batched_ops = g_conf().get_val("mds_allow_batched_ops"); cap_revoke_eviction_timeout = g_conf().get_val("mds_cap_revoke_eviction_timeout"); max_snaps_per_dir = g_conf().get_val("mds_max_snaps_per_dir"); delegate_inos_pct = g_conf().get_val("mds_client_delegate_inos_pct"); @@ -1327,6 +1328,9 @@ void Server::handle_conf_change(const std::set& changed) { if (changed.count("mds_forward_all_requests_to_auth")){ forward_all_requests_to_auth = g_conf().get_val("mds_forward_all_requests_to_auth"); } + if (changed.count("mds_allow_batched_ops")) { + allow_batched_ops = g_conf().get_val("mds_allow_batched_ops"); + } if (changed.count("mds_cap_revoke_eviction_timeout")) { cap_revoke_eviction_timeout = g_conf().get_val("mds_cap_revoke_eviction_timeout"); dout(20) << __func__ << " cap revoke eviction timeout changed to " @@ -4116,7 +4120,7 @@ void Server::handle_client_getattr(const MDRequestRef& mdr, bool is_lookup) if (mask & CEPH_STAT_RSTAT) want_auth = true; // set want_auth for CEPH_STAT_RSTAT mask - if (!mdr->is_batch_head() && mdr->can_batch()) { + if (!mdr->is_batch_head() && allow_batched_ops && mdr->can_batch()) { CF_MDS_RetryRequestFactory cf(mdcache, mdr, false); int r = mdcache->path_traverse(mdr, cf, mdr->get_filepath(), (want_auth ? MDS_TRAVERSE_WANT_AUTH : 0), diff --git a/src/mds/Server.h b/src/mds/Server.h index c7d64efff5b..495cbaf2c1b 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -570,6 +570,7 @@ private: unsigned delegate_inos_pct = 0; uint64_t dir_max_entries = 0; int64_t bal_fragment_size_max = 0; + bool allow_batched_ops = true; double inject_rename_corrupt_dentry_first = 0.0; -- 2.47.3