From: Jason Dillaman Date: Tue, 8 Mar 2016 01:44:28 +0000 (-0500) Subject: librbd: track local to peer snapshot id mapping within journal X-Git-Tag: v10.1.0~104^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ffa8cc39b5f271e18d6d67d130ca2f760969ef1f;p=ceph.git librbd: track local to peer snapshot id mapping within journal Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/journal/Types.cc b/src/librbd/journal/Types.cc index 8da835eaf5fd..db29392dd4e7 100644 --- a/src/librbd/journal/Types.cc +++ b/src/librbd/journal/Types.cc @@ -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 &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())); } diff --git a/src/librbd/journal/Types.h b/src/librbd/journal/Types.h index 252ab7767590..0eb28ac2392a 100644 --- a/src/librbd/journal/Types.h +++ b/src/librbd/journal/Types.h @@ -339,17 +339,20 @@ struct MirrorPeerSyncPoint { struct MirrorPeerClientMeta { typedef std::list SyncPoints; + typedef std::map 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;