]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: optimize random threshold lookup for dentry load 35969/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 8 Jul 2020 03:09:35 +0000 (20:09 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 14 Jul 2020 01:33:19 +0000 (18:33 -0700)
Credit to Zheng for the suggestions.

Fixes: https://tracker.ceph.com/issues/46302
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h

index 6acc5d025bc0c61d4083cd5bf9c0ffe484bea055..f3e20e0972f565f735ec3dc7169ba9b1beaf3b95 100644 (file)
@@ -1695,6 +1695,7 @@ CDentry *CDir::_load_dentry(
     bufferlist &bl,
     const int pos,
     const std::set<snapid_t> *snaps,
+    double rand_threshold,
     bool *force_dirty)
 {
   auto q = bl.cbegin();
@@ -1857,7 +1858,7 @@ CDentry *CDir::_load_dentry(
         if (in->inode.is_dirty_rstat())
           in->mark_dirty_rstat();
 
-        in->maybe_ephemeral_rand(true);
+        in->maybe_ephemeral_rand(true, rand_threshold);
         //in->hack_accessed = false;
         //in->hack_load_stamp = ceph_clock_now();
         //num_new_inodes_loaded++;
@@ -1969,6 +1970,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
   }
 
   unsigned pos = omap.size() - 1;
+  double rand_threshold = get_inode()->get_ephemeral_rand();
   for (map<string, bufferlist>::reverse_iterator p = omap.rbegin();
        p != omap.rend();
        ++p, --pos) {
@@ -1980,7 +1982,7 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map<string, bufferlist>& omap,
     try {
       dn = _load_dentry(
             p->first, dname, last, p->second, pos, snaps,
-            &force_dirty);
+            rand_threshold, &force_dirty);
     } catch (const buffer::error &err) {
       cache->mds->clog->warn() << "Corrupt dentry '" << dname << "' in "
                                   "dir frag " << dirfrag() << ": "
index 4ad5edfd5de74a357f39f0159c646d3ceeff9a5d..ca27e32e18630debe62d460c909584f8959c8507 100644 (file)
@@ -646,6 +646,7 @@ protected:
       ceph::buffer::list &bl,
       int pos,
       const std::set<snapid_t> *snaps,
+      double rand_threshold,
       bool *force_dirty);
 
   /**
index 03ad469d5071785ae1a90ac2a7714b3efda56396..292321dc0fc3a6b5481227a84476ad3c2b22a894 100644 (file)
@@ -5388,7 +5388,7 @@ void CInode::set_ephemeral_rand(bool yes)
   }
 }
 
-void CInode::maybe_ephemeral_rand(bool fresh)
+void CInode::maybe_ephemeral_rand(bool fresh, double threshold)
 {
   if (!mdcache->get_export_ephemeral_random_config()) {
     dout(15) << __func__ << " config false: cannot ephemeral random pin " << *this << dendl;
@@ -5410,7 +5410,13 @@ void CInode::maybe_ephemeral_rand(bool fresh)
     return;
   }
 
-  double threshold = get_ephemeral_rand();
+  /* not precomputed? */
+  if (threshold < 0.0) {
+    threshold = get_ephemeral_rand();
+  }
+  if (threshold <= 0.0) {
+    return;
+  }
   double n = ceph::util::generate_random_number(0.0, 1.0);
 
   dout(15) << __func__ << " rand " << n << " <?= " << threshold
index 83fb13e4d82967126b87556dd3978ea9bfd8f94e..6e6be5374d02a96ec12b3535ae315fa527eb2bc5 100644 (file)
@@ -942,7 +942,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
 
   double get_ephemeral_rand(bool inherit=true) const;
   void set_ephemeral_rand(bool yes);
-  void maybe_ephemeral_rand(bool fresh=false);
+  void maybe_ephemeral_rand(bool fresh=false, double threshold=-1.0);
   void setxattr_ephemeral_rand(double prob=0.0);
   bool is_ephemeral_rand() const {
     return state_test(STATE_RANDEPHEMERALPIN);