From 6044485fe95f33272b41a245df33b08fb6da0ffc Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Wed, 23 Jun 2021 17:56:20 +0100 Subject: [PATCH] cls/rbd: rename GroupSnapshotNamespace to GroupImageSnapshotNamespace Signed-off-by: Mykola Golub Signed-off-by: Prasanna Kumar Kalever --- src/cls/rbd/cls_rbd_types.cc | 26 ++++++++++++++++---------- src/cls/rbd/cls_rbd_types.h | 20 ++++++++++---------- src/librbd/api/Group.cc | 16 ++++++++-------- src/librbd/api/Snapshot.cc | 4 ++-- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/cls/rbd/cls_rbd_types.cc b/src/cls/rbd/cls_rbd_types.cc index 1fdfbd0f63e0c..5d8edb509ef99 100644 --- a/src/cls/rbd/cls_rbd_types.cc +++ b/src/cls/rbd/cls_rbd_types.cc @@ -708,21 +708,26 @@ void GroupSpec::generate_test_instances(std::list &o) { o.push_back(new GroupSpec("1018643c9869", 3)); } -void GroupSnapshotNamespace::encode(bufferlist& bl) const { +std::ostream& operator<<(std::ostream& os, const GroupSpec& gs) { + os << "{pool_id=" << gs.pool_id << ", group_id=" << gs.group_id << "}"; + return os; +} + +void GroupImageSnapshotNamespace::encode(bufferlist& bl) const { using ceph::encode; encode(group_pool, bl); encode(group_id, bl); encode(group_snapshot_id, bl); } -void GroupSnapshotNamespace::decode(bufferlist::const_iterator& it) { +void GroupImageSnapshotNamespace::decode(bufferlist::const_iterator& it) { using ceph::decode; decode(group_pool, it); decode(group_id, it); decode(group_snapshot_id, it); } -void GroupSnapshotNamespace::dump(Formatter *f) const { +void GroupImageSnapshotNamespace::dump(Formatter *f) const { f->dump_int("group_pool", group_pool); f->dump_string("group_id", group_id); f->dump_string("group_snapshot_id", group_snapshot_id); @@ -885,7 +890,7 @@ void SnapshotInfo::generate_test_instances(std::list &o) { o.push_back(new SnapshotInfo(1ULL, UserSnapshotNamespace{}, "snap1", 123, {123456, 0}, 12)); o.push_back(new SnapshotInfo(2ULL, - GroupSnapshotNamespace{567, "group1", "snap1"}, + GroupImageSnapshotNamespace{567, "group1", "snap1"}, "snap1", 123, {123456, 0}, 987)); o.push_back(new SnapshotInfo(3ULL, TrashSnapshotNamespace{ @@ -917,7 +922,7 @@ void SnapshotNamespace::decode(bufferlist::const_iterator &p) *this = UserSnapshotNamespace(); break; case cls::rbd::SNAPSHOT_NAMESPACE_TYPE_GROUP: - *this = GroupSnapshotNamespace(); + *this = GroupImageSnapshotNamespace(); break; case cls::rbd::SNAPSHOT_NAMESPACE_TYPE_TRASH: *this = TrashSnapshotNamespace(); @@ -939,10 +944,10 @@ void SnapshotNamespace::dump(Formatter *f) const { void SnapshotNamespace::generate_test_instances(std::list &o) { o.push_back(new SnapshotNamespace(UserSnapshotNamespace())); - o.push_back(new SnapshotNamespace(GroupSnapshotNamespace(0, "10152ae8944a", - "2118643c9732"))); - o.push_back(new SnapshotNamespace(GroupSnapshotNamespace(5, "1018643c9869", - "33352be8933c"))); + o.push_back(new SnapshotNamespace(GroupImageSnapshotNamespace(0, "10152ae8944a", + "2118643c9732"))); + o.push_back(new SnapshotNamespace(GroupImageSnapshotNamespace(5, "1018643c9869", + "33352be8933c"))); o.push_back(new SnapshotNamespace(TrashSnapshotNamespace())); o.push_back(new SnapshotNamespace(MirrorSnapshotNamespace(MIRROR_SNAPSHOT_STATE_PRIMARY, {"peer uuid"}, @@ -990,7 +995,8 @@ std::ostream& operator<<(std::ostream& os, const UserSnapshotNamespace& ns) { return os; } -std::ostream& operator<<(std::ostream& os, const GroupSnapshotNamespace& ns) { +std::ostream& operator<<(std::ostream& os, + const GroupImageSnapshotNamespace& ns) { os << "[" << SNAPSHOT_NAMESPACE_TYPE_GROUP << " " << "group_pool=" << ns.group_pool << ", " << "group_id=" << ns.group_id << ", " diff --git a/src/cls/rbd/cls_rbd_types.h b/src/cls/rbd/cls_rbd_types.h index d5f65abd75f44..2f80718207ba8 100644 --- a/src/cls/rbd/cls_rbd_types.h +++ b/src/cls/rbd/cls_rbd_types.h @@ -455,15 +455,15 @@ struct UserSnapshotNamespace { } }; -struct GroupSnapshotNamespace { +struct GroupImageSnapshotNamespace { static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE = SNAPSHOT_NAMESPACE_TYPE_GROUP; - GroupSnapshotNamespace() {} + GroupImageSnapshotNamespace() {} - GroupSnapshotNamespace(int64_t _group_pool, - const std::string &_group_id, - const std::string &_group_snapshot_id) + GroupImageSnapshotNamespace(int64_t _group_pool, + const std::string &_group_id, + const std::string &_group_snapshot_id) : group_id(_group_id), group_pool(_group_pool), group_snapshot_id(_group_snapshot_id) {} @@ -476,17 +476,17 @@ struct GroupSnapshotNamespace { void dump(ceph::Formatter *f) const; - inline bool operator==(const GroupSnapshotNamespace& gsn) const { + inline bool operator==(const GroupImageSnapshotNamespace& gsn) const { return group_pool == gsn.group_pool && group_id == gsn.group_id && group_snapshot_id == gsn.group_snapshot_id; } - inline bool operator!=(const GroupSnapshotNamespace& gsn) const { + inline bool operator!=(const GroupImageSnapshotNamespace& gsn) const { return !operator==(gsn); } - inline bool operator<(const GroupSnapshotNamespace& gsn) const { + inline bool operator<(const GroupImageSnapshotNamespace& gsn) const { if (group_pool != gsn.group_pool) { return group_pool < gsn.group_pool; } @@ -674,13 +674,13 @@ struct UnknownSnapshotNamespace { std::ostream& operator<<(std::ostream& os, const SnapshotNamespaceType& type); std::ostream& operator<<(std::ostream& os, const UserSnapshotNamespace& ns); -std::ostream& operator<<(std::ostream& os, const GroupSnapshotNamespace& ns); +std::ostream& operator<<(std::ostream& os, const GroupImageSnapshotNamespace& ns); 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 std::variant SnapshotNamespaceVariant; diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index 22e3ba86757da..b95173d2b0763 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -43,12 +43,12 @@ template snap_t get_group_snap_id(I* ictx, const cls::rbd::SnapshotNamespace& in_snap_namespace) { ceph_assert(ceph_mutex_is_locked(ictx->image_lock)); - auto it = ictx->snap_ids.lower_bound({cls::rbd::GroupSnapshotNamespace{}, + auto it = ictx->snap_ids.lower_bound({cls::rbd::GroupImageSnapshotNamespace{}, ""}); for (; it != ictx->snap_ids.end(); ++it) { if (it->first.first == in_snap_namespace) { return it->second; - } else if (!std::holds_alternative( + } else if (!std::holds_alternative( it->first.first)) { break; } @@ -185,8 +185,8 @@ int group_snap_remove_by_record(librados::IoCtx& group_ioctx, std::vector ictxs; - cls::rbd::GroupSnapshotNamespace ne{group_ioctx.get_id(), group_id, - group_snap.id}; + cls::rbd::GroupImageSnapshotNamespace ne{group_ioctx.get_id(), group_id, + group_snap.id}; ldout(cct, 20) << "Removing snapshots" << dendl; int snap_count = group_snap.snaps.size(); @@ -291,8 +291,8 @@ int group_snap_rollback_by_record(librados::IoCtx& group_ioctx, std::vector ictxs; - cls::rbd::GroupSnapshotNamespace ne{group_ioctx.get_id(), group_id, - group_snap.id}; + cls::rbd::GroupImageSnapshotNamespace ne{group_ioctx.get_id(), group_id, + group_snap.id}; ldout(cct, 20) << "Rolling back snapshots" << dendl; int snap_count = group_snap.snaps.size(); @@ -956,8 +956,8 @@ int Group::snap_create(librados::IoCtx& group_ioctx, group_snap.state = cls::rbd::GROUP_SNAPSHOT_STATE_INCOMPLETE; group_snap.snaps = image_snaps; - cls::rbd::GroupSnapshotNamespace ne{group_ioctx.get_id(), group_id, - group_snap.id}; + cls::rbd::GroupImageSnapshotNamespace ne{group_ioctx.get_id(), group_id, + group_snap.id}; r = cls_client::group_snap_set(&group_ioctx, group_header_oid, group_snap); if (r == -EEXIST) { diff --git a/src/librbd/api/Snapshot.cc b/src/librbd/api/Snapshot.cc index 044237484a926..3d61de395b54d 100644 --- a/src/librbd/api/Snapshot.cc +++ b/src/librbd/api/Snapshot.cc @@ -40,12 +40,12 @@ public: template inline int operator()(const T&) const { - // ignore other than GroupSnapshotNamespace types. + // ignore other than GroupImageSnapshotNamespace types. return -EINVAL; } inline int operator()( - const cls::rbd::GroupSnapshotNamespace& snap_namespace) { + const cls::rbd::GroupImageSnapshotNamespace& snap_namespace) { IoCtx group_ioctx; int r = util::create_ioctx(*image_ioctx, "group", snap_namespace.group_pool, {}, &group_ioctx); -- 2.39.5