]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add config to require forward to auth MDS 35377/head
authorsimon gao <simon29rock@gmail.com>
Tue, 10 Sep 2019 09:57:25 +0000 (05:57 -0400)
committerroot <root@cephdev.cern.ch>
Thu, 4 Jun 2020 15:18:19 +0000 (17:18 +0200)
If mds_forward_all_requests_to_auth is set to true. MDS will been forbidden to load noauth inode, and the auth MDS will not send other info of rep. MDS through func named set_trace_dist. so the client will only send req to auth mds of inode.
(cherry picked from commit 7d42df0)

Signed-off-by: simon gao <simon29rock@gmail.com>
 Conflicts:
src/mds/MDCache.h
 - There were conflicts involving definitions in master between the added
   lines. The master only code was removed and the PR's changes were kept.
   bool forward_all_requests_to_auth was moved to the appropriate position,
   the surrounding code block in the "theirs" section was already repeated
   in the file at another place.

src/common/options.cc
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSRank.cc
src/mds/Server.cc

index e490cb3703a1c8d0f5b178209f1d9efc0a2f0687..6485222f1a94d870a67684da95acee9ef3ab2a78 100644 (file)
@@ -8138,6 +8138,11 @@ std::vector<Option> get_mds_options() {
     .set_default(5)
     .set_description("maximum number of scrub operations performed in parallel"),
 
+    Option("mds_forward_all_requests_to_auth", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
+    .set_default(false)
+    .set_flag(Option::FLAG_RUNTIME)
+    .set_description("always process op on auth mds"),
+    
     Option("mds_damage_table_max_entries", Option::TYPE_INT, Option::LEVEL_ADVANCED)
     .set_default(10000)
     .set_description("maximum number of damage table entries"),
index 68a3299ae53a55fc1640c986ab08c9510757b748..9d1fc6b3cd09ef6b64afb1dd92c512b7714fad97 100644 (file)
@@ -151,6 +151,7 @@ MDCache::MDCache(MDSRank *m, PurgeQueue &purge_queue_) :
   cache_memory_limit = g_conf().get_val<Option::size_t>("mds_cache_memory_limit");
   cache_reservation = g_conf().get_val<double>("mds_cache_reservation");
   cache_health_threshold = g_conf().get_val<double>("mds_health_cache_threshold");
+  forward_all_requests_to_auth = g_conf().get_val<bool>("mds_forward_all_requests_to_auth");
 
   lru.lru_set_midpoint(g_conf().get_val<double>("mds_cache_mid"));
 
@@ -226,6 +227,9 @@ void MDCache::handle_conf_change(const std::set<std::string>& changed, const MDS
   if (changed.count("mds_cache_trim_decay_rate")) {
     trim_counter = DecayCounter(g_conf().get_val<double>("mds_cache_trim_decay_rate"));
   }
+  if (changed.count("mds_forward_all_requests_to_auth")){
+    forward_all_requests_to_auth = g_conf().get_val<bool>("mds_forward_all_requests_to_auth");
+  }
 
   migrator->handle_conf_change(changed, mdsmap);
   mds->balancer->handle_conf_change(changed, mdsmap);
@@ -8379,9 +8383,10 @@ int MDCache::path_traverse(MDRequestRef& mdr, MDSContextFactory& cf,     // who
       // dirfrag/dentry is not mine.
       mds_authority_t dauth = curdir->authority();
 
-      if (forward &&
+      if (!forward_all_requests_to_auth &&
+         forward &&
          mdr && mdr->client_request &&
-         (int)depth < mdr->client_request->get_num_fwd()) {
+         (int)depth < mdr->client_request->get_num_fwd()){
        dout(7) << "traverse: snap " << snapid << " and depth " << depth
                << " < fwd " << mdr->client_request->get_num_fwd()
                << ", discovering instead of forwarding" << dendl;
index 5b0b361b4ffeacecbdfc4cc3640032f516e9c86f..ea6912e76cbd8f98faf6934ac170064456c45d9e 100644 (file)
@@ -163,11 +163,15 @@ private:
   uint64_t cache_memory_limit;
   double cache_reservation;
   double cache_health_threshold;
+  bool forward_all_requests_to_auth;
 
 public:
   uint64_t cache_limit_inodes(void) {
     return cache_inode_limit;
   }
+  bool forward_all_reqs_to_auth() const { 
+    return forward_all_requests_to_auth;
+  }
   uint64_t cache_limit_memory(void) {
     return cache_memory_limit;
   }
index af108a99984fa2a53f794791d7a3b33a89676618..732d1cdefd1271c139cd2ffed4f2b407f92c6ff7 100644 (file)
@@ -3694,6 +3694,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const
     "mds_log_pause",
     "mds_max_export_size",
     "mds_max_purge_files",
+    "mds_forward_all_requests_to_auth",
     "mds_max_purge_ops",
     "mds_max_purge_ops_per_pg",
     "mds_max_snaps_per_dir",
index 016784afc59ff107db281bb58e1001db1ee6ba6f..4c3fe0c0d546f94288028207525bc7f3d662ce3a 100644 (file)
@@ -2129,7 +2129,7 @@ void Server::set_trace_dist(Session *session, const MClientReply::ref &reply,
     DirStat ds;
     ds.frag = dir->get_frag();
     ds.auth = dir->get_dir_auth().first;
-    if (dir->is_auth())
+    if (dir->is_auth() && !mdcache->forward_all_reqs_to_auth())
       dir->get_dist_spec(ds.dist, whoami);
 
     dir->encode_dirstat(bl, session->info, ds);
@@ -4359,7 +4359,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())
+  if (dir->is_auth() && !mdcache->forward_all_reqs_to_auth())
     dir->get_dist_spec(ds.dist, mds->get_nodeid());
 
   dir->encode_dirstat(dirbl, mdr->session->info, ds);