From: Jason Dillaman Date: Wed, 22 Aug 2018 18:27:48 +0000 (-0400) Subject: librbd: replace librbd::ParentSpec with cls::rbd::ParentImageSpec X-Git-Tag: v14.0.1~241^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=625ac30e69d409907294f08b9af18dac13e026d4;p=ceph.git librbd: replace librbd::ParentSpec with cls::rbd::ParentImageSpec The newer struct includes support for pool namespaces. Signed-off-by: Jason Dillaman --- diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index 3c83c13626c..b4835551209 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -304,9 +304,11 @@ void get_parent_start(librados::ObjectReadOperation *op, snapid_t snap_id) op->exec("rbd", "get_parent", bl); } -int get_parent_finish(bufferlist::const_iterator *it, ParentSpec *pspec, +int get_parent_finish(bufferlist::const_iterator *it, + cls::rbd::ParentImageSpec *pspec, uint64_t *parent_overlap) { + *pspec = {}; try { decode(pspec->pool_id, *it); decode(pspec->image_id, *it); @@ -319,7 +321,7 @@ int get_parent_finish(bufferlist::const_iterator *it, ParentSpec *pspec, } int get_parent(librados::IoCtx *ioctx, const std::string &oid, - snapid_t snap_id, ParentSpec *pspec, + snapid_t snap_id, cls::rbd::ParentImageSpec *pspec, uint64_t *parent_overlap) { librados::ObjectReadOperation op; @@ -336,7 +338,7 @@ int get_parent(librados::IoCtx *ioctx, const std::string &oid, } int set_parent(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, uint64_t parent_overlap) + const cls::rbd::ParentImageSpec &pspec, uint64_t parent_overlap) { librados::ObjectWriteOperation op; set_parent(&op, pspec, parent_overlap); @@ -344,7 +346,10 @@ int set_parent(librados::IoCtx *ioctx, const std::string &oid, } void set_parent(librados::ObjectWriteOperation *op, - const ParentSpec &pspec, uint64_t parent_overlap) { + const cls::rbd::ParentImageSpec &pspec, + uint64_t parent_overlap) { + assert(pspec.pool_namespace.empty()); + bufferlist in_bl; encode(pspec.pool_id, in_bl); encode(pspec.image_id, in_bl); @@ -467,7 +472,8 @@ int parent_detach(librados::IoCtx *ioctx, const std::string &oid) { } int add_child(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, const std::string &c_imageid) + const cls::rbd::ParentImageSpec &pspec, + const std::string &c_imageid) { librados::ObjectWriteOperation op; add_child(&op, pspec, c_imageid); @@ -475,8 +481,11 @@ int add_child(librados::IoCtx *ioctx, const std::string &oid, } void add_child(librados::ObjectWriteOperation *op, - const ParentSpec pspec, const std::string &c_imageid) + const cls::rbd::ParentImageSpec& pspec, + const std::string &c_imageid) { + assert(pspec.pool_namespace.empty()); + bufferlist in; encode(pspec.pool_id, in); encode(pspec.image_id, in); @@ -487,8 +496,11 @@ void add_child(librados::ObjectWriteOperation *op, } void remove_child(librados::ObjectWriteOperation *op, - const ParentSpec &pspec, const std::string &c_imageid) + const cls::rbd::ParentImageSpec &pspec, + const std::string &c_imageid) { + assert(pspec.pool_namespace.empty()); + bufferlist in; encode(pspec.pool_id, in); encode(pspec.image_id, in); @@ -498,7 +510,8 @@ void remove_child(librados::ObjectWriteOperation *op, } int remove_child(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, const std::string &c_imageid) + const cls::rbd::ParentImageSpec &pspec, + const std::string &c_imageid) { librados::ObjectWriteOperation op; remove_child(&op, pspec, c_imageid); @@ -506,7 +519,7 @@ int remove_child(librados::IoCtx *ioctx, const std::string &oid, } void get_children_start(librados::ObjectReadOperation *op, - const ParentSpec &pspec) { + const cls::rbd::ParentImageSpec &pspec) { bufferlist in_bl; encode(pspec.pool_id, in_bl); encode(pspec.image_id, in_bl); @@ -525,7 +538,7 @@ int get_children_finish(bufferlist::const_iterator *it, } int get_children(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, set& children) + const cls::rbd::ParentImageSpec &pspec, set& children) { librados::ObjectReadOperation op; get_children_start(&op, pspec); diff --git a/src/cls/rbd/cls_rbd_client.h b/src/cls/rbd/cls_rbd_client.h index 7404ff25ab2..c7a8e22badd 100644 --- a/src/cls/rbd/cls_rbd_client.h +++ b/src/cls/rbd/cls_rbd_client.h @@ -9,7 +9,6 @@ #include "common/bit_vector.hpp" #include "common/snap_types.h" #include "include/types.h" -#include "librbd/Types.h" class Context; namespace librados { @@ -70,7 +69,8 @@ void set_flags(librados::ObjectWriteOperation *op, snapid_t snap_id, uint64_t flags, uint64_t mask); void op_features_get_start(librados::ObjectReadOperation *op); -int op_features_get_finish(bufferlist::const_iterator *it, uint64_t *op_features); +int op_features_get_finish(bufferlist::const_iterator *it, + uint64_t *op_features); int op_features_get(librados::IoCtx *ioctx, const std::string &oid, uint64_t *op_features); void op_features_set(librados::ObjectWriteOperation *op, @@ -80,15 +80,17 @@ int op_features_set(librados::IoCtx *ioctx, const std::string &oid, // NOTE: deprecate v1 parent APIs after mimic EOLed void get_parent_start(librados::ObjectReadOperation *op, snapid_t snap_id); -int get_parent_finish(bufferlist::const_iterator *it, ParentSpec *pspec, +int get_parent_finish(bufferlist::const_iterator *it, + cls::rbd::ParentImageSpec *pspec, uint64_t *parent_overlap); int get_parent(librados::IoCtx *ioctx, const std::string &oid, - snapid_t snap_id, ParentSpec *pspec, + snapid_t snap_id, cls::rbd::ParentImageSpec *pspec, uint64_t *parent_overlap); int set_parent(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, uint64_t parent_overlap); + const cls::rbd::ParentImageSpec &pspec, uint64_t parent_overlap); void set_parent(librados::ObjectWriteOperation *op, - const ParentSpec &pspec, uint64_t parent_overlap); + const cls::rbd::ParentImageSpec &pspec, + uint64_t parent_overlap); int remove_parent(librados::IoCtx *ioctx, const std::string &oid); void remove_parent(librados::ObjectWriteOperation *op); @@ -118,19 +120,23 @@ void parent_detach(librados::ObjectWriteOperation* op); int parent_detach(librados::IoCtx *ioctx, const std::string &oid); int add_child(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, const std::string &c_imageid); + const cls::rbd::ParentImageSpec &pspec, + const std::string &c_imageid); void add_child(librados::ObjectWriteOperation *op, - const ParentSpec pspec, const std::string &c_imageid); + const cls::rbd::ParentImageSpec& pspec, + const std::string &c_imageid); void remove_child(librados::ObjectWriteOperation *op, - const ParentSpec &pspec, const std::string &c_imageid); + const cls::rbd::ParentImageSpec &pspec, + const std::string &c_imageid); int remove_child(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, const std::string &c_imageid); + const cls::rbd::ParentImageSpec &pspec, + const std::string &c_imageid); void get_children_start(librados::ObjectReadOperation *op, - const ParentSpec &pspec); + const cls::rbd::ParentImageSpec &pspec); int get_children_finish(bufferlist::const_iterator *it, std::set *children); int get_children(librados::IoCtx *ioctx, const std::string &oid, - const ParentSpec &pspec, set& children); + const cls::rbd::ParentImageSpec& pspec, set& children); void snapshot_get_start(librados::ObjectReadOperation* op, snapid_t snap_id); diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 7b73921831e..f6b5047cf7b 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -389,7 +389,7 @@ public: } int ImageCtx::get_parent_spec(snap_t in_snap_id, - ParentSpec *out_pspec) const + cls::rbd::ParentImageSpec *out_pspec) const { const SnapInfo *info = get_snap_info(in_snap_id); if (info) { @@ -487,8 +487,9 @@ public: void ImageCtx::add_snap(cls::rbd::SnapshotNamespace in_snap_namespace, string in_snap_name, snap_t id, uint64_t in_size, - const ParentInfo &parent, uint8_t protection_status, - uint64_t flags, utime_t timestamp) + const ParentImageInfo &parent, + uint8_t protection_status, uint64_t flags, + utime_t timestamp) { ceph_assert(snap_lock.is_wlocked()); snaps.push_back(id); @@ -616,7 +617,7 @@ public: return 0; } - const ParentInfo* ImageCtx::get_parent_info(snap_t in_snap_id) const + const ParentImageInfo* ImageCtx::get_parent_info(snap_t in_snap_id) const { ceph_assert(snap_lock.is_locked()); ceph_assert(parent_lock.is_locked()); @@ -630,7 +631,7 @@ public: int64_t ImageCtx::get_parent_pool_id(snap_t in_snap_id) const { - const ParentInfo *info = get_parent_info(in_snap_id); + const auto info = get_parent_info(in_snap_id); if (info) return info->spec.pool_id; return -1; @@ -638,7 +639,7 @@ public: string ImageCtx::get_parent_image_id(snap_t in_snap_id) const { - const ParentInfo *info = get_parent_info(in_snap_id); + const auto info = get_parent_info(in_snap_id); if (info) return info->spec.image_id; return ""; @@ -646,7 +647,7 @@ public: uint64_t ImageCtx::get_parent_snap_id(snap_t in_snap_id) const { - const ParentInfo *info = get_parent_info(in_snap_id); + const auto info = get_parent_info(in_snap_id); if (info) return info->spec.snap_id; return CEPH_NOSNAP; @@ -655,7 +656,7 @@ public: int ImageCtx::get_parent_overlap(snap_t in_snap_id, uint64_t *overlap) const { ceph_assert(snap_lock.is_locked()); - const ParentInfo *info = get_parent_info(in_snap_id); + const auto info = get_parent_info(in_snap_id); if (info) { *overlap = info->overlap; return 0; diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index a15fabe4882..76679382320 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -121,7 +121,7 @@ namespace librbd { char *format_string; std::string header_oid; std::string id; // only used for new-format images - ParentInfo parent_md; + ParentImageInfo parent_md; ImageCtx *parent; ImageCtx *child = nullptr; MigrationInfo migration_info; @@ -267,7 +267,7 @@ namespace librbd { int get_snap_namespace(librados::snap_t in_snap_id, cls::rbd::SnapshotNamespace *out_snap_namespace) const; int get_parent_spec(librados::snap_t in_snap_id, - ParentSpec *pspec) const; + cls::rbd::ParentImageSpec *pspec) const; int is_snap_protected(librados::snap_t in_snap_id, bool *is_protected) const; int is_snap_unprotected(librados::snap_t in_snap_id, @@ -289,7 +289,7 @@ namespace librbd { void add_snap(cls::rbd::SnapshotNamespace in_snap_namespace, std::string in_snap_name, librados::snap_t id, - uint64_t in_size, const ParentInfo &parent, + uint64_t in_size, const ParentImageInfo &parent, uint8_t protection_status, uint64_t flags, utime_t timestamp); void rm_snap(cls::rbd::SnapshotNamespace in_snap_namespace, std::string in_snap_name, @@ -310,7 +310,7 @@ namespace librbd { bool *flags_set) const; int update_flags(librados::snap_t in_snap_id, uint64_t flag, bool enabled); - const ParentInfo* get_parent_info(librados::snap_t in_snap_id) const; + const ParentImageInfo* get_parent_info(librados::snap_t in_snap_id) const; int64_t get_parent_pool_id(librados::snap_t in_snap_id) const; std::string get_parent_image_id(librados::snap_t in_snap_id) const; uint64_t get_parent_snap_id(librados::snap_t in_snap_id) const; diff --git a/src/librbd/Types.h b/src/librbd/Types.h index b1658ee69cb..5b9f1793714 100644 --- a/src/librbd/Types.h +++ b/src/librbd/Types.h @@ -57,57 +57,30 @@ enum { typedef std::map SnapSeqs; -/** @brief Unique identification of a parent in clone relationship. - * Cloning an image creates a child image that keeps a reference - * to its parent. This allows copy-on-write images. */ -struct ParentSpec { - int64_t pool_id; - std::string image_id; - snapid_t snap_id; - - ParentSpec() : pool_id(-1), snap_id(CEPH_NOSNAP) { - } - ParentSpec(int64_t pool_id, std::string image_id, snapid_t snap_id) - : pool_id(pool_id), image_id(image_id), snap_id(snap_id) { - } - - bool operator==(const ParentSpec &other) { - return ((this->pool_id == other.pool_id) && - (this->image_id == other.image_id) && - (this->snap_id == other.snap_id)); - } - bool operator!=(const ParentSpec &other) { - return !(*this == other); - } -}; - /// Full information about an image's parent. -struct ParentInfo { +struct ParentImageInfo { /// Identification of the parent. - ParentSpec spec; + cls::rbd::ParentImageSpec spec; /** @brief Where the portion of data shared with the child image ends. * Since images can be resized multiple times, the portion of data shared * with the child image is not necessarily min(parent size, child size). * If the child image is first shrunk and then enlarged, the common portion * will be shorter. */ - uint64_t overlap; - - ParentInfo() : overlap(0) { - } + uint64_t overlap = 0; }; struct SnapInfo { std::string name; cls::rbd::SnapshotNamespace snap_namespace; uint64_t size; - ParentInfo parent; + ParentImageInfo parent; uint8_t protection_status; uint64_t flags; utime_t timestamp; SnapInfo(std::string _name, const cls::rbd::SnapshotNamespace &_snap_namespace, - uint64_t _size, const ParentInfo &_parent, + uint64_t _size, const ParentImageInfo &_parent, uint8_t _protection_status, uint64_t _flags, utime_t _timestamp) : name(_name), snap_namespace(_snap_namespace), size(_size), parent(_parent), protection_status(_protection_status), flags(_flags), diff --git a/src/librbd/api/Image.cc b/src/librbd/api/Image.cc index c8480872e20..c008e61bf18 100644 --- a/src/librbd/api/Image.cc +++ b/src/librbd/api/Image.cc @@ -71,7 +71,8 @@ int Image::list_images(librados::IoCtx& io_ctx, ImageNameToIds *images) { } template -int Image::list_children(I *ictx, const ParentSpec &parent_spec, +int Image::list_children(I *ictx, + const cls::rbd::ParentImageSpec &parent_spec, PoolImageIds *pool_image_ids) { CephContext *cct = ictx->cct; @@ -129,16 +130,19 @@ int Image::list_children(I *ictx, const ParentSpec &parent_spec, << dendl; return r; } - pool_image_ids->insert({*it, image_ids}); + pool_image_ids->insert({ + {it->first, it->second, ictx->md_ctx.get_namespace()}, image_ids}); } // retrieve clone v2 children attached to this snapshot IoCtx parent_io_ctx; r = rados.ioctx_create2(parent_spec.pool_id, parent_io_ctx); - ceph_assert(r == 0); - - // TODO support clone v2 parent namespaces - parent_io_ctx.set_namespace(ictx->md_ctx.get_namespace()); + if (r < 0) { + lderr(cct) << "error accessing parent image pool " + << parent_spec.pool_id << ": " << cpp_strerror(r) << dendl; + return r; + } + parent_io_ctx.set_namespace(parent_spec.pool_namespace); cls::rbd::ChildImageSpecs child_images; r = cls_client::children_list(&parent_io_ctx, @@ -156,12 +160,13 @@ int Image::list_children(I *ictx, const ParentSpec &parent_spec, ldout(cct, 1) << "pool " << child_image.pool_id << " no longer exists" << dendl; continue; + } else if (r < 0) { + lderr(cct) << "error accessing child image pool " + << child_image.pool_id << ": " << cpp_strerror(r) << dendl; } - // TODO support clone v2 child namespaces - io_ctx.set_namespace(ictx->md_ctx.get_namespace()); - - PoolSpec pool_spec = {child_image.pool_id, io_ctx.get_pool_name()}; + PoolSpec pool_spec = {child_image.pool_id, io_ctx.get_pool_name(), + child_image.pool_namespace}; (*pool_image_ids)[pool_spec].insert(child_image.image_id); } @@ -217,7 +222,7 @@ int Image::deep_copy(I *src, librados::IoCtx& dest_md_ctx, opts.unset(RBD_IMAGE_OPTION_FLATTEN); } - ParentSpec parent_spec; + cls::rbd::ParentImageSpec parent_spec; if (flatten > 0) { parent_spec.pool_id = -1; } else { diff --git a/src/librbd/api/Image.h b/src/librbd/api/Image.h index 062d98c23c8..88c15f80c77 100644 --- a/src/librbd/api/Image.h +++ b/src/librbd/api/Image.h @@ -22,7 +22,7 @@ namespace api { template struct Image { - typedef std::pair PoolSpec; + typedef std::tuple PoolSpec; typedef std::set ImageIds; typedef std::map PoolImageIds; typedef std::map ImageNameToIds; @@ -32,7 +32,8 @@ struct Image { static int list_images(librados::IoCtx& io_ctx, ImageNameToIds *images); - static int list_children(ImageCtxT *ictx, const ParentSpec &parent_spec, + static int list_children(ImageCtxT *ictx, + const cls::rbd::ParentImageSpec &parent_spec, PoolImageIds *pool_image_ids); static int deep_copy(ImageCtxT *ictx, librados::IoCtx& dest_md_ctx, diff --git a/src/librbd/api/Migration.cc b/src/librbd/api/Migration.cc index 57a0008b92d..5aeb38a6656 100644 --- a/src/librbd/api/Migration.cc +++ b/src/librbd/api/Migration.cc @@ -1131,7 +1131,7 @@ int Migration::create_dst_image() { ldout(m_cct, 10) << dendl; uint64_t size; - ParentSpec parent_spec; + cls::rbd::ParentImageSpec parent_spec; { RWLock::RLocker snap_locker(m_src_image_ctx->snap_lock); RWLock::RLocker parent_locker(m_src_image_ctx->parent_lock); diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index b9eac8313db..1f4fc17e34c 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -273,8 +273,10 @@ int Mirror::image_disable(I *ictx, bool force) { RWLock::RLocker l(ictx->snap_lock); map snap_info = ictx->snap_info; for (auto &info : snap_info) { - ParentSpec parent_spec(ictx->md_ctx.get_id(), ictx->id, info.first); - map< pair, set > image_info; + cls::rbd::ParentImageSpec parent_spec{ictx->md_ctx.get_id(), + ictx->md_ctx.get_namespace(), + ictx->id, info.first}; + map< tuple, set > image_info; r = Image::list_children(ictx, parent_spec, &image_info); if (r < 0) { @@ -287,16 +289,14 @@ int Mirror::image_disable(I *ictx, bool force) { librados::Rados rados(ictx->md_ctx); for (auto &info: image_info) { librados::IoCtx ioctx; - r = rados.ioctx_create2(info.first.first, ioctx); + r = rados.ioctx_create2(std::get<0>(info.first), ioctx); if (r < 0) { rollback = true; lderr(cct) << "error accessing child image pool " - << info.first.second << dendl; + << std::get<1>(info.first) << dendl; return r; } - - // TODO support clone v2 child namespaces - ioctx.set_namespace(ictx->md_ctx.get_namespace()); + ioctx.set_namespace(std::get<2>(info.first)); for (auto &id_it : info.second) { cls::rbd::MirrorImage mirror_image_internal; diff --git a/src/librbd/deep_copy/SetHeadRequest.cc b/src/librbd/deep_copy/SetHeadRequest.cc index 34bd93506d2..ae110f47650 100644 --- a/src/librbd/deep_copy/SetHeadRequest.cc +++ b/src/librbd/deep_copy/SetHeadRequest.cc @@ -23,7 +23,7 @@ using librbd::util::create_rados_callback; template SetHeadRequest::SetHeadRequest(I *image_ctx, uint64_t size, - const librbd::ParentSpec &spec, + const cls::rbd::ParentImageSpec &spec, uint64_t parent_overlap, Context *on_finish) : m_image_ctx(image_ctx), m_size(size), m_parent_spec(spec), @@ -172,10 +172,7 @@ void SetHeadRequest::send_attach_parent() { finish_op_ctx->complete(0); }); auto req = image::AttachParentRequest::create( - *m_image_ctx, - {m_parent_spec.pool_id, "", m_parent_spec.image_id, - m_parent_spec.snap_id}, - m_parent_overlap, ctx); + *m_image_ctx, m_parent_spec, m_parent_overlap, ctx); req->send(); } diff --git a/src/librbd/deep_copy/SetHeadRequest.h b/src/librbd/deep_copy/SetHeadRequest.h index cddad95785a..3b9fab7a73b 100644 --- a/src/librbd/deep_copy/SetHeadRequest.h +++ b/src/librbd/deep_copy/SetHeadRequest.h @@ -23,7 +23,7 @@ template class SetHeadRequest { public: static SetHeadRequest* create(ImageCtxT *image_ctx, uint64_t size, - const librbd::ParentSpec &parent_spec, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { return new SetHeadRequest(image_ctx, size, parent_spec, parent_overlap, @@ -31,8 +31,8 @@ public: } SetHeadRequest(ImageCtxT *image_ctx, uint64_t size, - const librbd::ParentSpec &parent_spec, uint64_t parent_overlap, - Context *on_finish); + const cls::rbd::ParentImageSpec &parent_spec, + uint64_t parent_overlap, Context *on_finish); void send(); @@ -59,7 +59,7 @@ private: ImageCtxT *m_image_ctx; uint64_t m_size; - librbd::ParentSpec m_parent_spec; + cls::rbd::ParentImageSpec m_parent_spec; uint64_t m_parent_overlap; Context *m_on_finish; diff --git a/src/librbd/deep_copy/SnapshotCopyRequest.cc b/src/librbd/deep_copy/SnapshotCopyRequest.cc index 943e3e7bf11..68da4e6ef13 100644 --- a/src/librbd/deep_copy/SnapshotCopyRequest.cc +++ b/src/librbd/deep_copy/SnapshotCopyRequest.cc @@ -67,7 +67,7 @@ SnapshotCopyRequest::SnapshotCopyRequest(I *src_image_ctx, template void SnapshotCopyRequest::send() { - librbd::ParentSpec src_parent_spec; + cls::rbd::ParentImageSpec src_parent_spec; int r = validate_parent(m_src_image_ctx, &src_parent_spec); if (r < 0) { lderr(m_cct) << "source image parent spec mismatch" << dendl; @@ -353,7 +353,7 @@ void SnapshotCopyRequest::send_snap_create() { uint64_t size = snap_info_it->second.size; m_snap_namespace = snap_info_it->second.snap_namespace; - librbd::ParentSpec parent_spec; + cls::rbd::ParentImageSpec parent_spec; uint64_t parent_overlap = 0; if (!m_flatten && snap_info_it->second.parent.spec.pool_id != -1) { parent_spec = m_dst_parent_spec; @@ -520,7 +520,7 @@ void SnapshotCopyRequest::send_set_head() { ldout(m_cct, 20) << dendl; uint64_t size; - ParentSpec parent_spec; + cls::rbd::ParentImageSpec parent_spec; uint64_t parent_overlap = 0; { RWLock::RLocker src_locker(m_src_image_ctx->snap_lock); @@ -621,7 +621,7 @@ void SnapshotCopyRequest::error(int r) { template int SnapshotCopyRequest::validate_parent(I *image_ctx, - librbd::ParentSpec *spec) { + cls::rbd::ParentImageSpec *spec) { RWLock::RLocker owner_locker(image_ctx->owner_lock); RWLock::RLocker snap_locker(image_ctx->snap_lock); diff --git a/src/librbd/deep_copy/SnapshotCopyRequest.h b/src/librbd/deep_copy/SnapshotCopyRequest.h index 0155488b6df..99434422760 100644 --- a/src/librbd/deep_copy/SnapshotCopyRequest.h +++ b/src/librbd/deep_copy/SnapshotCopyRequest.h @@ -97,7 +97,7 @@ private: std::string m_snap_name; cls::rbd::SnapshotNamespace m_snap_namespace; - librbd::ParentSpec m_dst_parent_spec; + cls::rbd::ParentImageSpec m_dst_parent_spec; Mutex m_lock; bool m_canceled = false; @@ -124,7 +124,7 @@ private: void error(int r); - int validate_parent(ImageCtxT *image_ctx, librbd::ParentSpec *spec); + int validate_parent(ImageCtxT *image_ctx, cls::rbd::ParentImageSpec *spec); Context *start_lock_op(); Context *start_lock_op(RWLock &owner_lock); diff --git a/src/librbd/deep_copy/SnapshotCreateRequest.cc b/src/librbd/deep_copy/SnapshotCreateRequest.cc index 6e110c72c85..1a8800cb646 100644 --- a/src/librbd/deep_copy/SnapshotCreateRequest.cc +++ b/src/librbd/deep_copy/SnapshotCreateRequest.cc @@ -27,8 +27,8 @@ template SnapshotCreateRequest::SnapshotCreateRequest( I *dst_image_ctx, const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, - uint64_t size, const librbd::ParentSpec &spec, uint64_t parent_overlap, - Context *on_finish) + uint64_t size, const cls::rbd::ParentImageSpec &spec, + uint64_t parent_overlap, Context *on_finish) : m_dst_image_ctx(dst_image_ctx), m_snap_name(snap_name), m_snap_namespace(snap_namespace), m_size(size), m_parent_spec(spec), m_parent_overlap(parent_overlap), diff --git a/src/librbd/deep_copy/SnapshotCreateRequest.h b/src/librbd/deep_copy/SnapshotCreateRequest.h index 4ddcefd19d9..30a31dc591a 100644 --- a/src/librbd/deep_copy/SnapshotCreateRequest.h +++ b/src/librbd/deep_copy/SnapshotCreateRequest.h @@ -26,7 +26,7 @@ public: const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::ParentSpec &parent_spec, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { return new SnapshotCreateRequest(dst_image_ctx, snap_name, snap_namespace, size, @@ -37,7 +37,7 @@ public: const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::ParentSpec &parent_spec, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish); void send(); @@ -67,7 +67,7 @@ private: std::string m_snap_name; cls::rbd::SnapshotNamespace m_snap_namespace; uint64_t m_size; - librbd::ParentSpec m_parent_spec; + cls::rbd::ParentImageSpec m_parent_spec; uint64_t m_parent_overlap; Context *m_on_finish; diff --git a/src/librbd/image/AttachParentRequest.cc b/src/librbd/image/AttachParentRequest.cc index 239f1054364..ec82d2923e4 100644 --- a/src/librbd/image/AttachParentRequest.cc +++ b/src/librbd/image/AttachParentRequest.cc @@ -35,11 +35,7 @@ void AttachParentRequest::attach_parent() { librbd::cls_client::parent_attach(&op, m_parent_image_spec, m_parent_overlap); } else { - librbd::cls_client::set_parent(&op, - {m_parent_image_spec.pool_id, - m_parent_image_spec.image_id, - m_parent_image_spec.snap_id}, - m_parent_overlap); + librbd::cls_client::set_parent(&op, m_parent_image_spec, m_parent_overlap); } auto aio_comp = create_rados_callback< diff --git a/src/librbd/image/CloneRequest.cc b/src/librbd/image/CloneRequest.cc index f1b0acb72af..936d0025929 100644 --- a/src/librbd/image/CloneRequest.cc +++ b/src/librbd/image/CloneRequest.cc @@ -148,7 +148,8 @@ void CloneRequest::handle_open_parent(int r) { } m_parent_snap_id = m_parent_image_ctx->snap_id; - m_pspec = {m_parent_io_ctx.get_id(), m_parent_image_id, m_parent_snap_id}; + m_pspec = {m_parent_io_ctx.get_id(), m_parent_io_ctx.get_namespace(), + m_parent_image_id, m_parent_snap_id}; validate_parent(); } @@ -327,8 +328,7 @@ void CloneRequest::attach_parent() { auto ctx = create_context_callback< CloneRequest, &CloneRequest::handle_attach_parent>(this); auto req = AttachParentRequest::create( - *m_imctx, {m_pspec.pool_id, "", m_pspec.image_id, m_pspec.snap_id}, - m_size, ctx); + *m_imctx, m_pspec, m_size, ctx); req->send(); } diff --git a/src/librbd/image/CloneRequest.h b/src/librbd/image/CloneRequest.h index afcbbd2386b..e406276bfb2 100644 --- a/src/librbd/image/CloneRequest.h +++ b/src/librbd/image/CloneRequest.h @@ -114,7 +114,7 @@ private: std::string m_name; std::string m_id; ImageOptions m_opts; - ParentSpec m_pspec; + cls::rbd::ParentImageSpec m_pspec; ImageCtxT *m_imctx; cls::rbd::MirrorMode m_mirror_mode = cls::rbd::MIRROR_MODE_DISABLED; const std::string m_non_primary_global_image_id; diff --git a/src/librbd/image/DetachChildRequest.cc b/src/librbd/image/DetachChildRequest.cc index d29c575cb51..592611298c7 100644 --- a/src/librbd/image/DetachChildRequest.cc +++ b/src/librbd/image/DetachChildRequest.cc @@ -69,10 +69,13 @@ void DetachChildRequest::clone_v2_child_detach() { librados::Rados rados(m_image_ctx.md_ctx); int r = rados.ioctx_create2(m_parent_spec.pool_id, m_parent_io_ctx); - ceph_assert(r == 0); - - // TODO support clone v2 parent namespaces - m_parent_io_ctx.set_namespace(m_image_ctx.md_ctx.get_namespace()); + if (r < 0) { + lderr(cct) << "error accessing parent pool: " << cpp_strerror(r) + << dendl; + finish(r); + return; + } + m_parent_io_ctx.set_namespace(m_parent_spec.pool_namespace); m_parent_header_name = util::header_name(m_parent_spec.image_id); diff --git a/src/librbd/image/DetachChildRequest.h b/src/librbd/image/DetachChildRequest.h index d9bfdf107ba..bb0c81d21af 100644 --- a/src/librbd/image/DetachChildRequest.h +++ b/src/librbd/image/DetachChildRequest.h @@ -68,7 +68,7 @@ private: Context* m_on_finish; librados::IoCtx m_parent_io_ctx; - ParentSpec m_parent_spec; + cls::rbd::ParentImageSpec m_parent_spec; std::string m_parent_header_name; cls::rbd::SnapshotNamespace m_parent_snap_namespace; diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index 925d3d8c95b..9028078d383 100644 --- a/src/librbd/image/RefreshParentRequest.cc +++ b/src/librbd/image/RefreshParentRequest.cc @@ -24,7 +24,7 @@ using util::create_context_callback; template RefreshParentRequest::RefreshParentRequest( - I &child_image_ctx, const ParentInfo &parent_md, + I &child_image_ctx, const ParentImageInfo &parent_md, const MigrationInfo &migration_info, Context *on_finish) : m_child_image_ctx(child_image_ctx), m_parent_md(parent_md), m_migration_info(migration_info), m_on_finish(on_finish), @@ -34,7 +34,7 @@ RefreshParentRequest::RefreshParentRequest( template bool RefreshParentRequest::is_refresh_required( - I &child_image_ctx, const ParentInfo &parent_md, + I &child_image_ctx, const ParentImageInfo &parent_md, const MigrationInfo &migration_info) { ceph_assert(child_image_ctx.snap_lock.is_locked()); ceph_assert(child_image_ctx.parent_lock.is_locked()); @@ -44,7 +44,7 @@ bool RefreshParentRequest::is_refresh_required( template bool RefreshParentRequest::is_close_required( - I &child_image_ctx, const ParentInfo &parent_md, + I &child_image_ctx, const ParentImageInfo &parent_md, const MigrationInfo &migration_info) { return (child_image_ctx.parent != nullptr && !does_parent_exist(child_image_ctx, parent_md, migration_info)); @@ -52,18 +52,20 @@ bool RefreshParentRequest::is_close_required( template bool RefreshParentRequest::is_open_required( - I &child_image_ctx, const ParentInfo &parent_md, + I &child_image_ctx, const ParentImageInfo &parent_md, const MigrationInfo &migration_info) { return (does_parent_exist(child_image_ctx, parent_md, migration_info) && (child_image_ctx.parent == nullptr || child_image_ctx.parent->md_ctx.get_id() != parent_md.spec.pool_id || + child_image_ctx.parent->md_ctx.get_namespace() != + parent_md.spec.pool_namespace || child_image_ctx.parent->id != parent_md.spec.image_id || child_image_ctx.parent->snap_id != parent_md.spec.snap_id)); } template bool RefreshParentRequest::does_parent_exist( - I &child_image_ctx, const ParentInfo &parent_md, + I &child_image_ctx, const ParentImageInfo &parent_md, const MigrationInfo &migration_info) { if (child_image_ctx.child != nullptr && child_image_ctx.child->migration_info.empty() && parent_md.overlap == 0) { @@ -122,9 +124,7 @@ void RefreshParentRequest::send_open_parent() { send_complete(r); return; } - - // TODO support clone v2 parent namespaces - parent_io_ctx.set_namespace(m_child_image_ctx.md_ctx.get_namespace()); + parent_io_ctx.set_namespace(m_parent_md.spec.pool_namespace); std::string image_name; uint64_t flags = 0; diff --git a/src/librbd/image/RefreshParentRequest.h b/src/librbd/image/RefreshParentRequest.h index 39abc1b789c..086d8ec1b9a 100644 --- a/src/librbd/image/RefreshParentRequest.h +++ b/src/librbd/image/RefreshParentRequest.h @@ -19,7 +19,7 @@ template class RefreshParentRequest { public: static RefreshParentRequest *create(ImageCtxT &child_image_ctx, - const ParentInfo &parent_md, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info, Context *on_finish) { return new RefreshParentRequest(child_image_ctx, parent_md, migration_info, @@ -27,7 +27,7 @@ public: } static bool is_refresh_required(ImageCtxT &child_image_ctx, - const ParentInfo &parent_md, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info); void send(); @@ -58,11 +58,12 @@ private: * @endverbatim */ - RefreshParentRequest(ImageCtxT &child_image_ctx, const ParentInfo &parent_md, + RefreshParentRequest(ImageCtxT &child_image_ctx, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info, Context *on_finish); ImageCtxT &m_child_image_ctx; - ParentInfo m_parent_md; + ParentImageInfo m_parent_md; MigrationInfo m_migration_info; Context *m_on_finish; @@ -72,13 +73,13 @@ private: int m_error_result; static bool is_close_required(ImageCtxT &child_image_ctx, - const ParentInfo &parent_md, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info); static bool is_open_required(ImageCtxT &child_image_ctx, - const ParentInfo &parent_md, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info); static bool does_parent_exist(ImageCtxT &child_image_ctx, - const ParentInfo &parent_md, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info); void send_open_parent(); diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index d9178fc3b2d..4cdb74f68e2 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -450,16 +450,8 @@ Context *RefreshRequest::handle_v2_get_parent(int *result) { auto it = m_out_bl.cbegin(); if (!m_legacy_parent) { - cls::rbd::ParentImageSpec parent_image_spec; if (*result == 0) { - *result = cls_client::parent_get_finish(&it, &parent_image_spec); - - m_parent_md.spec = {}; - if (*result == 0) { - m_parent_md.spec.pool_id = parent_image_spec.pool_id; - m_parent_md.spec.image_id = parent_image_spec.image_id; - m_parent_md.spec.snap_id = parent_image_spec.snap_id; - } + *result = cls_client::parent_get_finish(&it, &m_parent_md.spec); } std::optional parent_overlap; @@ -765,7 +757,7 @@ void RefreshRequest::send_v2_refresh_parent() { RWLock::RLocker snap_locker(m_image_ctx.snap_lock); RWLock::RLocker parent_locker(m_image_ctx.parent_lock); - ParentInfo parent_md; + ParentImageInfo parent_md; MigrationInfo migration_info; int r = get_parent_info(m_image_ctx.snap_id, &parent_md, &migration_info); if (!m_skip_open_parent_image && (r < 0 || @@ -1296,7 +1288,7 @@ void RefreshRequest::apply() { uint8_t protection_status = m_image_ctx.old_format ? static_cast(RBD_PROTECTION_STATUS_UNPROTECTED) : m_snap_protection[i]; - ParentInfo parent; + ParentImageInfo parent; if (!m_image_ctx.old_format) { if (!m_image_ctx.migration_info.empty()) { parent = m_image_ctx.parent_md; @@ -1369,7 +1361,7 @@ void RefreshRequest::apply() { template int RefreshRequest::get_parent_info(uint64_t snap_id, - ParentInfo *parent_md, + ParentImageInfo *parent_md, MigrationInfo *migration_info) { if (get_migration_info(parent_md, migration_info)) { return 0; @@ -1390,7 +1382,7 @@ int RefreshRequest::get_parent_info(uint64_t snap_id, } template -bool RefreshRequest::get_migration_info(ParentInfo *parent_md, +bool RefreshRequest::get_migration_info(ParentImageInfo *parent_md, MigrationInfo *migration_info) { if (m_migration_spec.header_type != cls::rbd::MIGRATION_HEADER_TYPE_DST || (m_migration_spec.state != cls::rbd::MIGRATION_STATE_PREPARED && diff --git a/src/librbd/image/RefreshRequest.h b/src/librbd/image/RefreshRequest.h index 1fa380fc7c3..842d79f569d 100644 --- a/src/librbd/image/RefreshRequest.h +++ b/src/librbd/image/RefreshRequest.h @@ -146,13 +146,13 @@ private: std::map m_metadata; std::string m_object_prefix; - ParentInfo m_parent_md; + ParentImageInfo m_parent_md; bool m_head_parent_overlap = false; cls::rbd::GroupSpec m_group_spec; ::SnapContext m_snapc; std::vector m_snap_infos; - std::vector m_snap_parents; + std::vector m_snap_parents; std::vector m_snap_protection; std::vector m_snap_flags; @@ -242,9 +242,10 @@ private: } void apply(); - int get_parent_info(uint64_t snap_id, ParentInfo *parent_md, + int get_parent_info(uint64_t snap_id, ParentImageInfo *parent_md, MigrationInfo *migration_info); - bool get_migration_info(ParentInfo *parent_md, MigrationInfo *migration_info); + bool get_migration_info(ParentImageInfo *parent_md, + MigrationInfo *migration_info); }; } // namespace image diff --git a/src/librbd/image/SetSnapRequest.cc b/src/librbd/image/SetSnapRequest.cc index e9542491db6..f342147f35e 100644 --- a/src/librbd/image/SetSnapRequest.cc +++ b/src/librbd/image/SetSnapRequest.cc @@ -175,13 +175,13 @@ template Context *SetSnapRequest::send_refresh_parent(int *result) { CephContext *cct = m_image_ctx.cct; - ParentInfo parent_md; + ParentImageInfo parent_md; bool refresh_parent; { RWLock::RLocker snap_locker(m_image_ctx.snap_lock); RWLock::RLocker parent_locker(m_image_ctx.parent_lock); - const ParentInfo *parent_info = m_image_ctx.get_parent_info(m_snap_id); + const auto parent_info = m_image_ctx.get_parent_info(m_snap_id); if (parent_info == nullptr) { *result = -ENOENT; lderr(cct) << "failed to retrieve snapshot parent info" << dendl; diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index d7d26066d4e..e70b64ba5b8 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -573,9 +573,13 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) } RWLock::RLocker l(ictx->snap_lock); - snap_t snap_id = ictx->get_snap_id(cls::rbd::UserSnapshotNamespace(), snap_name); - ParentSpec parent_spec(ictx->md_ctx.get_id(), ictx->id, snap_id); - map< pair, set > image_info; + snap_t snap_id = ictx->get_snap_id(cls::rbd::UserSnapshotNamespace(), + snap_name); + + cls::rbd::ParentImageSpec parent_spec{ictx->md_ctx.get_id(), + ictx->md_ctx.get_namespace(), + ictx->id, snap_id}; + map< tuple, set > image_info; r = api::Image<>::list_children(ictx, parent_spec, &image_info); if (r < 0) { @@ -589,17 +593,15 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) size_t i = 0; Rados rados(ictx->md_ctx); for ( auto &info : image_info){ - string pool = info.first.second; + string pool = std::get<1>(info.first); IoCtx ioctx; - r = rados.ioctx_create2(info.first.first, ioctx); + r = rados.ioctx_create2(std::get<0>(info.first), ioctx); if (r < 0) { lderr(cct) << "Error accessing child image pool " << pool << dendl; return r; } - - // TODO support clone v2 child namespaces - ioctx.set_namespace(ictx->md_ctx.get_namespace()); + ioctx.set_namespace(std::get<2>(info.first)); for (auto &id_it : info.second) { ImageCtx *imctx = new ImageCtx("", id_it, nullptr, ioctx, false); @@ -652,8 +654,10 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) } RWLock::RLocker l(ictx->snap_lock); - ParentSpec parent_spec(ictx->md_ctx.get_id(), ictx->id, ictx->snap_id); - map< pair, set > image_info; + cls::rbd::ParentImageSpec parent_spec{ictx->md_ctx.get_id(), + ictx->md_ctx.get_namespace(), + ictx->id, ictx->snap_id}; + map< tuple, set > image_info; r = api::Image<>::list_children(ictx, parent_spec, &image_info); if (r < 0) { @@ -663,15 +667,13 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) Rados rados(ictx->md_ctx); for (auto &info : image_info) { IoCtx ioctx; - r = rados.ioctx_create2(info.first.first, ioctx); + r = rados.ioctx_create2(std::get<0>(info.first), ioctx); if (r < 0) { - lderr(cct) << "Error accessing child image pool " << info.first.second - << dendl; + lderr(cct) << "Error accessing child image pool " + << std::get<1>(info.first) << dendl; return r; } - - // TODO support clone v2 child namespaces - ioctx.set_namespace(ictx->md_ctx.get_namespace()); + ioctx.set_namespace(std::get<2>(info.first)); for (auto &id_it : info.second) { string name; @@ -692,12 +694,16 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) trash = true; } else if (r < 0 && r != -ENOENT) { lderr(cct) << "Error looking up name for image id " << id_it - << " in pool " << info.first.second << dendl; + << " in pool " << std::get<1>(info.first) + << (std::get<2>(info.first).empty() ? + "" : "/" + std::get<2>(info.first)) << dendl; return r; } + + // TODO support namespaces names->push_back( child_info_t { - info.first.second, + std::get<1>(info.first), name, id_it, trash @@ -1099,7 +1105,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) return -ENOENT; } - ParentSpec parent_spec; + cls::rbd::ParentImageSpec parent_spec; if (ictx->snap_id == CEPH_NOSNAP) { parent_spec = ictx->parent_md.spec; diff --git a/src/librbd/operation/SnapshotCreateRequest.h b/src/librbd/operation/SnapshotCreateRequest.h index 571916000f2..406d2f01c47 100644 --- a/src/librbd/operation/SnapshotCreateRequest.h +++ b/src/librbd/operation/SnapshotCreateRequest.h @@ -86,7 +86,7 @@ private: uint64_t m_snap_id; uint64_t m_size; - ParentInfo m_parent_info; + ParentImageInfo m_parent_info; void send_suspend_requests(); Context *handle_suspend_requests(int *result); diff --git a/src/librbd/operation/SnapshotRemoveRequest.cc b/src/librbd/operation/SnapshotRemoveRequest.cc index 51bc9ffd004..8c34ebf6c53 100644 --- a/src/librbd/operation/SnapshotRemoveRequest.cc +++ b/src/librbd/operation/SnapshotRemoveRequest.cc @@ -162,7 +162,7 @@ void SnapshotRemoveRequest::detach_child() { RWLock::RLocker snap_locker(image_ctx.snap_lock); RWLock::RLocker parent_locker(image_ctx.parent_lock); - ParentSpec our_pspec; + cls::rbd::ParentImageSpec our_pspec; int r = image_ctx.get_parent_spec(m_snap_id, &our_pspec); if (r < 0) { if (r == -ENOENT) { @@ -338,7 +338,8 @@ void SnapshotRemoveRequest::remove_snap_context() { } template -int SnapshotRemoveRequest::scan_for_parents(ParentSpec &pspec) { +int SnapshotRemoveRequest::scan_for_parents( + cls::rbd::ParentImageSpec &pspec) { I &image_ctx = this->m_image_ctx; ceph_assert(image_ctx.snap_lock.is_locked()); ceph_assert(image_ctx.parent_lock.is_locked()); diff --git a/src/librbd/operation/SnapshotRemoveRequest.h b/src/librbd/operation/SnapshotRemoveRequest.h index dfb4399f465..f980ba3b83f 100644 --- a/src/librbd/operation/SnapshotRemoveRequest.h +++ b/src/librbd/operation/SnapshotRemoveRequest.h @@ -97,7 +97,7 @@ private: void handle_remove_snap(int r); void remove_snap_context(); - int scan_for_parents(ParentSpec &pspec); + int scan_for_parents(cls::rbd::ParentImageSpec &pspec); }; diff --git a/src/librbd/operation/SnapshotUnprotectRequest.cc b/src/librbd/operation/SnapshotUnprotectRequest.cc index ce5ba9a6fb2..c80f05dd966 100644 --- a/src/librbd/operation/SnapshotUnprotectRequest.cc +++ b/src/librbd/operation/SnapshotUnprotectRequest.cc @@ -56,7 +56,7 @@ template class C_ScanPoolChildren : public C_AsyncObjectThrottle { public: C_ScanPoolChildren(AsyncObjectThrottle &throttle, I *image_ctx, - const ParentSpec &pspec, const Pools &pools, + const cls::rbd::ParentImageSpec &pspec, const Pools &pools, size_t pool_idx) : C_AsyncObjectThrottle(throttle, *image_ctx), m_pspec(pspec), m_pool(pools[pool_idx]) { @@ -97,9 +97,7 @@ public: << "'" << dendl; return r; } - - // TODO support clone v2 child namespaces - m_pool_ioctx.set_namespace(image_ctx.md_ctx.get_namespace()); + m_pool_ioctx.set_namespace(m_pspec.pool_namespace); librados::ObjectReadOperation op; cls_client::get_children_start(&op, m_pspec); @@ -142,7 +140,7 @@ protected: } private: - ParentSpec m_pspec; + cls::rbd::ParentImageSpec m_pspec; Pool m_pool; IoCtx m_pool_ioctx; @@ -258,7 +256,9 @@ void SnapshotUnprotectRequest::send_scan_pool_children() { std::list pool_list; rados.pool_list2(pool_list); - ParentSpec pspec(image_ctx.md_ctx.get_id(), image_ctx.id, m_snap_id); + cls::rbd::ParentImageSpec pspec(image_ctx.md_ctx.get_id(), + image_ctx.md_ctx.get_namespace(), + image_ctx.id, m_snap_id); Pools pools(pool_list.begin(), pool_list.end()); Context *ctx = this->create_callback_context(); diff --git a/src/test/cls_rbd/test_cls_rbd.cc b/src/test/cls_rbd/test_cls_rbd.cc index 63b52ff034b..99a0a55b981 100644 --- a/src/test/cls_rbd/test_cls_rbd.cc +++ b/src/test/cls_rbd/test_cls_rbd.cc @@ -14,6 +14,7 @@ #include "cls/rbd/cls_rbd.h" #include "cls/rbd/cls_rbd_client.h" #include "cls/rbd/cls_rbd_types.h" +#include "librbd/Types.h" #include "gtest/gtest.h" #include "test/librados/test.h" @@ -24,8 +25,7 @@ using namespace std; using namespace librbd::cls_client; -using ::librbd::ParentInfo; -using ::librbd::ParentSpec; +using ::librbd::ParentImageInfo; using ceph::encode; using ceph::decode; @@ -196,7 +196,7 @@ TEST_F(TestClsRbd, add_remove_child) snapid_t snapid(10); string parent_image = "parent_id"; setchildren; - ParentSpec pspec(ioctx.get_id(), parent_image, snapid); + cls::rbd::ParentImageSpec pspec(ioctx.get_id(), "", parent_image, snapid); // nonexistent children cannot be listed or removed ASSERT_EQ(-ENOENT, get_children(&ioctx, oid, pspec, children)); @@ -651,7 +651,7 @@ TEST_F(TestClsRbd, parents_v1) librados::IoCtx ioctx; ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx)); - ParentSpec pspec; + cls::rbd::ParentImageSpec pspec; uint64_t size; ASSERT_EQ(-ENOENT, get_parent(&ioctx, "doesnotexist", CEPH_NOSNAP, &pspec, &size)); @@ -665,8 +665,8 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_STREQ("", pspec.image_id.c_str()); ASSERT_EQ(pspec.snap_id, CEPH_NOSNAP); ASSERT_EQ(size, 0ULL); - pspec = ParentSpec(-1, "parent", 3); - ASSERT_EQ(-ENOEXEC, set_parent(&ioctx, oid, ParentSpec(-1, "parent", 3), 10<<20)); + pspec = {-1, "", "parent", 3}; + ASSERT_EQ(-ENOEXEC, set_parent(&ioctx, oid, {-1, "", "parent", 3}, 10<<20)); ASSERT_EQ(-ENOEXEC, remove_parent(&ioctx, oid)); // new image will work @@ -679,15 +679,15 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(0, get_parent(&ioctx, oid, 123, &pspec, &size)); ASSERT_EQ(-1, pspec.pool_id); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, ParentSpec(-1, "parent", 3), 10<<20)); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, ParentSpec(1, "", 3), 10<<20)); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, ParentSpec(1, "parent", CEPH_NOSNAP), 10<<20)); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 0)); + ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, {-1, "", "parent", 3}, 10<<20)); + ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, {1, "", "", 3}, 10<<20)); + ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, {1, "", "parent", CEPH_NOSNAP}, 10<<20)); + ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, {1, "", "parent", 3}, 0)); - pspec = ParentSpec(1, "parent", 3); + pspec = {1, "", "parent", 3}; ASSERT_EQ(0, set_parent(&ioctx, oid, pspec, 10<<20)); ASSERT_EQ(-EEXIST, set_parent(&ioctx, oid, pspec, 10<<20)); - ASSERT_EQ(-EEXIST, set_parent(&ioctx, oid, ParentSpec(2, "parent", 34), 10<<20)); + ASSERT_EQ(-EEXIST, set_parent(&ioctx, oid, {2, "", "parent", 34}, 10<<20)); ASSERT_EQ(0, get_parent(&ioctx, oid, CEPH_NOSNAP, &pspec, &size)); ASSERT_EQ(pspec.pool_id, 1); @@ -700,7 +700,7 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(-1, pspec.pool_id); // snapshots - ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 10<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 3}, 10<<20)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 10, "snap1")); ASSERT_EQ(0, get_parent(&ioctx, oid, 10, &pspec, &size)); ASSERT_EQ(pspec.pool_id, 1); @@ -709,7 +709,7 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(size, 10ull<<20); ASSERT_EQ(0, remove_parent(&ioctx, oid)); - ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 5<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 3}, 5<<20)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 11, "snap2")); ASSERT_EQ(0, get_parent(&ioctx, oid, 10, &pspec, &size)); ASSERT_EQ(pspec.pool_id, 1); @@ -738,7 +738,7 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(-1, pspec.pool_id); // make sure set_parent takes min of our size and parent's size - ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 1<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 3}, 1<<20)); ASSERT_EQ(0, get_parent(&ioctx, oid, CEPH_NOSNAP, &pspec, &size)); ASSERT_EQ(pspec.pool_id, 1); ASSERT_EQ(pspec.image_id, "parent"); @@ -746,7 +746,7 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(size, 1ull<<20); ASSERT_EQ(0, remove_parent(&ioctx, oid)); - ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 100<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 3}, 100<<20)); ASSERT_EQ(0, get_parent(&ioctx, oid, CEPH_NOSNAP, &pspec, &size)); ASSERT_EQ(pspec.pool_id, 1); ASSERT_EQ(pspec.image_id, "parent"); @@ -755,7 +755,7 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(0, remove_parent(&ioctx, oid)); // make sure resize adjust parent overlap - ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 10<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 3}, 10<<20)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 14, "snap4")); ASSERT_EQ(0, set_size(&ioctx, oid, 3 << 20)); @@ -806,7 +806,7 @@ TEST_F(TestClsRbd, parents_v1) ASSERT_EQ(0, create_image(&ioctx, oid, 33<<20, 22, RBD_FEATURE_LAYERING | RBD_FEATURE_DEEP_FLATTEN, "foo.", -1)); - ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 100<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 3}, 100<<20)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 1, "snap1")); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 2, "snap2")); ASSERT_EQ(0, remove_parent(&ioctx, oid)); @@ -931,7 +931,7 @@ TEST_F(TestClsRbd, parents_v2) ASSERT_EQ(0, parent_detach(&ioctx, oid)); ASSERT_EQ(-ENOENT, parent_detach(&ioctx, oid)); - ParentSpec on_disk_parent_spec; + cls::rbd::ParentImageSpec on_disk_parent_spec; uint64_t legacy_parent_overlap; ASSERT_EQ(-EXDEV, get_parent(&ioctx, oid, CEPH_NOSNAP, &on_disk_parent_spec, &legacy_parent_overlap)); @@ -965,7 +965,7 @@ TEST_F(TestClsRbd, snapshots) std::string snap_name; uint64_t snap_size; uint8_t snap_order; - ParentInfo parent; + ParentImageInfo parent; uint8_t protection_status; utime_t snap_timestamp; @@ -2737,7 +2737,7 @@ TEST_F(TestClsRbd, clone_child) ASSERT_EQ(0, create_image(&ioctx, oid, 0, 22, RBD_FEATURE_LAYERING | RBD_FEATURE_DEEP_FLATTEN, oid, -1)); - ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "parent", 2}, 1)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 2}, 1)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 123, "user_snap1")); ASSERT_EQ(0, op_features_set(&ioctx, oid, RBD_OPERATION_FEATURE_CLONE_CHILD, RBD_OPERATION_FEATURE_CLONE_CHILD)); @@ -2749,7 +2749,7 @@ TEST_F(TestClsRbd, clone_child) ASSERT_TRUE((op_features & RBD_OPERATION_FEATURE_CLONE_CHILD) == 0ULL); ASSERT_EQ(0, set_features(&ioctx, oid, 0, RBD_FEATURE_DEEP_FLATTEN)); - ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "parent", 2}, 1)); + ASSERT_EQ(0, set_parent(&ioctx, oid, {1, "", "parent", 2}, 1)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 124, "user_snap2")); ASSERT_EQ(0, op_features_set(&ioctx, oid, RBD_OPERATION_FEATURE_CLONE_CHILD, RBD_OPERATION_FEATURE_CLONE_CHILD)); diff --git a/src/test/librbd/deep_copy/test_mock_SetHeadRequest.cc b/src/test/librbd/deep_copy/test_mock_SetHeadRequest.cc index 3eef98a6117..42bf0baa3c9 100644 --- a/src/test/librbd/deep_copy/test_mock_SetHeadRequest.cc +++ b/src/test/librbd/deep_copy/test_mock_SetHeadRequest.cc @@ -140,7 +140,7 @@ public: MockSetHeadRequest *create_request( librbd::MockTestImageCtx &mock_local_image_ctx, uint64_t size, - const librbd::ParentSpec &parent_spec, uint64_t parent_overlap, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { return new MockSetHeadRequest(&mock_local_image_ctx, size, parent_spec, parent_overlap, on_finish); @@ -230,7 +230,7 @@ TEST_F(TestMockDeepCopySetHeadRequest, RemoveSetParent) { C_SaferCond ctx; auto request = create_request(mock_image_ctx, m_image_ctx->size, - {123, "test", 0}, 0, &ctx); + {123, "", "test", 0}, 0, &ctx); request->send(); ASSERT_EQ(0, ctx.wait()); } @@ -247,7 +247,7 @@ TEST_F(TestMockDeepCopySetHeadRequest, SetParentSpec) { C_SaferCond ctx; auto request = create_request(mock_image_ctx, m_image_ctx->size, - {123, "test", 0}, 0, &ctx); + {123, "", "test", 0}, 0, &ctx); request->send(); ASSERT_EQ(0, ctx.wait()); } @@ -257,7 +257,7 @@ TEST_F(TestMockDeepCopySetHeadRequest, SetParentOverlap) { librbd::MockExclusiveLock mock_exclusive_lock; mock_image_ctx.exclusive_lock = &mock_exclusive_lock; - mock_image_ctx.parent_md.spec = {123, "test", 0}; + mock_image_ctx.parent_md.spec = {123, "", "test", 0}; mock_image_ctx.parent_md.overlap = m_image_ctx->size; InSequence seq; @@ -284,7 +284,7 @@ TEST_F(TestMockDeepCopySetHeadRequest, SetParentError) { C_SaferCond ctx; auto request = create_request(mock_image_ctx, m_image_ctx->size, - {123, "test", 0}, 0, &ctx); + {123, "", "test", 0}, 0, &ctx); request->send(); ASSERT_EQ(-ESTALE, ctx.wait()); } diff --git a/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc b/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc index 18e0614ccdd..44eb4b2bb51 100644 --- a/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc +++ b/src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc @@ -35,7 +35,7 @@ public: static SetHeadRequest* create(librbd::MockTestImageCtx *image_ctx, uint64_t size, - const librbd::ParentSpec &parent_spec, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { ceph_assert(s_instance != nullptr); s_instance->on_finish = on_finish; @@ -56,7 +56,7 @@ struct SnapshotCreateRequest { const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::ParentSpec &parent_spec, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { ceph_assert(s_instance != nullptr); diff --git a/src/test/librbd/deep_copy/test_mock_SnapshotCreateRequest.cc b/src/test/librbd/deep_copy/test_mock_SnapshotCreateRequest.cc index 88e9359e1c7..64d2d11d710 100644 --- a/src/test/librbd/deep_copy/test_mock_SnapshotCreateRequest.cc +++ b/src/test/librbd/deep_copy/test_mock_SnapshotCreateRequest.cc @@ -34,7 +34,7 @@ public: static SetHeadRequest* create(librbd::MockTestImageCtx *image_ctx, uint64_t size, - const librbd::ParentSpec &parent_spec, + const cls::rbd::ParentImageSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { ceph_assert(s_instance != nullptr); s_instance->on_finish = on_finish; @@ -136,7 +136,7 @@ public: const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::ParentSpec &spec, + const cls::rbd::ParentImageSpec &spec, uint64_t parent_overlap, Context *on_finish) { return new MockSnapshotCreateRequest(&mock_local_image_ctx, snap_name, snap_namespace, size, diff --git a/src/test/librbd/image/test_mock_DetachChildRequest.cc b/src/test/librbd/image/test_mock_DetachChildRequest.cc index 58c6378ac1e..37f38c63c9a 100644 --- a/src/test/librbd/image/test_mock_DetachChildRequest.cc +++ b/src/test/librbd/image/test_mock_DetachChildRequest.cc @@ -145,7 +145,7 @@ TEST_F(TestMockImageDetachChildRequest, SuccessV1) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, false); @@ -161,7 +161,7 @@ TEST_F(TestMockImageDetachChildRequest, SuccessV2) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -184,7 +184,7 @@ TEST_F(TestMockImageDetachChildRequest, TrashedSnapshotSuccess) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -210,7 +210,7 @@ TEST_F(TestMockImageDetachChildRequest, TrashedSnapshotInUse) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -233,7 +233,7 @@ TEST_F(TestMockImageDetachChildRequest, TrashedSnapshotSnapshotGetError) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -256,7 +256,7 @@ TEST_F(TestMockImageDetachChildRequest, TrashedSnapshotOpenParentError) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -281,7 +281,7 @@ TEST_F(TestMockImageDetachChildRequest, TrashedSnapshotRemoveError) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -317,7 +317,7 @@ TEST_F(TestMockImageDetachChildRequest, ChildDetachError) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, true); @@ -336,7 +336,7 @@ TEST_F(TestMockImageDetachChildRequest, RemoveChildError) { REQUIRE_FEATURE(RBD_FEATURE_LAYERING); MockTestImageCtx mock_image_ctx(*image_ctx); - mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "parent id", 234}; + mock_image_ctx.parent_md.spec = {m_ioctx.get_id(), "", "parent id", 234}; InSequence seq; expect_test_op_features(mock_image_ctx, false); diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc index 2b5c8422e77..24cb22602f9 100644 --- a/src/test/librbd/image/test_mock_RefreshRequest.cc +++ b/src/test/librbd/image/test_mock_RefreshRequest.cc @@ -40,7 +40,7 @@ template <> struct RefreshParentRequest { static RefreshParentRequest* s_instance; static RefreshParentRequest* create(MockRefreshImageCtx &mock_image_ctx, - const ParentInfo &parent_md, + const ParentImageInfo &parent_md, const MigrationInfo &migration_info, Context *on_finish) { ceph_assert(s_instance != nullptr); @@ -48,7 +48,7 @@ struct RefreshParentRequest { return s_instance; } static bool is_refresh_required(MockRefreshImageCtx &mock_image_ctx, - const ParentInfo& parent_md, + const ParentImageInfo& parent_md, const MigrationInfo &migration_info) { ceph_assert(s_instance != nullptr); return s_instance->is_refresh_required(); diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index 0764c391774..028f4fba41f 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -173,8 +173,8 @@ struct MockImageCtx { MOCK_CONST_METHOD2(get_snap_namespace, int(librados::snap_t, cls::rbd::SnapshotNamespace *out_snap_namespace)); MOCK_CONST_METHOD2(get_parent_spec, int(librados::snap_t in_snap_id, - ParentSpec *pspec)); - MOCK_CONST_METHOD1(get_parent_info, const ParentInfo*(librados::snap_t)); + cls::rbd::ParentImageSpec *pspec)); + MOCK_CONST_METHOD1(get_parent_info, const ParentImageInfo*(librados::snap_t)); MOCK_CONST_METHOD2(get_parent_overlap, int(librados::snap_t in_snap_id, uint64_t *overlap)); MOCK_CONST_METHOD2(prune_parent_extents, uint64_t(vector >& , @@ -195,7 +195,7 @@ struct MockImageCtx { MOCK_METHOD8(add_snap, void(cls::rbd::SnapshotNamespace in_snap_namespace, std::string in_snap_name, librados::snap_t id, - uint64_t in_size, const ParentInfo &parent, + uint64_t in_size, const ParentImageInfo &parent, uint8_t protection_status, uint64_t flags, utime_t timestamp)); MOCK_METHOD3(rm_snap, void(cls::rbd::SnapshotNamespace in_snap_namespace, std::string in_snap_name, @@ -280,7 +280,7 @@ struct MockImageCtx { std::string header_oid; std::string id; std::string name; - ParentInfo parent_md; + ParentImageInfo parent_md; MigrationInfo migration_info; char *format_string; cls::rbd::GroupSpec group_spec; diff --git a/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc b/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc index 36d74c0053e..87e1f287922 100644 --- a/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc +++ b/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc @@ -129,7 +129,7 @@ public: if (r < 0) { expect.WillOnce(Return(r)); } else { - ParentSpec &parent_spec = mock_image_ctx.snap_info.rbegin()->second.parent.spec; + auto &parent_spec = mock_image_ctx.snap_info.rbegin()->second.parent.spec; expect.WillOnce(DoAll(SetArgPointee<1>(parent_spec), Return(0))); } diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc index 7cda68e9c8f..9056cc49a9f 100644 --- a/src/test/librbd/test_internal.cc +++ b/src/test/librbd/test_internal.cc @@ -729,7 +729,7 @@ TEST_F(TestInternal, ResizeCopyup) { // hide the parent from the snapshot RWLock::WLocker snap_locker(ictx2->snap_lock); - ictx2->snap_info.begin()->second.parent = librbd::ParentInfo(); + ictx2->snap_info.begin()->second.parent = librbd::ParentImageInfo(); } librbd::io::ReadResult read_result{&read_bl}; @@ -796,7 +796,7 @@ TEST_F(TestInternal, DiscardCopyup) { // hide the parent from the snapshot RWLock::WLocker snap_locker(ictx2->snap_lock); - ictx2->snap_info.begin()->second.parent = librbd::ParentInfo(); + ictx2->snap_info.begin()->second.parent = librbd::ParentImageInfo(); } librbd::io::ReadResult read_result{&read_bl}; diff --git a/src/test/rbd_mirror/test_ImageReplayer.cc b/src/test/rbd_mirror/test_ImageReplayer.cc index e3aa540b5fc..122182d7e42 100644 --- a/src/test/rbd_mirror/test_ImageReplayer.cc +++ b/src/test/rbd_mirror/test_ImageReplayer.cc @@ -800,7 +800,7 @@ TEST_F(TestImageReplayer, MultipleReplayFailures_SingleEpoch) { ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(), "foo")); ASSERT_EQ(0, librbd::cls_client::add_child(&ictx->md_ctx, RBD_CHILDREN, - {ictx->md_ctx.get_id(), + {ictx->md_ctx.get_id(), "", ictx->id, ictx->snap_ids[{cls::rbd::UserSnapshotNamespace(), "foo"}]}, "dummy child id")); @@ -853,7 +853,7 @@ TEST_F(TestImageReplayer, MultipleReplayFailures_MultiEpoch) { ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(), "foo")); ASSERT_EQ(0, librbd::cls_client::add_child(&ictx->md_ctx, RBD_CHILDREN, - {ictx->md_ctx.get_id(), + {ictx->md_ctx.get_id(), "", ictx->id, ictx->snap_ids[{cls::rbd::UserSnapshotNamespace(), "foo"}]}, diff --git a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h index 22c4aa0100b..0b20da52920 100644 --- a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h +++ b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h @@ -101,10 +101,10 @@ private: std::string m_local_parent_mirror_uuid; Journaler *m_remote_journaler = nullptr; ImageCtxT *m_remote_parent_image_ctx = nullptr; - librbd::ParentSpec m_remote_parent_spec; + cls::rbd::ParentImageSpec m_remote_parent_spec; librados::IoCtx m_local_parent_io_ctx; - librbd::ParentSpec m_local_parent_spec; + cls::rbd::ParentImageSpec m_local_parent_spec; bufferlist m_out_bl; std::string m_parent_global_image_id;