]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add maximum random ephemeral pin percentage
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 9 Jun 2020 23:49:20 +0000 (16:49 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 2 Jul 2020 00:19:54 +0000 (17:19 -0700)
This new config is designed to prevent creating too many subtrees from a
random ephemeral pinning policy.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit c8d343d592de92af91c6f9eecb6aab0ebed54657)

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

index c456ea173a87a8036e6b7d07ce64cedfe61f5626..c0941ceb503ce2097bd24fe9e67db52c55525c31 100644 (file)
@@ -7837,6 +7837,13 @@ std::vector<Option> get_mds_options() {
     .set_description("allow ephemeral random pinning of the loaded subtrees")
     .set_long_description("probabilistically pin the loaded directory inode and the subtree beneath it to an MDS based on the consistent hash of the inode number. The higher this value the more likely the loaded subtrees get pinned"),
 
+    Option("mds_export_ephemeral_random_max", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
+    .set_default(0.01)
+    .set_flag(Option::FLAG_RUNTIME)
+    .set_description("the maximum percent permitted for random ephemeral pin policy")
+    .set_min_max(0.0, 1.0)
+    .add_see_also("mds_export_ephemeral_random"),
+
     Option("mds_export_ephemeral_distributed", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(false)
     .set_flag(Option::FLAG_RUNTIME)
index e8b0b69e46f0b82916995d3036785e53678d2477..f543fa730f685a7684b93793770a53bdea33a379 100644 (file)
@@ -5474,6 +5474,7 @@ double CInode::get_ephemeral_rand(bool inherit) const
    * have a parent yet.
    */
   const CInode *in = this;
+  double max = mdcache->export_ephemeral_random_max;
   while (true) {
     if (in->is_system())
       break;
@@ -5485,7 +5486,7 @@ double CInode::get_ephemeral_rand(bool inherit) const
       break;
 
     if (in->get_inode().export_ephemeral_random_pin > 0.0)
-      return in->get_inode().export_ephemeral_random_pin;
+      return std::min(in->get_inode().export_ephemeral_random_pin, max);
 
     /* An export_pin overrides only if no closer parent (incl. this one) has a
      * random pin set.
index 6a9b314c92b4d61f2ab9444b2471de6b0f9b2995..88eece19f00bb485c42581b7cc838641626986bd 100644 (file)
@@ -155,6 +155,7 @@ MDCache::MDCache(MDSRank *m, PurgeQueue &purge_queue_) :
 
   export_ephemeral_distributed_config =  g_conf().get_val<bool>("mds_export_ephemeral_distributed");
   export_ephemeral_random_config =  g_conf().get_val<bool>("mds_export_ephemeral_random");
+  export_ephemeral_random_max = g_conf().get_val<double>("mds_export_ephemeral_random_max");
 
   lru.lru_set_midpoint(g_conf().get_val<double>("mds_cache_mid"));
 
@@ -243,6 +244,9 @@ void MDCache::handle_conf_change(const std::set<std::string>& changed, const MDS
     }
     mds->balancer->handle_export_pins();
   }
+  if (changed.count("mds_export_ephemeral_random_max")) {
+    export_ephemeral_random_max = g_conf().get_val<double>("mds_export_ephemeral_random_max");
+  }
   if (changed.count("mds_health_cache_threshold"))
     cache_health_threshold = g_conf().get_val<double>("mds_health_cache_threshold");
   if (changed.count("mds_cache_mid"))
index 20f946c60ff24288ad618ab6c2bec1636932e547..38fac4235db4dac098f3288933b43928d7be46cb 100644 (file)
@@ -1004,6 +1004,8 @@ class MDCache {
 
   OpenFileTable open_file_table;
 
+  double export_ephemeral_random_max = 0.0;
+
  protected:
   // track master requests whose slaves haven't acknowledged commit
   struct umaster {
index 4b267319a6b558de5514ca8b725fc98988323e5b..69e98db1c34254314bf67545335c271dc6c5be41 100644 (file)
@@ -3525,6 +3525,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const
     "mds_dump_cache_threshold_formatter",
     "mds_enable_op_tracker",
     "mds_export_ephemeral_random",
+    "mds_export_ephemeral_random_max",
     "mds_export_ephemeral_distributed",
     "mds_health_cache_threshold",
     "mds_inject_migrator_session_race",
index 2899031a880e975a5b2201546aaff5765de4d6e4..d636646807d850628dc152cb98203c1995fadecf 100644 (file)
@@ -5640,6 +5640,14 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur)
       return;
     }
 
+    if (val < 0.0 || 1.0 < val) {
+      respond_to_request(mdr, -EDOM);
+      return;
+    } else if (mdcache->export_ephemeral_random_max < val) {
+      respond_to_request(mdr, -EINVAL);
+      return;
+    }
+
     if (!xlock_policylock(mdr, cur))
       return;