]> git.apps.os.sepia.ceph.com Git - ceph-ci.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>
Wed, 24 Jun 2020 22:43:32 +0000 (15:43 -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>
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 5b232c7f88e6a0ac39e776a027531b5455570634..55e4d5539c924e99cd06f0c81e188f0db2d6e224 100644 (file)
@@ -8005,6 +8005,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 39239f8fcd9aec76dbe81bea8b66f51a741776b8..03ad469d5071785ae1a90ac2a7714b3efda56396 100644 (file)
@@ -5514,6 +5514,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;
@@ -5525,7 +5526,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 58ce50128fbe56b6a38da135d0a1e84bfa1bd4b2..46974b7024d6e230d09224e8c34bd333afb90789 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 1cce2ac33b51b9d4046c171ec38bd8ba70d4ed3e..11fe5b9e3a6b3a3e59fe0a0fad9d6e28b879e5d1 100644 (file)
@@ -1001,6 +1001,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 fed587d5d33eba9529a276cc29c0b8b28d0dc70b..73527884f5fb5b139192dd7312aa21e481f7a1b1 100644 (file)
@@ -3600,6 +3600,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 a261fc4c31105fb3d1467ece7de3d56d4084ec3b..1b8a2ac031107e6a3eb61fd8b506a0bb6515c759 100644 (file)
@@ -5675,6 +5675,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;