From: Yan, Zheng Date: Mon, 17 Aug 2020 03:30:11 +0000 (+0800) Subject: mds: fix 'forward loop' when forward_all_requests_to_auth is set X-Git-Tag: v16.1.0~1360^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=13ca14d46aa66baf793b853d5b504a56a7e7654d;p=ceph.git mds: fix 'forward loop' when forward_all_requests_to_auth is set When forward_all_requests_to_auth is set, remote dentry that links to an inode with different auth can cause 'forward loop'. Fixes: https://tracker.ceph.com/issues/46988 Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 331d85102aac..682dea480e2d 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -151,7 +151,6 @@ MDCache::MDCache(MDSRank *m, PurgeQueue &purge_queue_) : cache_memory_limit = g_conf().get_val("mds_cache_memory_limit"); cache_reservation = g_conf().get_val("mds_cache_reservation"); cache_health_threshold = g_conf().get_val("mds_health_cache_threshold"); - forward_all_requests_to_auth = g_conf().get_val("mds_forward_all_requests_to_auth"); export_ephemeral_distributed_config = g_conf().get_val("mds_export_ephemeral_distributed"); export_ephemeral_random_config = g_conf().get_val("mds_export_ephemeral_random"); @@ -254,9 +253,6 @@ void MDCache::handle_conf_change(const std::set& changed, const MDS if (changed.count("mds_cache_trim_decay_rate")) { trim_counter = DecayCounter(g_conf().get_val("mds_cache_trim_decay_rate")); } - if (changed.count("mds_forward_all_requests_to_auth")){ - forward_all_requests_to_auth = g_conf().get_val("mds_forward_all_requests_to_auth"); - } migrator->handle_conf_change(changed, mdsmap); mds->balancer->handle_conf_change(changed, mdsmap); @@ -8601,8 +8597,7 @@ int MDCache::path_traverse(MDRequestRef& mdr, MDSContextFactory& cf, // dirfrag/dentry is not mine. mds_authority_t dauth = curdir->authority(); - if (!forward_all_requests_to_auth && - forward && + if (forward && mdr && mdr->client_request && (int)depth < mdr->client_request->get_num_fwd()){ dout(7) << "traverse: snap " << snapid << " and depth " << depth diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 1829350f8e1d..26667edac683 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -193,9 +193,6 @@ class MDCache { explicit MDCache(MDSRank *m, PurgeQueue &purge_queue_); ~MDCache(); - bool forward_all_reqs_to_auth() const { - return forward_all_requests_to_auth; - } uint64_t cache_limit_memory(void) { return cache_memory_limit; } @@ -1308,7 +1305,6 @@ class MDCache { uint64_t cache_memory_limit; double cache_reservation; double cache_health_threshold; - bool forward_all_requests_to_auth; std::array strays{}; // my stray dir bool export_ephemeral_distributed_config; diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 77f2b561436b..3c7d8427f7a3 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -248,6 +248,7 @@ Server::Server(MDSRank *m, MetricsHandler *metrics_handler) : recall_throttle(g_conf().get_val("mds_recall_max_decay_rate")), metrics_handler(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"); 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"); @@ -1178,6 +1179,9 @@ void Server::evict_cap_revoke_non_responders() { } 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_replay_unsafe_with_closed_session")) { replay_unsafe_with_closed_session = g_conf().get_val("mds_replay_unsafe_with_closed_session"); } @@ -2234,7 +2238,7 @@ void Server::set_trace_dist(const ref_t &reply, DirStat ds; ds.frag = dir->get_frag(); ds.auth = dir->get_dir_auth().first; - if (dir->is_auth() && !mdcache->forward_all_reqs_to_auth()) + if (dir->is_auth() && !forward_all_requests_to_auth) dir->get_dist_spec(ds.dist, whoami); dir->encode_dirstat(bl, session->info, ds); @@ -3374,6 +3378,8 @@ CInode* Server::rdlock_path_pin_ref(MDRequestRef& mdr, if (!no_want_auth) want_auth = true; } else { + if (!no_want_auth && forward_all_requests_to_auth) + want_auth = true; flags |= MDS_TRAVERSE_RDLOCK_PATH | MDS_TRAVERSE_RDLOCK_SNAP; } if (want_auth) @@ -4545,7 +4551,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr) DirStat ds; ds.frag = dir->get_frag(); ds.auth = dir->get_dir_auth().first; - if (dir->is_auth() && !mdcache->forward_all_reqs_to_auth()) + if (dir->is_auth() && !forward_all_requests_to_auth) dir->get_dist_spec(ds.dist, mds->get_nodeid()); dir->encode_dirstat(dirbl, mdr->session->info, ds); diff --git a/src/mds/Server.h b/src/mds/Server.h index 301725f5aa74..0c8d8532108f 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -342,6 +342,7 @@ private: feature_bitset_t supported_features; feature_bitset_t required_client_features; + bool forward_all_requests_to_auth = false; bool replay_unsafe_with_closed_session = false; double cap_revoke_eviction_timeout = 0; uint64_t max_snaps_per_dir = 100;