]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: splice pg_temp_wanted more efficiently
authorKefu Chai <kchai@redhat.com>
Fri, 15 Sep 2017 10:51:39 +0000 (18:51 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 15 Sep 2017 11:27:11 +0000 (19:27 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 0dd6155274799147d7cf71475bac2a2c41efaaa8..fa8dfcbddaa0cff5f57e4dc69f0d2a441b2b66cc 100644 (file)
@@ -1035,7 +1035,7 @@ pair<ConnectionRef,ConnectionRef> OSDService::get_con_osd_hb(int peer, epoch_t f
 }
 
 
-void OSDService::queue_want_pg_temp(pg_t pgid, vector<int>& want)
+void OSDService::queue_want_pg_temp(pg_t pgid, const vector<int>& want)
 {
   Mutex::Locker l(pg_temp_lock);
   map<pg_t,vector<int> >::iterator p = pg_temp_pending.find(pgid);
@@ -1054,10 +1054,8 @@ void OSDService::remove_want_pg_temp(pg_t pgid)
 
 void OSDService::_sent_pg_temp()
 {
-  for (map<pg_t,vector<int> >::iterator p = pg_temp_wanted.begin();
-       p != pg_temp_wanted.end();
-       ++p)
-    pg_temp_pending[p->first] = p->second;
+  pg_temp_pending.insert(make_move_iterator(begin(pg_temp_wanted)),
+                        make_move_iterator(end(pg_temp_wanted)));
   pg_temp_wanted.clear();
 }
 
index 575d84c7e15721669d17751f02f7c1d6b15b6a74..2982656fdd349b843d5b9660b0731ec30bbb59ee 100644 (file)
@@ -841,7 +841,7 @@ private:
   map<pg_t, vector<int> > pg_temp_pending;
   void _sent_pg_temp();
 public:
-  void queue_want_pg_temp(pg_t pgid, vector<int>& want);
+  void queue_want_pg_temp(pg_t pgid, const vector<int>& want);
   void remove_want_pg_temp(pg_t pgid);
   void requeue_pg_temp();
   void send_pg_temp();
@@ -1149,7 +1149,7 @@ public:
     PREPARING_TO_STOP,
     STOPPING };
   std::atomic_int state{NOT_STOPPING};
-  int get_state() {
+  int get_state() const {
     return state;
   }
   void set_state(int s) {