From: Jason Dillaman Date: Fri, 14 Feb 2020 14:34:35 +0000 (-0500) Subject: librbd: fix issues with snapshot-based mirroring image state X-Git-Tag: v15.1.1~298^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1b18c067b769b02635ded5fb2f51544075df1877;p=ceph.git librbd: fix issues with snapshot-based mirroring image state 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 --- diff --git a/src/librbd/mirror/snapshot/SetImageStateRequest.cc b/src/librbd/mirror/snapshot/SetImageStateRequest.cc index 6c90a1614c5c..55c2df629810 100644 --- a/src/librbd/mirror/snapshot/SetImageStateRequest.cc +++ b/src/librbd/mirror/snapshot/SetImageStateRequest.cc @@ -130,7 +130,7 @@ void SetImageStateRequest::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}; } diff --git a/src/librbd/mirror/snapshot/Types.cc b/src/librbd/mirror/snapshot/Types.cc index 00232cbffbf5..866b4c3e22bf 100644 --- a/src/librbd/mirror/snapshot/Types.cc +++ b/src/librbd/mirror/snapshot/Types.cc @@ -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(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; } diff --git a/src/librbd/mirror/snapshot/Types.h b/src/librbd/mirror/snapshot/Types.h index 1c35aea3307a..79947a5f8aa8 100644 --- a/src/librbd/mirror/snapshot/Types.h +++ b/src/librbd/mirror/snapshot/Types.h @@ -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; }