]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: change MDSRank::finished_queue to deque
authorYan, Zheng <zyan@redhat.com>
Tue, 31 Jul 2018 00:57:36 +0000 (08:57 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 2 Aug 2018 00:22:22 +0000 (08:22 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDSContext.h
src/mds/MDSRank.cc
src/mds/MDSRank.h

index 29952f9b3dd3edc3f0e04bb3733460599ee072d7..e9c0d52ab0109fb63de27313e77c318899f5edb8 100644 (file)
@@ -17,7 +17,7 @@
 #define MDS_CONTEXT_H
 
 #include <vector>
-#include <queue>
+#include <deque>
 
 #include "include/Context.h"
 #include "include/elist.h"
@@ -52,7 +52,7 @@ public:
     using vec = vec_alloc<std::allocator>;
 
     template<template<typename> class A>
-    using que_alloc = std::queue<MDSInternalContextBase *, std::deque<MDSInternalContextBase *, A<MDSInternalContextBase *>>>;
+    using que_alloc = std::deque<MDSInternalContextBase *, A<MDSInternalContextBase *>>;
     using que = que_alloc<std::allocator>;
 
     void complete(int r) override;
index 2289508410e18b8bc7b9a73f32dc2738ac344148..2997baf719b6e6e2855cd433fd90f760b8281103 100644 (file)
@@ -818,14 +818,15 @@ void MDSRank::_advance_queues()
 {
   assert(mds_lock.is_locked_by_me());
 
-  while (!finished_queue.empty()) {
+  if (!finished_queue.empty()) {
     dout(7) << "mds has " << finished_queue.size() << " queued contexts" << dendl;
-    dout(10) << finished_queue << dendl;
-    decltype(finished_queue) ls;
-    ls.swap(finished_queue);
-    for (auto& c : ls) {
-      dout(10) << " finish " << c << dendl;
-      c->complete(0);
+    while (!finished_queue.empty()) {
+      auto fin = finished_queue.front();
+      finished_queue.pop_front();
+
+      dout(10) << " finish " << fin << dendl;
+      fin->complete(0);
+
       heartbeat_reset();
     }
   }
@@ -1535,7 +1536,7 @@ bool MDSRank::queue_one_replay()
     return false;
   }
   queue_waiter(replay_queue.front());
-  replay_queue.pop();
+  replay_queue.pop_front();
   return true;
 }
 
index 7cf3be6a65e5b3600d8ff4d2663bcb9fc68cfa12..2b8807ae283ec3d46cf08d5f5bb1a8a264d0f410 100644 (file)
@@ -249,7 +249,7 @@ class MDSRank {
     } progress_thread;
 
     list<Message*> waiting_for_nolaggy;
-    MDSInternalContextBase::vec finished_queue;
+    MDSInternalContextBase::que finished_queue;
     // Dispatch, retry, queues
     int dispatch_depth;
     void inc_dispatch_depth() { ++dispatch_depth; }
@@ -304,7 +304,7 @@ class MDSRank {
     void queue_waiters(MDSInternalContextBase::vec& ls) {
       MDSInternalContextBase::vec v;
       v.swap(ls);
-      finished_queue.insert(finished_queue.end(), v.begin(), v.end());
+      std::copy(v.begin(), v.end(), std::back_inserter(finished_queue));
       progress_thread.signal();
     }
 
@@ -407,7 +407,7 @@ class MDSRank {
       waiting_for_mdsmap[e].push_back(c);
     }
     void enqueue_replay(MDSInternalContextBase *c) {
-      replay_queue.push(c);
+      replay_queue.push_back(c);
     }
 
     bool queue_one_replay();