From: Patrick Donnelly Date: Mon, 23 Jul 2018 22:55:46 +0000 (-0700) Subject: mds: use compact map to manage waiting list X-Git-Tag: v14.0.1~708^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ad1aeb54fcbdc707f6eb74cac17211bb454eb64;p=ceph.git mds: use compact map to manage waiting list Now that compact_multimap can handle custom allocators, this is no longer necessary. Signed-off-by: Patrick Donnelly --- diff --git a/src/include/mempool.h b/src/include/mempool.h index 60f6326d357d..886fbf44032b 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -405,6 +405,10 @@ public: using compact_map = compact_map>>; \ \ + template > \ + using compact_multimap = compact_multimap>>; \ + \ template > \ using compact_set = compact_set>; \ \ diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index e66fcca35c23..5bad26590bb7 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -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>> waiting; + mempool::mds_co::compact_multimap> 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 >( + waiting.insert(pair >( mask, pair(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& ls) { - if (!waiting || waiting->empty()) return; + if (waiting.empty()) return; // process ordered waiters in the same order that they were added. std::map 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);