]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: track maximum object count during mirror sync
authorJason Dillaman <dillaman@redhat.com>
Fri, 11 Mar 2016 16:52:48 +0000 (11:52 -0500)
committerJason Dillaman <dillaman@redhat.com>
Sun, 13 Mar 2016 03:40:16 +0000 (22:40 -0500)
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 <dillaman@redhat.com>
src/librbd/journal/Types.cc
src/librbd/journal/Types.h

index b79785ddd6d59fe85b0c0b6f3594389e07d804da..86d7ec127d33a8a6e87cd3c95277be12123ae990 100644 (file)
@@ -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<uint32_t>(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) {
index 4139847133aa441b6ca56c2f1df80a3dac49013e..b19850daa675f9a8d25a0e1b57c3a6a673f9ad8e 100644 (file)
@@ -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);
   }