]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use compact map to manage waiting list
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 23 Jul 2018 22:55:46 +0000 (15:55 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 25 Jul 2018 23:03:08 +0000 (16:03 -0700)
Now that compact_multimap can handle custom allocators, this is no longer
necessary.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/include/mempool.h
src/mds/MDSCacheObject.h

index 60f6326d357dab4db111d21ffa2765d1931fde48..886fbf44032b7a7a4ad1d088563b81951eb09075 100644 (file)
@@ -405,6 +405,10 @@ public:
     using compact_map = compact_map<k, v, cmp,                          \
                         pool_allocator<std::pair<const k,v>>>;         \
                                                                         \
+    template<typename k,typename v, typename cmp = std::less<k> >       \
+    using compact_multimap = compact_multimap<k, v, cmp,                \
+                        pool_allocator<std::pair<const k,v>>>;         \
+                                                                        \
     template<typename k, typename cmp = std::less<k> >                  \
     using compact_set = compact_set<k, cmp, pool_allocator<k>>;         \
                                                                         \
index e66fcca35c2327515d60f34445e24087fc3db83d..5bad26590bb7ba076da040924944b5a7249c413f 100644 (file)
@@ -6,7 +6,6 @@
 #include "common/config.h"
 
 #include "include/Context.h"
-#include "include/alloc_ptr.h"
 #include "include/assert.h"
 #include "include/mempool.h"
 #include "include/types.h"
@@ -299,7 +298,7 @@ protected:
   // ---------------------------------------------
   // waiting
  private:
-  alloc_ptr<mempool::mds_co::multimap<uint64_t, std::pair<uint64_t, MDSInternalContextBase*>>> waiting;
+  mempool::mds_co::compact_multimap<uint64_t, std::pair<uint64_t, MDSInternalContextBase*>> waiting;
   static uint64_t last_wait_seq;
 
  public:
@@ -309,16 +308,14 @@ protected:
       while (min & (min-1))  // if more than one bit is set
         min &= min-1;        //  clear LSB
     }
-    if (waiting) {
-      for (auto p = waiting->lower_bound(min); p != waiting->end(); ++p) {
-        if (p->first & mask) return true;
-        if (p->first > mask) return false;
-      }
+    for (auto p = waiting.lower_bound(min); p != waiting.end(); ++p) {
+      if (p->first & mask) return true;
+      if (p->first > mask) return false;
     }
     return false;
   }
   virtual void add_waiter(uint64_t mask, MDSInternalContextBase *c) {
-    if (waiting->empty())
+    if (waiting.empty())
       get(PIN_WAITER);
 
     uint64_t seq = 0;
@@ -326,7 +323,7 @@ protected:
       seq = ++last_wait_seq;
       mask &= ~WAIT_ORDERED;
     }
-    waiting->insert(pair<uint64_t, pair<uint64_t, MDSInternalContextBase*> >(
+    waiting.insert(pair<uint64_t, pair<uint64_t, MDSInternalContextBase*> >(
                            mask,
                            pair<uint64_t, MDSInternalContextBase*>(seq, c)));
 //    pdout(10,g_conf()->debug_mds) << (mdsco_db_line_prefix(this)) 
@@ -336,12 +333,12 @@ protected:
     
   }
   virtual void take_waiting(uint64_t mask, std::list<MDSInternalContextBase*>& ls) {
-    if (!waiting || waiting->empty()) return;
+    if (waiting.empty()) return;
 
     // process ordered waiters in the same order that they were added.
     std::map<uint64_t, MDSInternalContextBase*> ordered_waiters;
 
-    for (auto it = waiting->begin(); it != waiting->end(); ) {
+    for (auto it = waiting.begin(); it != waiting.end(); ) {
       if (it->first & mask) {
            if (it->second.first > 0) {
              ordered_waiters.insert(it->second);
@@ -353,7 +350,7 @@ protected:
 //                                << " tag " << hex << it->first << dec
 //                                << " on " << *this
 //                                << dendl;
-        waiting->erase(it++);
+        waiting.erase(it++);
       } else {
 //     pdout(10,g_conf()->debug_mds) << "take_waiting mask " << hex << mask << dec << " SKIPPING " << it->second
 //                                << " tag " << hex << it->first << dec
@@ -365,9 +362,9 @@ protected:
     for (auto it = ordered_waiters.begin(); it != ordered_waiters.end(); ++it) {
       ls.push_back(it->second);
     }
-    if (waiting->empty()) {
+    if (waiting.empty()) {
       put(PIN_WAITER);
-      waiting.reset();
+      waiting.clear();
     }
   }
   void finish_waiting(uint64_t mask, int result = 0);