]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMap: deepish_copy_from()
authorSage Weil <sage@inktank.com>
Fri, 24 Jan 2014 19:03:26 +0000 (11:03 -0800)
committerSage Weil <sage@inktank.com>
Mon, 27 Jan 2014 22:17:02 +0000 (14:17 -0800)
Make a deep(ish) copy of another OSDMap.  Unfortunatley we can't make the
compiler-generated copy operator/constructors private until c++11.  :(

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/OSDMap.h

index 927ab182bfd2b89d920ac2a2be84ec9646d8bb66..d7a479c3923b3fa84063a47263b900277be28b2e 100644 (file)
@@ -240,6 +240,26 @@ private:
     memset(&fsid, 0, sizeof(fsid));
   }
 
+  // no copying
+  /* oh, how i long for c++11...
+private:
+  OSDMap(const OSDMap& other) = default;
+  const OSDMap& operator=(const OSDMap& other) = default;
+public:
+  */
+
+  void deepish_copy_from(const OSDMap& o) {
+    primary_temp.reset(new map<pg_t,int>(*o.primary_temp));
+    pg_temp.reset(new map<pg_t,vector<int> >(*o.pg_temp));
+    osd_uuid.reset(new vector<uuid_d>(*o.osd_uuid));
+
+    // NOTE: this still references shared entity_addr_t's.
+    osd_addrs.reset(new addrs_s(*o.osd_addrs));
+
+    // NOTE: we do not copy crush.  note that apply_incremental will
+    // allocate a new CrushWrapper, though.
+  }
+
   // map info
   const uuid_d& get_fsid() const { return fsid; }
   void set_fsid(uuid_d& f) { fsid = f; }