]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix issues with snapshot-based mirroring image state
authorJason Dillaman <dillaman@redhat.com>
Fri, 14 Feb 2020 14:34:35 +0000 (09:34 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 21 Feb 2020 14:03:09 +0000 (09:03 -0500)
There is no need to record the snapshot id within the SnapState structure
since that will duplicate the id. Additionally, the protection status wasn't
being decoded. Also includes some improvements to the debug formatting.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/mirror/snapshot/SetImageStateRequest.cc
src/librbd/mirror/snapshot/Types.cc
src/librbd/mirror/snapshot/Types.h

index 6c90a1614c5cd598239cca671ad52bc4a0089e19..55c2df6298106fa914301433b366fa33b81bdf2e 100644 (file)
@@ -130,7 +130,7 @@ void SetImageStateRequest<I>::handle_get_metadata(int r) {
       if (type == cls::rbd::SNAPSHOT_NAMESPACE_TYPE_MIRROR) {
         continue;
       }
-      m_image_state.snapshots[snap_id] = {snap_id, snap_info.snap_namespace,
+      m_image_state.snapshots[snap_id] = {snap_info.snap_namespace,
                                           snap_info.name,
                                           snap_info.protection_status};
     }
index 00232cbffbf5542ac29ea4738e0f3fcb091230f3..866b4c3e22bf05e8068ccec864a67aa6d9bc879e 100644 (file)
@@ -24,7 +24,6 @@ void ImageStateHeader::decode(bufferlist::const_iterator& bl) {
 
 void SnapState::encode(bufferlist& bl) const {
   ENCODE_START(1, 1, bl);
-  encode(id, bl);
   encode(snap_namespace, bl);
   encode(name, bl);
   encode(protection_status, bl);
@@ -33,14 +32,13 @@ void SnapState::encode(bufferlist& bl) const {
 
 void SnapState::decode(bufferlist::const_iterator& bl) {
   DECODE_START(1, bl);
-  decode(id, bl);
   decode(snap_namespace, bl);
   decode(name, bl);
+  decode(protection_status, bl);
   DECODE_FINISH(bl);
 }
 
 void SnapState::dump(Formatter *f) const {
-  f->dump_unsigned("id", id);
   f->open_object_section("namespace");
   snap_namespace.dump(f);
   f->close_section();
@@ -49,8 +47,11 @@ void SnapState::dump(Formatter *f) const {
 }
 
 std::ostream& operator<<(std::ostream& os, const SnapState& snap_state) {
-  os << "[" << snap_state.id << " " << snap_state.snap_namespace << " "
-     << snap_state.name << " " << snap_state.protection_status << "]";
+  os << "["
+     << "namespace=" << snap_state.snap_namespace << ", "
+     << "name=" << snap_state.name << ", "
+     << "protection=" << static_cast<int>(snap_state.protection_status)
+     << "]";
   return os;
 }
 
@@ -93,9 +94,13 @@ void ImageState::dump(Formatter *f) const {
 }
 
 std::ostream& operator<<(std::ostream& os, const ImageState& image_state) {
-  os << "[" << image_state.name << " " << image_state.features << " "
-     << image_state.snap_limit << " " << image_state.snapshots.size()
-     << " " << image_state.metadata.size() << "]";
+  os << "["
+     << "name=" << image_state.name << ", "
+     << "features=" << image_state.features << ", "
+     << "snap_limit=" << image_state.snap_limit << ", "
+     << "snaps=" << image_state.snapshots << ", "
+     << "metadata_count=" << image_state.metadata.size()
+     << "]";
   return os;
 }
 
index 1c35aea3307abccac222f67785d2335eaa12a116..79947a5f8aa8a34ad2dcdd55b259fe202c2b8453 100644 (file)
@@ -36,28 +36,24 @@ struct ImageStateHeader {
 WRITE_CLASS_ENCODER(ImageStateHeader);
 
 struct SnapState {
-  uint64_t id = CEPH_NOSNAP;
   cls::rbd::SnapshotNamespace snap_namespace;
   std::string name;
   uint8_t protection_status = 0;
 
   SnapState() {
   }
-  SnapState(uint64_t id, const cls::rbd::SnapshotNamespace &snap_namespace,
+  SnapState(const cls::rbd::SnapshotNamespace &snap_namespace,
             const std::string &name, uint8_t protection_status)
-    : id(id), snap_namespace(snap_namespace), name(name),
+    : snap_namespace(snap_namespace), name(name),
       protection_status(protection_status) {
   }
 
   bool operator==(const SnapState& rhs) const {
-    return id == rhs.id && snap_namespace == rhs.snap_namespace &&
+    return snap_namespace == rhs.snap_namespace &&
            name == rhs.name && protection_status == rhs.protection_status;
   }
 
   bool operator<(const SnapState& rhs) const {
-    if (id != rhs.id) {
-      return id < rhs.id;
-    }
     if (snap_namespace != rhs.snap_namespace) {
       return snap_namespace < rhs.snap_namespace;
     }