]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
messages/MOSDPGQuery: add a ctor for moving pg_list
authorKefu Chai <kchai@redhat.com>
Tue, 26 Feb 2019 08:42:19 +0000 (16:42 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 16 Mar 2019 06:22:59 +0000 (14:22 +0800)
* add a constructor for movable pg_list parameter: less memcpy().

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/messages/MOSDPGQuery.h
src/osd/OSD.cc

index d1d9ecd9156ae54805023db3fd514338a028ea78..c9f3f8e4e70430b7d0fda04ec2ed6899994d54b4 100644 (file)
@@ -34,19 +34,20 @@ private:
 
  public:
   version_t get_epoch() const { return epoch; }
-  map<spg_t, pg_query_t>  pg_list;
+  using pg_list_t = std::map<spg_t, pg_query_t>;
+  pg_list_t pg_list;
 
   MOSDPGQuery() : MessageInstance(MSG_OSD_PG_QUERY,
                          HEAD_VERSION,
                          COMPAT_VERSION) {
     set_priority(CEPH_MSG_PRIO_HIGH);
   }
-  MOSDPGQuery(epoch_t e, map<spg_t,pg_query_t>& ls) :
+  MOSDPGQuery(epoch_t e, pg_list_t&& ls) :
     MessageInstance(MSG_OSD_PG_QUERY,
            HEAD_VERSION,
            COMPAT_VERSION),
-    epoch(e) {
-    pg_list.swap(ls);
+    epoch(e),
+    pg_list(std::move(ls)) {
     set_priority(CEPH_MSG_PRIO_HIGH);
   }
 private:
index e511fa4e79b86a027aca20a51be6f384f9fd9deb..a52625e24b09d55861e6ecf54116c9b499b9f6cc 100644 (file)
@@ -9213,7 +9213,8 @@ void OSD::do_queries(map<int, map<spg_t,pg_query_t> >& query_map,
     service.share_map_peer(who, con.get(), curmap);
     dout(7) << __func__ << " querying osd." << who
            << " on " << pit->second.size() << " PGs" << dendl;
-    MOSDPGQuery *m = new MOSDPGQuery(curmap->get_epoch(), pit->second);
+    MOSDPGQuery *m = new MOSDPGQuery(curmap->get_epoch(),
+                                    std::move(pit->second));
     con->send_message(m);
   }
 }