From: Jason Dillaman Date: Fri, 11 Mar 2016 16:52:48 +0000 (-0500) Subject: librbd: track maximum object count during mirror sync X-Git-Tag: v10.1.0~104^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7f5f9da34c962ec22a7df15747b57479b6b6f66;p=ceph.git librbd: track maximum object count during mirror sync If the sync is interrupted, it is possible the image the source image is shrunk. Therefore, the sync process needs to track the maximum known object extent of the image so objects can be properly freed. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/journal/Types.cc b/src/librbd/journal/Types.cc index b79785ddd6d..86d7ec127d3 100644 --- a/src/librbd/journal/Types.cc +++ b/src/librbd/journal/Types.cc @@ -356,6 +356,7 @@ void MirrorPeerSyncPoint::dump(Formatter *f) const { void MirrorPeerClientMeta::encode(bufferlist& bl) const { ::encode(image_id, bl); + ::encode(sync_object_count, bl); ::encode(static_cast(sync_points.size()), bl); for (auto &sync_point : sync_points) { sync_point.encode(bl); @@ -365,6 +366,7 @@ void MirrorPeerClientMeta::encode(bufferlist& bl) const { void MirrorPeerClientMeta::decode(__u8 version, bufferlist::iterator& it) { ::decode(image_id, it); + ::decode(sync_object_count, it); uint32_t sync_point_count; ::decode(sync_point_count, it); @@ -378,6 +380,7 @@ void MirrorPeerClientMeta::decode(__u8 version, bufferlist::iterator& it) { void MirrorPeerClientMeta::dump(Formatter *f) const { f->dump_string("image_id", image_id); + f->dump_unsigned("sync_object_count", sync_object_count); f->open_array_section("sync_points"); for (auto &sync_point : sync_points) { f->open_object_section("sync_point"); @@ -584,6 +587,7 @@ std::ostream &operator<<(std::ostream &out, const MirrorPeerSyncPoint &sync) { std::ostream &operator<<(std::ostream &out, const MirrorPeerClientMeta &meta) { out << "[image_id=" << meta.image_id << ", " + << "sync_object_count=" << meta.sync_object_count << ", " << "sync_points=["; std::string delimiter; for (auto &sync_point : meta.sync_points) { diff --git a/src/librbd/journal/Types.h b/src/librbd/journal/Types.h index 4139847133a..b19850daa67 100644 --- a/src/librbd/journal/Types.h +++ b/src/librbd/journal/Types.h @@ -357,8 +357,9 @@ struct MirrorPeerClientMeta { static const ClientMetaType TYPE = MIRROR_PEER_CLIENT_META_TYPE; std::string image_id; - SyncPoints sync_points; ///< max two in-use snapshots for sync - SnapSeqs snap_seqs; ///< local to peer snap seq mapping + uint64_t sync_object_count = 0; ///< maximum number of objects ever sync'ed + SyncPoints sync_points; ///< max two in-use snapshots for sync + SnapSeqs snap_seqs; ///< local to peer snap seq mapping MirrorPeerClientMeta() { } @@ -370,6 +371,7 @@ struct MirrorPeerClientMeta { inline bool operator==(const MirrorPeerClientMeta &meta) const { return (image_id == meta.image_id && + sync_object_count == meta.sync_object_count && sync_points == meta.sync_points && snap_seqs == meta.snap_seqs); }