diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index 6c22256fd0d..9f38c043a25 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -2326,8 +2326,8 @@ int snapshot_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return -EINVAL; } - if (boost::get( - &snap_meta.snapshot_namespace) != nullptr) { + if (std::holds_alternative( + snap_meta.snapshot_namespace)) { CLS_ERR("Unknown snapshot namespace provided"); return -EINVAL; } @@ -5708,7 +5708,7 @@ int image_snapshot_unlink_peer(cls_method_context_t hctx, return r; } - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &snap.snapshot_namespace); if (mirror_ns == nullptr) { CLS_LOG(5, "mirror_image_snapshot_unlink_peer " \ @@ -5726,8 +5726,8 @@ int image_snapshot_unlink_peer(cls_method_context_t hctx, // should remove the snapshot instead. auto search_lambda = [snap_id](const cls_rbd_snap& snap_meta) { if (snap_meta.id > snap_id && - boost::get( - &snap_meta.snapshot_namespace) != nullptr) { + std::holds_alternative( + snap_meta.snapshot_namespace)) { return -EEXIST; } return 0; @@ -5763,7 +5763,7 @@ int image_snapshot_set_copy_progress(cls_method_context_t hctx, return r; } - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &snap.snapshot_namespace); if (mirror_ns == nullptr) { CLS_LOG(5, "mirror_image_snapshot_set_copy_progress " \ diff --git a/src/cls/rbd/cls_rbd_types.cc b/src/cls/rbd/cls_rbd_types.cc index ce424f7c36a..b3fc67cf081 100644 --- a/src/cls/rbd/cls_rbd_types.cc +++ b/src/cls/rbd/cls_rbd_types.cc @@ -784,7 +784,7 @@ void MirrorSnapshotNamespace::dump(Formatter *f) const { } } -class EncodeSnapshotNamespaceVisitor : public boost::static_visitor { +class EncodeSnapshotNamespaceVisitor { public: explicit EncodeSnapshotNamespaceVisitor(bufferlist &bl) : m_bl(bl) { } @@ -800,7 +800,7 @@ private: bufferlist &m_bl; }; -class DecodeSnapshotNamespaceVisitor : public boost::static_visitor { +class DecodeSnapshotNamespaceVisitor { public: DecodeSnapshotNamespaceVisitor(bufferlist::const_iterator &iter) : m_iter(iter) { @@ -814,7 +814,7 @@ private: bufferlist::const_iterator &m_iter; }; -class DumpSnapshotNamespaceVisitor : public boost::static_visitor { +class DumpSnapshotNamespaceVisitor { public: explicit DumpSnapshotNamespaceVisitor(Formatter *formatter, const std::string &key) : m_formatter(formatter), m_key(key) {} @@ -830,7 +830,7 @@ private: std::string m_key; }; -class GetTypeVisitor : public boost::static_visitor { +class GetTypeVisitor { public: template inline SnapshotNamespaceType operator()(const T&) const { @@ -840,8 +840,8 @@ public: SnapshotNamespaceType get_snap_namespace_type( const SnapshotNamespace& snapshot_namespace) { - return static_cast(boost::apply_visitor( - GetTypeVisitor(), snapshot_namespace)); + return static_cast(snapshot_namespace.visit( + GetTypeVisitor())); } void SnapshotInfo::encode(bufferlist& bl) const { @@ -869,8 +869,7 @@ void SnapshotInfo::decode(bufferlist::const_iterator& it) { void SnapshotInfo::dump(Formatter *f) const { f->dump_unsigned("id", id); f->open_object_section("namespace"); - boost::apply_visitor(DumpSnapshotNamespaceVisitor(f, "type"), - snapshot_namespace); + snapshot_namespace.visit(DumpSnapshotNamespaceVisitor(f, "type")); f->close_section(); f->dump_string("name", name); f->dump_unsigned("image_size", image_size); @@ -899,7 +898,7 @@ void SnapshotInfo::generate_test_instances(std::list &o) { void SnapshotNamespace::encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); - boost::apply_visitor(EncodeSnapshotNamespaceVisitor(bl), *this); + visit(EncodeSnapshotNamespaceVisitor(bl)); ENCODE_FINISH(bl); } @@ -925,13 +924,12 @@ void SnapshotNamespace::decode(bufferlist::const_iterator &p) *this = UnknownSnapshotNamespace(); break; } - boost::apply_visitor(DecodeSnapshotNamespaceVisitor(p), *this); + visit(DecodeSnapshotNamespaceVisitor(p)); DECODE_FINISH(p); } void SnapshotNamespace::dump(Formatter *f) const { - boost::apply_visitor( - DumpSnapshotNamespaceVisitor(f, "snapshot_namespace_type"), *this); + visit(DumpSnapshotNamespaceVisitor(f, "snapshot_namespace_type")); } void SnapshotNamespace::generate_test_instances(std::list &o) { @@ -955,6 +953,12 @@ void SnapshotNamespace::generate_test_instances(std::list &o "uuid", 123))); } +std::ostream& operator<<(std::ostream& os, const SnapshotNamespace& ns) { + return ns.visit([&os](const auto& val) -> std::ostream& { + return os << val; + }); +} + std::ostream& operator<<(std::ostream& os, const SnapshotNamespaceType& type) { switch (type) { case SNAPSHOT_NAMESPACE_TYPE_USER: diff --git a/src/cls/rbd/cls_rbd_types.h b/src/cls/rbd/cls_rbd_types.h index 645861b2d8f..c8d2cb871e4 100644 --- a/src/cls/rbd/cls_rbd_types.h +++ b/src/cls/rbd/cls_rbd_types.h @@ -4,7 +4,6 @@ #ifndef CEPH_CLS_RBD_TYPES_H #define CEPH_CLS_RBD_TYPES_H -#include #include "include/int_types.h" #include "include/buffer.h" #include "include/encoding.h" @@ -14,6 +13,7 @@ #include #include #include +#include #define RBD_GROUP_REF "rbd_group_ref" @@ -442,6 +442,10 @@ struct UserSnapshotNamespace { return true; } + inline bool operator!=(const UserSnapshotNamespace& usn) const { + return false; + } + inline bool operator<(const UserSnapshotNamespace& usn) const { return false; } @@ -474,6 +478,10 @@ struct GroupSnapshotNamespace { group_snapshot_id == gsn.group_snapshot_id; } + inline bool operator!=(const GroupSnapshotNamespace& gsn) const { + return !operator==(gsn); + } + inline bool operator<(const GroupSnapshotNamespace& gsn) const { if (group_pool != gsn.group_pool) { return group_pool < gsn.group_pool; @@ -506,6 +514,9 @@ struct TrashSnapshotNamespace { inline bool operator==(const TrashSnapshotNamespace& usn) const { return true; } + inline bool operator!=(const TrashSnapshotNamespace& usn) const { + return false; + } inline bool operator<(const TrashSnapshotNamespace& usn) const { return false; } @@ -611,6 +622,10 @@ struct MirrorSnapshotNamespace { snap_seqs == rhs.snap_seqs; } + inline bool operator!=(const MirrorSnapshotNamespace& rhs) const { + return !operator==(rhs); + } + inline bool operator<(const MirrorSnapshotNamespace& rhs) const { if (state != rhs.state) { return state < rhs.state; @@ -644,6 +659,10 @@ struct UnknownSnapshotNamespace { return true; } + inline bool operator!=(const UnknownSnapshotNamespace& gsn) const { + return false; + } + inline bool operator<(const UnknownSnapshotNamespace& gsn) const { return false; } @@ -656,38 +675,33 @@ std::ostream& operator<<(std::ostream& os, const TrashSnapshotNamespace& ns); std::ostream& operator<<(std::ostream& os, const MirrorSnapshotNamespace& ns); std::ostream& operator<<(std::ostream& os, const UnknownSnapshotNamespace& ns); -typedef boost::variant SnapshotNamespaceVariant; +typedef std::variant SnapshotNamespaceVariant; struct SnapshotNamespace : public SnapshotNamespaceVariant { - SnapshotNamespace() { - } - - template - SnapshotNamespace(T&& t) : SnapshotNamespaceVariant(std::forward(t)) { - } + using SnapshotNamespaceVariant::SnapshotNamespaceVariant; void encode(ceph::buffer::list& bl) const; void decode(ceph::buffer::list::const_iterator& it); void dump(ceph::Formatter *f) const; + template + decltype(auto) visit(F&& f) const & { + return std::visit(std::forward(f), static_cast(*this)); + } + template + decltype(auto) visit(F&& f) & { + return std::visit(std::forward(f), static_cast(*this)); + } static void generate_test_instances(std::list &o); - - inline bool operator==(const SnapshotNamespaceVariant& sn) const { - return static_cast(*this) == sn; - } - inline bool operator<(const SnapshotNamespaceVariant& sn) const { - return static_cast(*this) < sn; - } - inline bool operator!=(const SnapshotNamespaceVariant& sn) const { - return !(*this == sn); - } }; WRITE_CLASS_ENCODER(SnapshotNamespace); +std::ostream& operator<<(std::ostream& os, const SnapshotNamespace& ns); + SnapshotNamespaceType get_snap_namespace_type( const SnapshotNamespace& snapshot_namespace); @@ -871,6 +885,7 @@ struct TrashImageSpec { deferment_end_time == rhs.deferment_end_time); } }; + WRITE_CLASS_ENCODER(TrashImageSpec); struct MirrorImageMap { diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 729b962be4f..d8887f9af8d 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -75,8 +75,8 @@ namespace librbd { 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(); + if (lhs.first.index() != rhs.first.index()) { + return lhs.first.index() < rhs.first.index(); } return lhs.second < rhs.second; } diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index f4fdc54b90d..f8e47a8dfd3 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -1150,7 +1150,7 @@ bool ImageWatcher::handle_payload(const SnapCreatePayload &payload, auto request_type = exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL; // rbd-mirror needs to accept forced promotion orphan snap create requests - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &payload.snap_namespace); if (mirror_ns != nullptr && mirror_ns->is_orphan()) { request_type = exclusive_lock::OPERATION_REQUEST_TYPE_FORCE_PROMOTION; diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index cb6b44e8d5a..e5f3da69cb4 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -45,8 +45,8 @@ snap_t get_group_snap_id(I* ictx, for (; it != ictx->snap_ids.end(); ++it) { if (it->first.first == in_snap_namespace) { return it->second; - } else if (boost::get(&it->first.first) == - nullptr) { + } else if (!std::holds_alternative( + it->first.first)) { break; } } diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index 51716ff3698..3ae98ea73b2 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -1610,7 +1610,7 @@ int Mirror::peer_site_remove(librados::IoCtx& io_ctx, { std::shared_lock image_locker{img_ctx->image_lock}; for (auto &it : img_ctx->snap_info) { - auto info = boost::get( + auto info = std::get_if( &it.second.snap_namespace); if (info && info->mirror_peer_uuids.count(uuid)) { snap_ids.push_back(it.first); diff --git a/src/librbd/api/Snapshot.cc b/src/librbd/api/Snapshot.cc index c175808bdc2..03cefbd1c0a 100644 --- a/src/librbd/api/Snapshot.cc +++ b/src/librbd/api/Snapshot.cc @@ -26,7 +26,7 @@ namespace api { namespace { -class GetGroupVisitor : public boost::static_visitor { +class GetGroupVisitor { public: CephContext* cct; librados::IoCtx *image_ioctx; @@ -80,7 +80,7 @@ public: } }; -class GetTrashVisitor : public boost::static_visitor { +class GetTrashVisitor { public: std::string* original_name; @@ -100,7 +100,7 @@ public: } }; -class GetMirrorVisitor : public boost::static_visitor { +class GetMirrorVisitor { public: snap_mirror_namespace_t *mirror_snap; @@ -143,7 +143,7 @@ int Snapshot::get_group_namespace(I *ictx, uint64_t snap_id, } GetGroupVisitor ggv = GetGroupVisitor(ictx->cct, &ictx->md_ctx, group_snap); - r = boost::apply_visitor(ggv, snap_info->snap_namespace); + r = snap_info->snap_namespace.visit(ggv); if (r < 0) { return r; } @@ -166,7 +166,7 @@ int Snapshot::get_trash_namespace(I *ictx, uint64_t snap_id, } auto visitor = GetTrashVisitor(original_name); - r = boost::apply_visitor(visitor, snap_info->snap_namespace); + r = snap_info->snap_namespace.visit(visitor); if (r < 0) { return r; } @@ -189,7 +189,7 @@ int Snapshot::get_mirror_namespace( } auto gmv = GetMirrorVisitor(mirror_snap); - r = boost::apply_visitor(gmv, snap_info->snap_namespace); + r = snap_info->snap_namespace.visit(gmv); if (r < 0) { return r; } diff --git a/src/librbd/deep_copy/SnapshotCopyRequest.cc b/src/librbd/deep_copy/SnapshotCopyRequest.cc index 9ff02644de9..1aadd34db36 100644 --- a/src/librbd/deep_copy/SnapshotCopyRequest.cc +++ b/src/librbd/deep_copy/SnapshotCopyRequest.cc @@ -257,8 +257,7 @@ void SnapshotCopyRequest::send_snap_remove() { return; } - if (boost::get(&snap_namespace) == - nullptr) { + if (!std::holds_alternative(snap_namespace)) { continue; } @@ -347,8 +346,7 @@ void SnapshotCopyRequest::send_snap_create() { if (m_snap_seqs.find(src_snap_id) == m_snap_seqs.end()) { // the source snapshot is not in our mapping table, ... - if (boost::get(&snap_namespace) != - nullptr) { + if (std::holds_alternative(snap_namespace)) { // ... create it since it's a user snapshot break; } else if (src_snap_id == m_src_snap_id_end) { diff --git a/src/librbd/mirror/GetInfoRequest.cc b/src/librbd/mirror/GetInfoRequest.cc index a7ee6456704..2db8aaa84c5 100644 --- a/src/librbd/mirror/GetInfoRequest.cc +++ b/src/librbd/mirror/GetInfoRequest.cc @@ -259,7 +259,7 @@ void GetInfoRequest::calc_promotion_state( *m_primary_mirror_uuid = ""; for (auto it = snap_info.rbegin(); it != snap_info.rend(); it++) { - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &it->second.snap_namespace); if (mirror_ns != nullptr) { diff --git a/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc b/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc index 13f7894156e..9f8317ed936 100644 --- a/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc +++ b/src/librbd/mirror/snapshot/CreatePrimaryRequest.cc @@ -194,7 +194,7 @@ void CreatePrimaryRequest::unlink_peer() { size_t count = 0; uint64_t unlink_snap_id = 0; for (auto &snap_it : m_image_ctx->snap_info) { - auto info = boost::get( + auto info = std::get_if( &snap_it.second.snap_namespace); if (info == nullptr) { continue; diff --git a/src/librbd/mirror/snapshot/UnlinkPeerRequest.cc b/src/librbd/mirror/snapshot/UnlinkPeerRequest.cc index 6e188424936..b28591c00e8 100644 --- a/src/librbd/mirror/snapshot/UnlinkPeerRequest.cc +++ b/src/librbd/mirror/snapshot/UnlinkPeerRequest.cc @@ -68,10 +68,10 @@ void UnlinkPeerRequest::unlink_peer() { snap_it != m_image_ctx->snap_info.end(); ++snap_it) { if (snap_it->first == m_snap_id) { r = 0; - mirror_ns = boost::get( + mirror_ns = std::get_if( &snap_it->second.snap_namespace); - } else if (boost::get( - &snap_it->second.snap_namespace) != nullptr) { + } else if (std::holds_alternative( + snap_it->second.snap_namespace)) { ldout(cct, 15) << "located newer mirror snapshot" << dendl; m_newer_mirror_snapshots = true; break; @@ -186,7 +186,7 @@ void UnlinkPeerRequest::remove_snapshot() { return; } - auto info = boost::get( + auto info = std::get( snap_namespace); info.mirror_peer_uuids.erase(m_mirror_peer_uuid); diff --git a/src/librbd/mirror/snapshot/Utils.cc b/src/librbd/mirror/snapshot/Utils.cc index ecf884b54c4..36d1558be43 100644 --- a/src/librbd/mirror/snapshot/Utils.cc +++ b/src/librbd/mirror/snapshot/Utils.cc @@ -28,12 +28,12 @@ bool get_rollback_snap_id( uint64_t *rollback_snap_id) { for (; it != end; it++) { - auto mirror_ns = boost::get( - &it->second.snap_namespace); - if (mirror_ns->state != cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY) { + auto mirror_ns = std::get( + it->second.snap_namespace); + if (mirror_ns.state != cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY) { break; } - if (mirror_ns->complete) { + if (mirror_ns.complete) { break; } } @@ -69,7 +69,7 @@ bool can_create_primary_snapshot(I *image_ctx, bool demoted, bool force, for (auto it = image_ctx->snap_info.rbegin(); it != image_ctx->snap_info.rend(); it++) { - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &it->second.snap_namespace); if (mirror_ns == nullptr) { continue; @@ -133,7 +133,7 @@ bool can_create_non_primary_snapshot(I *image_ctx) { for (auto it = image_ctx->snap_info.rbegin(); it != image_ctx->snap_info.rend(); it++) { - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &it->second.snap_namespace); if (mirror_ns != nullptr) { ldout(cct, 20) << "previous mirror snapshot snap_id=" << it->first << " " diff --git a/src/librbd/operation/SnapshotCreateRequest.cc b/src/librbd/operation/SnapshotCreateRequest.cc index 866ef7d6101..8cea35d2f03 100644 --- a/src/librbd/operation/SnapshotCreateRequest.cc +++ b/src/librbd/operation/SnapshotCreateRequest.cc @@ -298,7 +298,7 @@ Context *SnapshotCreateRequest::handle_create_object_map(int *result) { template Context *SnapshotCreateRequest::send_create_image_state() { I &image_ctx = this->m_image_ctx; - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &m_snap_namespace); if (mirror_ns == nullptr || !mirror_ns->is_primary()) { update_snap_context(); diff --git a/src/test/cls_rbd/test_cls_rbd.cc b/src/test/cls_rbd/test_cls_rbd.cc index 5b335974556..aa6ca0ee249 100644 --- a/src/test/cls_rbd/test_cls_rbd.cc +++ b/src/test/cls_rbd/test_cls_rbd.cc @@ -2256,7 +2256,7 @@ TEST_F(TestClsRbd, mirror_snapshot) { cls::rbd::SnapshotInfo snap; ASSERT_EQ(0, snapshot_get(&ioctx, oid, 1, &snap)); - auto sn = boost::get( + auto sn = std::get_if( &snap.snapshot_namespace); ASSERT_NE(nullptr, sn); ASSERT_EQ(primary, *sn); @@ -2269,7 +2269,7 @@ TEST_F(TestClsRbd, mirror_snapshot) { ASSERT_EQ(-ENOENT, mirror_image_snapshot_unlink_peer(&ioctx, oid, 1, "peer1")); ASSERT_EQ(0, snapshot_get(&ioctx, oid, 1, &snap)); - sn = boost::get( + sn = std::get_if( &snap.snapshot_namespace); ASSERT_NE(nullptr, sn); ASSERT_EQ(1U, sn->mirror_peer_uuids.size()); @@ -2278,14 +2278,14 @@ TEST_F(TestClsRbd, mirror_snapshot) { ASSERT_EQ(-ERESTART, mirror_image_snapshot_unlink_peer(&ioctx, oid, 1, "peer2")); ASSERT_EQ(0, snapshot_get(&ioctx, oid, 1, &snap)); - sn = boost::get( + sn = std::get_if( &snap.snapshot_namespace); ASSERT_NE(nullptr, sn); ASSERT_EQ(1U, sn->mirror_peer_uuids.size()); ASSERT_EQ(1U, sn->mirror_peer_uuids.count("peer2")); ASSERT_EQ(0, snapshot_get(&ioctx, oid, 2, &snap)); - auto nsn = boost::get( + auto nsn = std::get_if( &snap.snapshot_namespace); ASSERT_NE(nullptr, nsn); ASSERT_EQ(non_primary, *nsn); @@ -2297,7 +2297,7 @@ TEST_F(TestClsRbd, mirror_snapshot) { ASSERT_EQ(0, mirror_image_snapshot_set_copy_progress(&ioctx, oid, 2, true, 10)); ASSERT_EQ(0, snapshot_get(&ioctx, oid, 2, &snap)); - nsn = boost::get( + nsn = std::get_if( &snap.snapshot_namespace); ASSERT_NE(nullptr, nsn); ASSERT_TRUE(nsn->complete); diff --git a/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc b/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc index 6a52898220a..0190c338ab0 100644 --- a/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc +++ b/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc @@ -252,8 +252,7 @@ public: } if (protect) { - EXPECT_TRUE(boost::get(&snap_ns) != - nullptr); + EXPECT_TRUE(std::holds_alternative(snap_ns)); r = image_ctx->operations->snap_protect(snap_ns, snap_name.c_str()); if (r < 0) { return r; diff --git a/src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc b/src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc index 95b25ffa12f..bf4d7974438 100644 --- a/src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc +++ b/src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc @@ -178,7 +178,7 @@ public: auto it = mock_image_ctx.snap_info.find(snap_id); ASSERT_NE(it, mock_image_ctx.snap_info.end()); auto info = - boost::get( + std::get_if( &it->second.snap_namespace); ASSERT_NE(nullptr, info); ASSERT_EQ(is_linked, info->mirror_peer_uuids.erase( diff --git a/src/test/librbd/mirror/snapshot/test_mock_UnlinkPeerRequest.cc b/src/test/librbd/mirror/snapshot/test_mock_UnlinkPeerRequest.cc index 456b6ccdca1..eebd9fd8181 100644 --- a/src/test/librbd/mirror/snapshot/test_mock_UnlinkPeerRequest.cc +++ b/src/test/librbd/mirror/snapshot/test_mock_UnlinkPeerRequest.cc @@ -91,7 +91,7 @@ public: auto it = mock_image_ctx.snap_info.find(snap_id); EXPECT_NE(it, mock_image_ctx.snap_info.end()); auto info = - boost::get( + std::get_if( &it->second.snap_namespace); EXPECT_NE(nullptr, info); EXPECT_NE(0, info->mirror_peer_uuids.erase( diff --git a/src/test/rbd_mirror/test_ImageReplayer.cc b/src/test/rbd_mirror/test_ImageReplayer.cc index dcb74fdb61b..abe163cfd69 100644 --- a/src/test/rbd_mirror/test_ImageReplayer.cc +++ b/src/test/rbd_mirror/test_ImageReplayer.cc @@ -393,7 +393,7 @@ public: return r; } - auto ns = boost::get( + auto ns = std::get_if( &snap_info.snapshot_namespace); if (ns != nullptr) { *mirror_snap_id = snap_id; diff --git a/src/tools/rbd_mirror/image_replayer/snapshot/ApplyImageStateRequest.cc b/src/tools/rbd_mirror/image_replayer/snapshot/ApplyImageStateRequest.cc index 2ed3217388f..75881307cee 100644 --- a/src/tools/rbd_mirror/image_replayer/snapshot/ApplyImageStateRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/snapshot/ApplyImageStateRequest.cc @@ -238,7 +238,7 @@ void ApplyImageStateRequest::unprotect_snapshot() { auto snap_id = snap_it->first; const auto& snap_info = snap_it->second; - auto user_ns = boost::get( + auto user_ns = std::get_if( &snap_info.snap_namespace); if (user_ns == nullptr) { dout(20) << "snapshot " << snap_id << " is not a user snapshot" << dendl; @@ -324,7 +324,7 @@ void ApplyImageStateRequest::remove_snapshot() { auto snap_id = snap_it->first; const auto& snap_info = snap_it->second; - auto user_ns = boost::get( + auto user_ns = std::get_if( &snap_info.snap_namespace); if (user_ns == nullptr) { dout(20) << "snapshot " << snap_id << " is not a user snapshot" << dendl; @@ -398,7 +398,7 @@ void ApplyImageStateRequest::protect_snapshot() { auto snap_id = snap_it->first; const auto& snap_info = snap_it->second; - auto user_ns = boost::get( + auto user_ns = std::get_if( &snap_info.snap_namespace); if (user_ns == nullptr) { dout(20) << "snapshot " << snap_id << " is not a user snapshot" << dendl; @@ -484,7 +484,7 @@ void ApplyImageStateRequest::rename_snapshot() { auto snap_id = snap_it->first; const auto& snap_info = snap_it->second; - auto user_ns = boost::get( + auto user_ns = std::get_if( &snap_info.snap_namespace); if (user_ns == nullptr) { dout(20) << "snapshot " << snap_id << " is not a user snapshot" << dendl; @@ -608,7 +608,7 @@ uint64_t ApplyImageStateRequest::compute_remote_snap_id( for (auto snap_it = m_remote_image_ctx->snap_info.begin(); snap_it != m_remote_image_ctx->snap_info.end(); ++snap_it) { auto snap_id = snap_it->first; - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &snap_it->second.snap_namespace); if (mirror_ns == nullptr || !mirror_ns->is_non_primary()) { continue; diff --git a/src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc b/src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc index e94ec71dfe2..60996bb864e 100644 --- a/src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc +++ b/src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc @@ -58,7 +58,7 @@ std::pair get_newest_mirror_snapshot( for (auto snap_info_it = image_ctx->snap_info.rbegin(); snap_info_it != image_ctx->snap_info.rend(); ++snap_info_it) { const auto& snap_ns = snap_info_it->second.snap_namespace; - auto mirror_ns = boost::get< + auto mirror_ns = std::get_if< cls::rbd::MirrorSnapshotNamespace>(&snap_ns); if (mirror_ns == nullptr || !mirror_ns->complete) { continue; @@ -446,7 +446,7 @@ void Replayer::scan_local_mirror_snapshots( for (auto snap_info_it = local_image_ctx->snap_info.begin(); snap_info_it != local_image_ctx->snap_info.end(); ++snap_info_it) { const auto& snap_ns = snap_info_it->second.snap_namespace; - auto mirror_ns = boost::get< + auto mirror_ns = std::get_if< cls::rbd::MirrorSnapshotNamespace>(&snap_ns); if (mirror_ns == nullptr) { continue; @@ -576,7 +576,7 @@ void Replayer::scan_remote_mirror_snapshots( for (auto snap_info_it = remote_image_ctx->snap_info.begin(); snap_info_it != remote_image_ctx->snap_info.end(); ++snap_info_it) { const auto& snap_ns = snap_info_it->second.snap_namespace; - auto mirror_ns = boost::get< + auto mirror_ns = std::get_if< cls::rbd::MirrorSnapshotNamespace>(&snap_ns); if (mirror_ns == nullptr) { continue; @@ -768,8 +768,8 @@ void Replayer::prune_non_primary_snapshot(uint64_t snap_id) { snap_namespace = snap_info->snap_namespace; snap_name = snap_info->name; - ceph_assert(boost::get( - &snap_namespace) != nullptr); + ceph_assert(std::holds_alternative( + snap_namespace)); } } @@ -913,7 +913,7 @@ void Replayer::create_non_primary_snapshot() { return; } - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &local_snap_info_it->second.snap_namespace); ceph_assert(mirror_ns != nullptr); @@ -930,8 +930,8 @@ void Replayer::create_non_primary_snapshot() { // we can ignore all non-user snapshots since image state only includes // user snapshots - if (boost::get( - &remote_snap_info.snap_namespace) == nullptr) { + if (!std::holds_alternative( + remote_snap_info.snap_namespace)) { continue; } diff --git a/src/tools/rbd_mirror/image_replayer/snapshot/Utils.cc b/src/tools/rbd_mirror/image_replayer/snapshot/Utils.cc index 7c20410cbc3..6df95d300e3 100644 --- a/src/tools/rbd_mirror/image_replayer/snapshot/Utils.cc +++ b/src/tools/rbd_mirror/image_replayer/snapshot/Utils.cc @@ -29,7 +29,7 @@ uint64_t compute_remote_snap_id( // come at or after the snapshot we are searching against for (auto snap_it = local_snap_infos.lower_bound(local_snap_id); snap_it != local_snap_infos.end(); ++snap_it) { - auto mirror_ns = boost::get( + auto mirror_ns = std::get_if( &snap_it->second.snap_namespace); if (mirror_ns == nullptr || !mirror_ns->is_non_primary()) { continue;