]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: track local to peer snapshot id mapping within journal
authorJason Dillaman <dillaman@redhat.com>
Tue, 8 Mar 2016 01:44:28 +0000 (20:44 -0500)
committerJason Dillaman <dillaman@redhat.com>
Sun, 13 Mar 2016 03:40:15 +0000 (22:40 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/journal/Types.cc
src/librbd/journal/Types.h

index 8da835eaf5fdf949d612c1ecc85bf1587b17133a..db29392dd4e75ce4b99694879e9f88e04ed5760a 100644 (file)
@@ -356,6 +356,7 @@ void MirrorPeerClientMeta::encode(bufferlist& bl) const {
   for (auto &sync_point : sync_points) {
     sync_point.encode(bl);
   }
+  ::encode(snap_seqs, bl);
 }
 
 void MirrorPeerClientMeta::decode(__u8 version, bufferlist::iterator& it) {
@@ -367,13 +368,25 @@ void MirrorPeerClientMeta::decode(__u8 version, bufferlist::iterator& it) {
   for (auto &sync_point : sync_points) {
     sync_point.decode(version, it);
   }
+
+  ::decode(snap_seqs, it);
 }
 
 void MirrorPeerClientMeta::dump(Formatter *f) const {
   f->dump_string("image_id", image_id);
   f->open_array_section("sync_points");
   for (auto &sync_point : sync_points) {
+    f->open_object_section("sync_point");
     sync_point.dump(f);
+    f->close_section();
+  }
+  f->close_section();
+  f->open_array_section("snap_seqs");
+  for (auto &pair : snap_seqs) {
+    f->open_object_section("snap_seq");
+    f->dump_unsigned("local_snap_seq", pair.first);
+    f->dump_unsigned("peer_snap_seq", pair.second);
+    f->close_section();
   }
   f->close_section();
 }
@@ -441,7 +454,8 @@ void ClientData::generate_test_instances(std::list<ClientData *> &o) {
   o.push_back(new ClientData(ImageClientMeta()));
   o.push_back(new ClientData(ImageClientMeta(123)));
   o.push_back(new ClientData(MirrorPeerClientMeta()));
-  o.push_back(new ClientData(MirrorPeerClientMeta("image_id", {{"snap 1", 123}})));
+  o.push_back(new ClientData(MirrorPeerClientMeta("image_id", {{"snap 1", 123}},
+                                                  {{1, 2}, {3, 4}})));
   o.push_back(new ClientData(CliClientMeta()));
 }
 
index 252ab7767590a528772d178eb6e8e9ea7bd74809..0eb28ac2392a1ecb60a07ee750dcabd5c45ef1f5 100644 (file)
@@ -339,17 +339,20 @@ struct MirrorPeerSyncPoint {
 
 struct MirrorPeerClientMeta {
   typedef std::list<MirrorPeerSyncPoint> SyncPoints;
+  typedef std::map<uint64_t, uint64_t> SnapSeqs;
 
   static const ClientMetaType TYPE = MIRROR_PEER_CLIENT_META_TYPE;
 
   std::string image_id;
-  SyncPoints sync_points;
+  SyncPoints sync_points; ///< max two in-use snapshots for sync
+  SnapSeqs snap_seqs;     ///< local to peer snap seq mapping
 
   MirrorPeerClientMeta() {
   }
   MirrorPeerClientMeta(const std::string &image_id,
-                       const SyncPoints &sync_points = SyncPoints())
-    : image_id(image_id), sync_points(sync_points) {
+                       const SyncPoints &sync_points = SyncPoints(),
+                       const SnapSeqs &snap_seqs = SnapSeqs())
+    : image_id(image_id), sync_points(sync_points), snap_seqs(snap_seqs) {
   }
 
   void encode(bufferlist& bl) const;