From 6716ecc393503b501793f4f921942fde1f417daa Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 21 Apr 2020 11:07:30 -0400 Subject: [PATCH] cls/rbd: added clean_since_snap_id to MirrorSnapshotNamespace It is only valid for primary snapshots so we can re-use the space previously used by the primary_snap_id without the need to bump the version id. Signed-off-by: Jason Dillaman (cherry picked from commit 50702eece0b1d7535d387bdf923b88cd4bbfee37) --- src/cls/rbd/cls_rbd_types.cc | 12 ++++++++---- src/cls/rbd/cls_rbd_types.h | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cls/rbd/cls_rbd_types.cc b/src/cls/rbd/cls_rbd_types.cc index 9071f3457fe5d..5f3c40b049f2f 100644 --- a/src/cls/rbd/cls_rbd_types.cc +++ b/src/cls/rbd/cls_rbd_types.cc @@ -767,10 +767,14 @@ void MirrorSnapshotNamespace::dump(Formatter *f) const { f->dump_string("mirror_peer_uuid", peer); } f->close_section(); - f->dump_string("primary_mirror_uuid", primary_mirror_uuid); - f->dump_unsigned("primary_snap_id", primary_snap_id); - f->dump_unsigned("last_copied_object_number", last_copied_object_number); - f->dump_stream("snap_seqs") << snap_seqs; + if (is_primary()) { + f->dump_unsigned("clean_since_snap_id", clean_since_snap_id); + } else { + f->dump_string("primary_mirror_uuid", primary_mirror_uuid); + f->dump_unsigned("primary_snap_id", primary_snap_id); + f->dump_unsigned("last_copied_object_number", last_copied_object_number); + f->dump_stream("snap_seqs") << snap_seqs; + } } class EncodeSnapshotNamespaceVisitor : public boost::static_visitor { diff --git a/src/cls/rbd/cls_rbd_types.h b/src/cls/rbd/cls_rbd_types.h index b2c155eb864a2..5ea37caf7d45c 100644 --- a/src/cls/rbd/cls_rbd_types.h +++ b/src/cls/rbd/cls_rbd_types.h @@ -545,7 +545,10 @@ struct MirrorSnapshotNamespace { std::set mirror_peer_uuids; std::string primary_mirror_uuid; - snapid_t primary_snap_id = CEPH_NOSNAP; + union { + snapid_t primary_snap_id = CEPH_NOSNAP; + snapid_t clean_since_snap_id; + }; uint64_t last_copied_object_number = 0; SnapSeqs snap_seqs; -- 2.39.5