From: Jason Dillaman Date: Fri, 7 Feb 2020 18:30:00 +0000 (-0500) Subject: librbd: only use snapshot namespace type in unique key sort X-Git-Tag: v15.1.1~350^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ecf71d301f339169321ae442c921da220d9a4dd9;p=ceph.git librbd: only use snapshot namespace type in unique key sort Don't use the internal snapshot namespace comparator since for the mirror snapshot the data can change. The important fact is that snapshot names should be unique within the namespace type. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 53d14452043b..e9132025d0fa 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -69,6 +69,17 @@ namespace librbd { } struct ImageCtx { + typedef std::pair SnapKey; + struct SnapKeyComparator { + inline bool operator()(const SnapKey& lhs, const SnapKey& rhs) const { + // only compare by namespace type and name + if (lhs.first.which() != rhs.first.which()) { + return lhs.first.which() < rhs.first.which(); + } + return lhs.second < rhs.second; + } + }; + static const string METADATA_CONF_PREFIX; CephContext *cct; @@ -81,7 +92,7 @@ namespace librbd { std::vector snaps; // this mirrors snapc.snaps, but is in // a format librados can understand std::map snap_info; - std::map, librados::snap_t> snap_ids; + std::map snap_ids; uint64_t open_snap_id = CEPH_NOSNAP; uint64_t snap_id; bool snap_exists; // false if our snap_id was deleted diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index 0e7616227134..870bbe08dcc8 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -230,7 +230,7 @@ struct MockImageCtx { ::SnapContext snapc; std::vector snaps; std::map snap_info; - std::map, librados::snap_t> snap_ids; + std::map snap_ids; bool old_format; bool read_only;