From: Jason Dillaman Date: Thu, 2 Feb 2017 17:05:47 +0000 (-0500) Subject: librbd: rename parent_spec/parent_info type to match code style specs X-Git-Tag: v12.0.1~112^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=52eb673092c1d0d239c513ab9c9131e5ffe0e615;p=ceph-ci.git librbd: rename parent_spec/parent_info type to match code style specs This also includes a consolidation of SnapInfo, ParentSpec, and ParentInfo into a single header. Signed-off-by: Jason Dillaman --- diff --git a/src/cls/rbd/cls_rbd.h b/src/cls/rbd/cls_rbd.h index 88f0bbccd93..c1f17b845e5 100644 --- a/src/cls/rbd/cls_rbd.h +++ b/src/cls/rbd/cls_rbd.h @@ -5,8 +5,8 @@ #include "include/types.h" #include "include/buffer_fwd.h" +#include "include/rbd_types.h" #include "common/Formatter.h" -#include "librbd/parent_types.h" #include "cls/rbd/cls_rbd_types.h" /// information about our parent image, if any diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index ca1768710ed..ed60a2f3a99 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -83,7 +83,7 @@ namespace librbd { std::map *lockers, bool *exclusive_lock, std::string *lock_tag, - ::SnapContext *snapc, parent_info *parent) { + ::SnapContext *snapc, ParentInfo *parent) { assert(size); assert(features); assert(incompatible_features); @@ -132,7 +132,7 @@ namespace librbd { bool *exclusive_lock, string *lock_tag, ::SnapContext *snapc, - parent_info *parent) + ParentInfo *parent) { librados::ObjectReadOperation op; get_mutable_metadata_start(&op, read_only); @@ -297,7 +297,7 @@ namespace librbd { } int get_parent(librados::IoCtx *ioctx, const std::string &oid, - snapid_t snap_id, parent_spec *pspec, + snapid_t snap_id, ParentSpec *pspec, uint64_t *parent_overlap) { bufferlist inbl, outbl; @@ -321,7 +321,7 @@ namespace librbd { } int set_parent(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, uint64_t parent_overlap) + const ParentSpec &pspec, uint64_t parent_overlap) { librados::ObjectWriteOperation op; set_parent(&op, pspec, parent_overlap); @@ -329,7 +329,7 @@ namespace librbd { } void set_parent(librados::ObjectWriteOperation *op, - parent_spec pspec, uint64_t parent_overlap) { + const ParentSpec &pspec, uint64_t parent_overlap) { bufferlist in_bl; ::encode(pspec.pool_id, in_bl); ::encode(pspec.image_id, in_bl); @@ -409,7 +409,7 @@ namespace librbd { } int add_child(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, const std::string &c_imageid) + const ParentSpec &pspec, const std::string &c_imageid) { bufferlist in, out; ::encode(pspec.pool_id, in); @@ -421,7 +421,7 @@ namespace librbd { } void remove_child(librados::ObjectWriteOperation *op, - parent_spec pspec, const std::string &c_imageid) + const ParentSpec &pspec, const std::string &c_imageid) { bufferlist in; ::encode(pspec.pool_id, in); @@ -432,7 +432,7 @@ namespace librbd { } int remove_child(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, const std::string &c_imageid) + const ParentSpec &pspec, const std::string &c_imageid) { librados::ObjectWriteOperation op; remove_child(&op, pspec, c_imageid); @@ -440,7 +440,7 @@ namespace librbd { } void get_children_start(librados::ObjectReadOperation *op, - const parent_spec &pspec) { + const ParentSpec &pspec) { bufferlist in_bl; ::encode(pspec.pool_id, in_bl); ::encode(pspec.image_id, in_bl); @@ -459,7 +459,7 @@ namespace librbd { } int get_children(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, set& children) + const ParentSpec &pspec, set& children) { librados::ObjectReadOperation op; get_children_start(&op, pspec); @@ -542,7 +542,7 @@ namespace librbd { const std::vector &ids, std::vector *names, std::vector *sizes, - std::vector *parents, + std::vector *parents, std::vector *protection_statuses) { names->resize(ids.size()); @@ -575,7 +575,7 @@ namespace librbd { const std::vector &ids, std::vector *names, std::vector *sizes, - std::vector *parents, + std::vector *parents, std::vector *protection_statuses) { librados::ObjectReadOperation op; diff --git a/src/cls/rbd/cls_rbd_client.h b/src/cls/rbd/cls_rbd_client.h index 6e928dcee44..81f799b04a8 100644 --- a/src/cls/rbd/cls_rbd_client.h +++ b/src/cls/rbd/cls_rbd_client.h @@ -10,7 +10,7 @@ #include "common/snap_types.h" #include "include/rados/librados.hpp" #include "include/types.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include #include @@ -35,7 +35,7 @@ namespace librbd { std::map *lockers, bool *exclusive_lock, std::string *lock_tag, - ::SnapContext *snapc, parent_info *parent); + ::SnapContext *snapc, ParentInfo *parent); int get_mutable_metadata(librados::IoCtx *ioctx, const std::string &oid, bool read_only, uint64_t *size, uint64_t *features, uint64_t *incompatible_features, @@ -44,7 +44,7 @@ namespace librbd { bool *exclusive_lock, std::string *lock_tag, ::SnapContext *snapc, - parent_info *parent); + ParentInfo *parent); // low-level interface (mainly for testing) void create_image(librados::ObjectWriteOperation *op, uint64_t size, @@ -71,12 +71,12 @@ namespace librbd { uint64_t size); void set_size(librados::ObjectWriteOperation *op, uint64_t size); int get_parent(librados::IoCtx *ioctx, const std::string &oid, - snapid_t snap_id, parent_spec *pspec, + snapid_t snap_id, ParentSpec *pspec, uint64_t *parent_overlap); int set_parent(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, uint64_t parent_overlap); + const ParentSpec &pspec, uint64_t parent_overlap); void set_parent(librados::ObjectWriteOperation *op, - parent_spec pspec, uint64_t parent_overlap); + const ParentSpec &pspec, uint64_t parent_overlap); void get_flags_start(librados::ObjectReadOperation *op, const std::vector &snap_ids); int get_flags_finish(bufferlist::iterator *it, uint64_t *flags, @@ -90,17 +90,17 @@ namespace librbd { int remove_parent(librados::IoCtx *ioctx, const std::string &oid); void remove_parent(librados::ObjectWriteOperation *op); int add_child(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, const std::string &c_imageid); + const ParentSpec &pspec, const std::string &c_imageid); void remove_child(librados::ObjectWriteOperation *op, - parent_spec pspec, const std::string &c_imageid); + const ParentSpec &pspec, const std::string &c_imageid); int remove_child(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, const std::string &c_imageid); + const ParentSpec &pspec, const std::string &c_imageid); void get_children_start(librados::ObjectReadOperation *op, - const parent_spec &pspec); + const ParentSpec &pspec); int get_children_finish(bufferlist::iterator *it, std::set *children); int get_children(librados::IoCtx *ioctx, const std::string &oid, - parent_spec pspec, set& children); + const ParentSpec &pspec, set& children); void snapshot_add(librados::ObjectWriteOperation *op, snapid_t snap_id, const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace); @@ -117,7 +117,7 @@ namespace librbd { const std::vector &ids, std::vector *names, std::vector *sizes, - std::vector *parents, + std::vector *parents, std::vector *protection_statuses); void snapshot_timestamp_list_start(librados::ObjectReadOperation *op, const std::vector &ids); @@ -134,7 +134,7 @@ namespace librbd { const std::vector &ids, std::vector *names, std::vector *sizes, - std::vector *parents, + std::vector *parents, std::vector *protection_statuses); void snapshot_namespace_list_start(librados::ObjectReadOperation *op, diff --git a/src/include/rbd_types.h b/src/include/rbd_types.h index 845a94e1ebd..cb00d3db48d 100644 --- a/src/include/rbd_types.h +++ b/src/include/rbd_types.h @@ -133,4 +133,11 @@ struct rbd_obj_header_ondisk { struct rbd_obj_snap_ondisk snaps[0]; } __attribute__((packed)); +enum { + RBD_PROTECTION_STATUS_UNPROTECTED = 0, + RBD_PROTECTION_STATUS_UNPROTECTING = 1, + RBD_PROTECTION_STATUS_PROTECTED = 2, + RBD_PROTECTION_STATUS_LAST = 3 +}; + #endif diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 0dcd7880b86..0fe40b5166b 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -480,7 +480,7 @@ struct C_InvalidateCache : public Context { } int ImageCtx::get_parent_spec(snap_t in_snap_id, - parent_spec *out_pspec) const + ParentSpec *out_pspec) const { const SnapInfo *info = get_snap_info(in_snap_id); if (info) { @@ -551,7 +551,7 @@ struct C_InvalidateCache : public Context { void ImageCtx::add_snap(string in_snap_name, cls::rbd::SnapshotNamespace in_snap_namespace, snap_t id, uint64_t in_size, - parent_info parent, uint8_t protection_status, + const ParentInfo &parent, uint8_t protection_status, uint64_t flags, utime_t timestamp) { assert(snap_lock.is_wlocked()); @@ -658,7 +658,7 @@ struct C_InvalidateCache : public Context { return 0; } - const parent_info* ImageCtx::get_parent_info(snap_t in_snap_id) const + const ParentInfo* ImageCtx::get_parent_info(snap_t in_snap_id) const { assert(snap_lock.is_locked()); assert(parent_lock.is_locked()); @@ -672,7 +672,7 @@ struct C_InvalidateCache : public Context { int64_t ImageCtx::get_parent_pool_id(snap_t in_snap_id) const { - const parent_info *info = get_parent_info(in_snap_id); + const ParentInfo *info = get_parent_info(in_snap_id); if (info) return info->spec.pool_id; return -1; @@ -680,7 +680,7 @@ struct C_InvalidateCache : public Context { string ImageCtx::get_parent_image_id(snap_t in_snap_id) const { - const parent_info *info = get_parent_info(in_snap_id); + const ParentInfo *info = get_parent_info(in_snap_id); if (info) return info->spec.image_id; return ""; @@ -688,7 +688,7 @@ struct C_InvalidateCache : public Context { uint64_t ImageCtx::get_parent_snap_id(snap_t in_snap_id) const { - const parent_info *info = get_parent_info(in_snap_id); + const ParentInfo *info = get_parent_info(in_snap_id); if (info) return info->spec.snap_id; return CEPH_NOSNAP; @@ -697,7 +697,7 @@ struct C_InvalidateCache : public Context { int ImageCtx::get_parent_overlap(snap_t in_snap_id, uint64_t *overlap) const { assert(snap_lock.is_locked()); - const parent_info *info = get_parent_info(in_snap_id); + const ParentInfo *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 bd9465dabb0..e264fbb5759 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -26,8 +26,7 @@ #include "cls/rbd/cls_rbd_types.h" #include "cls/rbd/cls_rbd_client.h" #include "librbd/AsyncRequest.h" -#include "librbd/SnapInfo.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" class CephContext; class ContextWQ; @@ -122,7 +121,7 @@ namespace librbd { char *format_string; std::string header_oid; std::string id; // only used for new-format images - parent_info parent_md; + ParentInfo parent_md; ImageCtx *parent; cls::rbd::GroupSpec group_spec; uint64_t stripe_unit, stripe_count; @@ -237,7 +236,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, - parent_spec *pspec) const; + ParentSpec *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, @@ -253,7 +252,7 @@ namespace librbd { void add_snap(std::string in_snap_name, cls::rbd::SnapshotNamespace in_snap_namespace, librados::snap_t id, - uint64_t in_size, parent_info parent, + uint64_t in_size, const ParentInfo &parent, uint8_t protection_status, uint64_t flags, utime_t timestamp); void rm_snap(std::string in_snap_name, librados::snap_t id); uint64_t get_image_size(librados::snap_t in_snap_id) const; @@ -266,7 +265,7 @@ namespace librbd { bool test_flags(uint64_t test_flags, const RWLock &in_snap_lock) const; int update_flags(librados::snap_t in_snap_id, uint64_t flag, bool enabled); - const parent_info* get_parent_info(librados::snap_t in_snap_id) const; + const ParentInfo* 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/SnapInfo.h b/src/librbd/SnapInfo.h deleted file mode 100644 index f5de553f49a..00000000000 --- a/src/librbd/SnapInfo.h +++ /dev/null @@ -1,29 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_SNAPINFO_H -#define CEPH_LIBRBD_SNAPINFO_H - -#include "cls/rbd/cls_rbd_types.h" -#include "include/int_types.h" - -#include "librbd/parent_types.h" - -namespace librbd { - - struct SnapInfo { - std::string name; - cls::rbd::SnapshotNamespace snap_namespace; - uint64_t size; - parent_info parent; - uint8_t protection_status; - uint64_t flags; - utime_t timestamp; - SnapInfo(std::string _name, const cls::rbd::SnapshotNamespace &_snap_namespace, - uint64_t _size, parent_info _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), timestamp(_timestamp) {} - }; -} - -#endif diff --git a/src/librbd/Types.h b/src/librbd/Types.h new file mode 100644 index 00000000000..8efe8a7763c --- /dev/null +++ b/src/librbd/Types.h @@ -0,0 +1,73 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef LIBRBD_TYPES_H +#define LIBRBD_TYPES_H + +#include "include/types.h" +#include "cls/rbd/cls_rbd_types.h" +#include + +namespace librbd { + +/** @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 { + /// Identification of the parent. + ParentSpec 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) { + } +}; + +struct SnapInfo { + std::string name; + cls::rbd::SnapshotNamespace snap_namespace; + uint64_t size; + ParentInfo 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, + 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), + timestamp(_timestamp) { + } +}; + +} // namespace librbd + +#endif // LIBRBD_TYPES_H diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index 28058abe7b5..31d079b2259 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 parent_info &parent_md, + const ParentInfo &parent_md, Context *on_finish) : m_child_image_ctx(child_image_ctx), m_parent_md(parent_md), m_on_finish(on_finish), m_parent_image_ctx(nullptr), @@ -33,7 +33,7 @@ RefreshParentRequest::RefreshParentRequest(I &child_image_ctx, template bool RefreshParentRequest::is_refresh_required(I &child_image_ctx, - const parent_info &parent_md) { + const ParentInfo &parent_md) { assert(child_image_ctx.snap_lock.is_locked()); assert(child_image_ctx.parent_lock.is_locked()); return (is_open_required(child_image_ctx, parent_md) || @@ -42,14 +42,14 @@ bool RefreshParentRequest::is_refresh_required(I &child_image_ctx, template bool RefreshParentRequest::is_close_required(I &child_image_ctx, - const parent_info &parent_md) { + const ParentInfo &parent_md) { return (child_image_ctx.parent != nullptr && (parent_md.spec.pool_id == -1 || parent_md.overlap == 0)); } template bool RefreshParentRequest::is_open_required(I &child_image_ctx, - const parent_info &parent_md) { + const ParentInfo &parent_md) { return (parent_md.spec.pool_id > -1 && parent_md.overlap > 0 && (child_image_ctx.parent == nullptr || child_image_ctx.parent->md_ctx.get_id() != parent_md.spec.pool_id || diff --git a/src/librbd/image/RefreshParentRequest.h b/src/librbd/image/RefreshParentRequest.h index 3fe653952c9..ed65b9a7514 100644 --- a/src/librbd/image/RefreshParentRequest.h +++ b/src/librbd/image/RefreshParentRequest.h @@ -5,7 +5,7 @@ #define CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H #include "include/int_types.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" class Context; @@ -19,13 +19,13 @@ template class RefreshParentRequest { public: static RefreshParentRequest *create(ImageCtxT &child_image_ctx, - const parent_info &parent_md, + const ParentInfo &parent_md, Context *on_finish) { return new RefreshParentRequest(child_image_ctx, parent_md, on_finish); } static bool is_refresh_required(ImageCtxT &child_image_ctx, - const parent_info &parent_md); + const ParentInfo &parent_md); void send(); void apply(); @@ -55,11 +55,11 @@ private: * @endverbatim */ - RefreshParentRequest(ImageCtxT &child_image_ctx, const parent_info &parent_md, + RefreshParentRequest(ImageCtxT &child_image_ctx, const ParentInfo &parent_md, Context *on_finish); ImageCtxT &m_child_image_ctx; - parent_info m_parent_md; + ParentInfo m_parent_md; Context *m_on_finish; ImageCtxT *m_parent_image_ctx; @@ -68,9 +68,9 @@ private: int m_error_result; static bool is_close_required(ImageCtxT &child_image_ctx, - const parent_info &parent_md); + const ParentInfo &parent_md); static bool is_open_required(ImageCtxT &child_image_ctx, - const parent_info &parent_md); + const ParentInfo &parent_md); void send_open_parent(); Context *handle_open_parent(int *result); diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index 214824831f5..86691b5baa7 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -541,7 +541,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); - parent_info parent_md; + ParentInfo parent_md; int r = get_parent_info(m_image_ctx.snap_id, &parent_md); if (!m_skip_open_parent_image && (r < 0 || RefreshParentRequest::is_refresh_required(m_image_ctx, parent_md))) { @@ -1044,7 +1044,7 @@ void RefreshRequest::apply() { uint8_t protection_status = m_image_ctx.old_format ? static_cast(RBD_PROTECTION_STATUS_UNPROTECTED) : m_snap_protection[i]; - parent_info parent; + ParentInfo parent; if (!m_image_ctx.old_format) { parent = m_snap_parents[i]; } @@ -1105,7 +1105,7 @@ void RefreshRequest::apply() { template int RefreshRequest::get_parent_info(uint64_t snap_id, - parent_info *parent_md) { + ParentInfo *parent_md) { if (snap_id == CEPH_NOSNAP) { *parent_md = m_parent_md; return 0; diff --git a/src/librbd/image/RefreshRequest.h b/src/librbd/image/RefreshRequest.h index 8bc57ae10d7..286703e39d5 100644 --- a/src/librbd/image/RefreshRequest.h +++ b/src/librbd/image/RefreshRequest.h @@ -10,7 +10,7 @@ #include "common/snap_types.h" #include "cls/lock/cls_lock_types.h" #include "librbd/ImageCtx.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include #include @@ -128,14 +128,14 @@ private: uint64_t m_incompatible_features; uint64_t m_flags; std::string m_object_prefix; - parent_info m_parent_md; + ParentInfo m_parent_md; cls::rbd::GroupSpec m_group_spec; ::SnapContext m_snapc; std::vector m_snap_names; std::vector m_snap_namespaces; std::vector m_snap_sizes; - std::vector m_snap_parents; + std::vector m_snap_parents; std::vector m_snap_protection; std::vector m_snap_flags; std::vector m_snap_timestamps; @@ -220,7 +220,7 @@ private: } void apply(); - int get_parent_info(uint64_t snap_id, parent_info *parent_md); + int get_parent_info(uint64_t snap_id, ParentInfo *parent_md); }; } // namespace image diff --git a/src/librbd/image/RemoveRequest.cc b/src/librbd/image/RemoveRequest.cc index ccccc68ac7e..64b83efffc0 100644 --- a/src/librbd/image/RemoveRequest.cc +++ b/src/librbd/image/RemoveRequest.cc @@ -332,7 +332,7 @@ void RemoveRequest::remove_child() { ldout(m_cct, 20) << dendl; m_image_ctx->parent_lock.get_read(); - parent_info parent_info = m_image_ctx->parent_md; + ParentInfo parent_info = m_image_ctx->parent_md; m_image_ctx->parent_lock.put_read(); librados::ObjectWriteOperation op; diff --git a/src/librbd/image/SetSnapRequest.cc b/src/librbd/image/SetSnapRequest.cc index 1b851eb7487..495c3adcfb3 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; - parent_info parent_md; + ParentInfo parent_md; bool refresh_parent; { RWLock::RLocker snap_locker(m_image_ctx.snap_lock); RWLock::RLocker parent_locker(m_image_ctx.parent_lock); - const parent_info *parent_info = m_image_ctx.get_parent_info(m_snap_id); + const ParentInfo *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 1286727f083..f32d0935d05 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -30,7 +30,7 @@ #include "librbd/MirroringWatcher.h" #include "librbd/ObjectMap.h" #include "librbd/Operations.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include "librbd/Utils.h" #include "librbd/exclusive_lock/AutomaticPolicy.h" #include "librbd/exclusive_lock/StandardPolicy.h" @@ -644,7 +644,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, RWLock::RLocker l(ictx->snap_lock); snap_t snap_id = ictx->get_snap_id(snap_name); - parent_spec parent_spec(ictx->md_ctx.get_id(), ictx->id, snap_id); + ParentSpec parent_spec(ictx->md_ctx.get_id(), ictx->id, snap_id); map< pair, set > image_info; int r = list_children_info(ictx, parent_spec, image_info); @@ -689,7 +689,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, if ((imctx->features & RBD_FEATURE_DEEP_FLATTEN) == 0 && !imctx->snaps.empty()) { imctx->parent_lock.get_read(); - parent_info parent_info = imctx->parent_md; + ParentInfo parent_info = imctx->parent_md; imctx->parent_lock.put_read(); r = cls_client::remove_child(&imctx->md_ctx, RBD_CHILDREN, @@ -720,7 +720,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, ldout(cct, 20) << "children list " << ictx->name << dendl; RWLock::RLocker l(ictx->snap_lock); - parent_spec parent_spec(ictx->md_ctx.get_id(), ictx->id, ictx->snap_id); + ParentSpec parent_spec(ictx->md_ctx.get_id(), ictx->id, ictx->snap_id); map< pair, set > image_info; int r = list_children_info(ictx, parent_spec, image_info); @@ -753,7 +753,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, return 0; } - int list_children_info(ImageCtx *ictx, librbd::parent_spec parent_spec, + int list_children_info(ImageCtx *ictx, const ParentSpec &parent_spec, map< pair, set >& image_info) { CephContext *cct = ictx->cct; @@ -1120,7 +1120,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, librbd::NoOpProgressContext no_op; ImageCtx *c_imctx = NULL; map pairs; - parent_spec pspec(p_imctx->md_ctx.get_id(), p_imctx->id, p_imctx->snap_id); + ParentSpec pspec(p_imctx->md_ctx.get_id(), p_imctx->id, p_imctx->snap_id); if (p_imctx->old_format) { lderr(cct) << "parent image must be in new format" << dendl; @@ -1365,7 +1365,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, return -ENOENT; } - parent_spec parent_spec; + ParentSpec parent_spec; if (ictx->snap_id == CEPH_NOSNAP) { parent_spec = ictx->parent_md.spec; @@ -2419,7 +2419,7 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, RWLock::RLocker l(ictx->snap_lock); map snap_info = ictx->snap_info; for (auto &info : snap_info) { - librbd::parent_spec parent_spec(ictx->md_ctx.get_id(), ictx->id, info.first); + ParentSpec parent_spec(ictx->md_ctx.get_id(), ictx->id, info.first); map< pair, set > image_info; r = list_children_info(ictx, parent_spec, image_info); diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 9a21161a3d7..28a3c387528 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -13,9 +13,9 @@ #include "include/buffer_fwd.h" #include "include/rbd/librbd.hpp" #include "include/rbd_types.h" -#include "librbd/parent_types.h" #include "cls/rbd/cls_rbd_types.h" #include "common/WorkQueue.h" +#include "librbd/Types.h" enum { l_librbd_first = 26000, @@ -100,7 +100,7 @@ namespace librbd { int list(librados::IoCtx& io_ctx, std::vector& names); int list_children(ImageCtx *ictx, std::set > & names); - int list_children_info(ImageCtx *ictx, librbd::parent_spec parent_spec, + int list_children_info(ImageCtx *ictx, const ParentSpec &parent_spec, std::map, std::set >& image_info); int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size, int *order); diff --git a/src/librbd/operation/FlattenRequest.h b/src/librbd/operation/FlattenRequest.h index bc1531ddcc7..19637ba2e0a 100644 --- a/src/librbd/operation/FlattenRequest.h +++ b/src/librbd/operation/FlattenRequest.h @@ -4,8 +4,8 @@ #define CEPH_LIBRBD_OPERATION_FLATTEN_REQUEST_H #include "librbd/operation/Request.h" -#include "librbd/parent_types.h" #include "common/snap_types.h" +#include "librbd/Types.h" namespace librbd { @@ -75,7 +75,7 @@ private: ProgressContext &m_prog_ctx; State m_state; - parent_spec m_parent_spec; + ParentSpec m_parent_spec; bool m_ignore_enoent; bool send_update_header(); diff --git a/src/librbd/operation/SnapshotCreateRequest.h b/src/librbd/operation/SnapshotCreateRequest.h index e1e4beb5503..b0f5f06428a 100644 --- a/src/librbd/operation/SnapshotCreateRequest.h +++ b/src/librbd/operation/SnapshotCreateRequest.h @@ -5,8 +5,8 @@ #define CEPH_LIBRBD_OPERATION_SNAPSHOT_CREATE_REQUEST_H #include "cls/rbd/cls_rbd_types.h" +#include "librbd/Types.h" #include "librbd/operation/Request.h" -#include "librbd/parent_types.h" #include class Context; @@ -86,7 +86,7 @@ private: uint64_t m_snap_id; uint64_t m_size; - parent_info m_parent_info; + ParentInfo 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 e056fe45de3..70bbf60e3d9 100644 --- a/src/librbd/operation/SnapshotRemoveRequest.cc +++ b/src/librbd/operation/SnapshotRemoveRequest.cc @@ -132,7 +132,7 @@ void SnapshotRemoveRequest::send_remove_child() { RWLock::RLocker snap_locker(image_ctx.snap_lock); RWLock::RLocker parent_locker(image_ctx.parent_lock); - parent_spec our_pspec; + ParentSpec our_pspec; int r = image_ctx.get_parent_spec(m_snap_id, &our_pspec); if (r < 0) { if (r == -ENOENT) { @@ -218,7 +218,7 @@ void SnapshotRemoveRequest::remove_snap_context() { } template -int SnapshotRemoveRequest::scan_for_parents(parent_spec &pspec) { +int SnapshotRemoveRequest::scan_for_parents(ParentSpec &pspec) { I &image_ctx = this->m_image_ctx; assert(image_ctx.snap_lock.is_locked()); assert(image_ctx.parent_lock.is_locked()); diff --git a/src/librbd/operation/SnapshotRemoveRequest.h b/src/librbd/operation/SnapshotRemoveRequest.h index 40c12c5c923..a3f1d0ed62b 100644 --- a/src/librbd/operation/SnapshotRemoveRequest.h +++ b/src/librbd/operation/SnapshotRemoveRequest.h @@ -5,7 +5,7 @@ #define CEPH_LIBRBD_OPERATION_SNAPSHOT_REMOVE_REQUEST_H #include "librbd/operation/Request.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include class Context; @@ -85,7 +85,7 @@ private: void send_release_snap_id(); void remove_snap_context(); - int scan_for_parents(parent_spec &pspec); + int scan_for_parents(ParentSpec &pspec); }; diff --git a/src/librbd/operation/SnapshotUnprotectRequest.cc b/src/librbd/operation/SnapshotUnprotectRequest.cc index 0660deddb6b..944b7b9e18b 100644 --- a/src/librbd/operation/SnapshotUnprotectRequest.cc +++ b/src/librbd/operation/SnapshotUnprotectRequest.cc @@ -9,7 +9,7 @@ #include "librbd/AsyncObjectThrottle.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include "librbd/Utils.h" #include #include @@ -56,7 +56,7 @@ template class C_ScanPoolChildren : public C_AsyncObjectThrottle { public: C_ScanPoolChildren(AsyncObjectThrottle &throttle, I *image_ctx, - const parent_spec &pspec, const Pools &pools, + const ParentSpec &pspec, const Pools &pools, size_t pool_idx) : C_AsyncObjectThrottle(throttle, *image_ctx), m_pspec(pspec), m_pool(pools[pool_idx]) { @@ -139,7 +139,7 @@ protected: } private: - parent_spec m_pspec; + ParentSpec m_pspec; Pool m_pool; IoCtx m_pool_ioctx; @@ -255,7 +255,7 @@ void SnapshotUnprotectRequest::send_scan_pool_children() { std::list pool_list; rados.pool_list2(pool_list); - parent_spec pspec(image_ctx.md_ctx.get_id(), image_ctx.id, m_snap_id); + ParentSpec pspec(image_ctx.md_ctx.get_id(), image_ctx.id, m_snap_id); Pools pools(pool_list.begin(), pool_list.end()); Context *ctx = this->create_callback_context(); diff --git a/src/librbd/parent_types.h b/src/librbd/parent_types.h deleted file mode 100644 index 69598b73308..00000000000 --- a/src/librbd/parent_types.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_PARENT_TYPES_H -#define CEPH_LIBRBD_PARENT_TYPES_H - -#include "include/int_types.h" -#include "include/types.h" -#include - -namespace librbd { - /** @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 parent_spec { - int64_t pool_id; - std::string image_id; - snapid_t snap_id; - parent_spec() : pool_id(-1), snap_id(CEPH_NOSNAP) {} - parent_spec(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 parent_spec &other) { - return ((this->pool_id == other.pool_id) && - (this->image_id == other.image_id) && - (this->snap_id == other.snap_id)); - } - bool operator!=(const parent_spec &other) { - return !(*this == other); - } - }; - - /// Full information about an image's parent. - struct parent_info { - /// Identification of the parent. - parent_spec 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; - - parent_info() : overlap(0) {} - }; -} - -enum { - RBD_PROTECTION_STATUS_UNPROTECTED = 0, - RBD_PROTECTION_STATUS_UNPROTECTING = 1, - RBD_PROTECTION_STATUS_PROTECTED = 2, - RBD_PROTECTION_STATUS_LAST = 3 -}; - -#endif diff --git a/src/librbd/type.h b/src/librbd/type.h deleted file mode 100644 index 20be5c2e4b7..00000000000 --- a/src/librbd/type.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef LIBRBD_TYPE_H -#define LIBRBD_TYPE_H - -#include - -#endif diff --git a/src/test/cls_rbd/test_cls_rbd.cc b/src/test/cls_rbd/test_cls_rbd.cc index 97fc597a9a5..472ea6ffcc0 100644 --- a/src/test/cls_rbd/test_cls_rbd.cc +++ b/src/test/cls_rbd/test_cls_rbd.cc @@ -23,8 +23,8 @@ using namespace std; using namespace librbd::cls_client; -using ::librbd::parent_info; -using ::librbd::parent_spec; +using ::librbd::ParentInfo; +using ::librbd::ParentSpec; static int snapshot_add(librados::IoCtx *ioctx, const std::string &oid, uint64_t snap_id, const std::string &snap_name) { @@ -192,7 +192,7 @@ TEST_F(TestClsRbd, add_remove_child) snapid_t snapid(10); string parent_image = "parent_id"; setchildren; - parent_spec pspec(ioctx.get_id(), parent_image, snapid); + ParentSpec pspec(ioctx.get_id(), parent_image, snapid); // nonexistent children cannot be listed or removed ASSERT_EQ(-ENOENT, get_children(&ioctx, oid, pspec, children)); @@ -598,7 +598,7 @@ TEST_F(TestClsRbd, parents) ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx)); string oid = get_temp_image_name(); - parent_spec pspec; + ParentSpec pspec; uint64_t size; ASSERT_EQ(-ENOENT, get_parent(&ioctx, "doesnotexist", CEPH_NOSNAP, &pspec, &size)); @@ -611,8 +611,8 @@ TEST_F(TestClsRbd, parents) ASSERT_STREQ("", pspec.image_id.c_str()); ASSERT_EQ(pspec.snap_id, CEPH_NOSNAP); ASSERT_EQ(size, 0ULL); - pspec = parent_spec(-1, "parent", 3); - ASSERT_EQ(-ENOEXEC, set_parent(&ioctx, "old", parent_spec(-1, "parent", 3), 10<<20)); + pspec = ParentSpec(-1, "parent", 3); + ASSERT_EQ(-ENOEXEC, set_parent(&ioctx, "old", ParentSpec(-1, "parent", 3), 10<<20)); ASSERT_EQ(-ENOEXEC, remove_parent(&ioctx, "old")); // new image will work @@ -624,15 +624,15 @@ TEST_F(TestClsRbd, parents) ASSERT_EQ(0, get_parent(&ioctx, oid, 123, &pspec, &size)); ASSERT_EQ(-1, pspec.pool_id); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, parent_spec(-1, "parent", 3), 10<<20)); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, parent_spec(1, "", 3), 10<<20)); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, parent_spec(1, "parent", CEPH_NOSNAP), 10<<20)); - ASSERT_EQ(-EINVAL, set_parent(&ioctx, oid, parent_spec(1, "parent", 3), 0)); + 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)); - pspec = parent_spec(1, "parent", 3); + pspec = ParentSpec(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, parent_spec(2, "parent", 34), 10<<20)); + ASSERT_EQ(-EEXIST, set_parent(&ioctx, oid, ParentSpec(2, "parent", 34), 10<<20)); ASSERT_EQ(0, get_parent(&ioctx, oid, CEPH_NOSNAP, &pspec, &size)); ASSERT_EQ(pspec.pool_id, 1); @@ -645,7 +645,7 @@ TEST_F(TestClsRbd, parents) ASSERT_EQ(-1, pspec.pool_id); // snapshots - ASSERT_EQ(0, set_parent(&ioctx, oid, parent_spec(1, "parent", 3), 10<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(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); @@ -654,7 +654,7 @@ TEST_F(TestClsRbd, parents) ASSERT_EQ(size, 10ull<<20); ASSERT_EQ(0, remove_parent(&ioctx, oid)); - ASSERT_EQ(0, set_parent(&ioctx, oid, parent_spec(4, "parent2", 6), 5<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(4, "parent2", 6), 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); @@ -683,7 +683,7 @@ TEST_F(TestClsRbd, parents) 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, parent_spec(1, "parent", 3), 1<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(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"); @@ -691,7 +691,7 @@ TEST_F(TestClsRbd, parents) ASSERT_EQ(size, 1ull<<20); ASSERT_EQ(0, remove_parent(&ioctx, oid)); - ASSERT_EQ(0, set_parent(&ioctx, oid, parent_spec(1, "parent", 3), 100<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(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"); @@ -700,7 +700,7 @@ TEST_F(TestClsRbd, parents) ASSERT_EQ(0, remove_parent(&ioctx, oid)); // make sure resize adjust parent overlap - ASSERT_EQ(0, set_parent(&ioctx, oid, parent_spec(1, "parent", 3), 10<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(1, "parent", 3), 10<<20)); ASSERT_EQ(0, snapshot_add(&ioctx, oid, 14, "snap4")); ASSERT_EQ(0, set_size(&ioctx, oid, 3 << 20)); @@ -751,7 +751,7 @@ TEST_F(TestClsRbd, parents) 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, parent_spec(1, "parent", 3), 100<<20)); + ASSERT_EQ(0, set_parent(&ioctx, oid, ParentSpec(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)); @@ -781,7 +781,7 @@ TEST_F(TestClsRbd, snapshots) vector snap_namespaces; vector snap_sizes; SnapContext snapc; - vector parents; + vector parents; vector protection_status; vector snap_timestamps; @@ -1127,7 +1127,7 @@ TEST_F(TestClsRbd, get_mutable_metadata_features) bool exclusive_lock; std::string lock_tag; ::SnapContext snapc; - parent_info parent; + ParentInfo parent; ASSERT_EQ(0, get_mutable_metadata(&ioctx, oid, true, &size, &features, &incompatible_features, &lockers, diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc index ea5a5dd2705..d5454785fd4 100644 --- a/src/test/librbd/image/test_mock_RefreshRequest.cc +++ b/src/test/librbd/image/test_mock_RefreshRequest.cc @@ -37,14 +37,14 @@ template <> struct RefreshParentRequest { static RefreshParentRequest* s_instance; static RefreshParentRequest* create(MockRefreshImageCtx &mock_image_ctx, - const parent_info& parent_md, + const ParentInfo& parent_md, Context *on_finish) { assert(s_instance != nullptr); s_instance->on_finish = on_finish; return s_instance; } static bool is_refresh_required(MockRefreshImageCtx &mock_image_ctx, - const parent_info& parent_md) { + const ParentInfo& parent_md) { 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 4d1fc06debe..61ca316515c 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -147,7 +147,7 @@ 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, - parent_spec *pspec)); + ParentSpec *pspec)); MOCK_CONST_METHOD2(is_snap_protected, int(librados::snap_t in_snap_id, bool *is_protected)); @@ -157,7 +157,7 @@ struct MockImageCtx { MOCK_METHOD8(add_snap, void(std::string in_snap_name, cls::rbd::SnapshotNamespace in_snap_namespace, librados::snap_t id, - uint64_t in_size, parent_info parent, + uint64_t in_size, const ParentInfo &parent, uint8_t protection_status, uint64_t flags, utime_t timestamp)); MOCK_METHOD2(rm_snap, void(std::string in_snap_name, librados::snap_t id)); @@ -239,7 +239,7 @@ struct MockImageCtx { std::string header_oid; std::string id; std::string name; - parent_info parent_md; + ParentInfo parent_md; 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 db31a83573c..3209859dd98 100644 --- a/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc +++ b/src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc @@ -63,7 +63,7 @@ public: if (r < 0) { expect.WillOnce(Return(r)); } else { - parent_spec &parent_spec = mock_image_ctx.snap_info.rbegin()->second.parent.spec; + ParentSpec &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 c262a070527..db3bbbffaca 100644 --- a/src/test/librbd/test_internal.cc +++ b/src/test/librbd/test_internal.cc @@ -677,7 +677,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::parent_info(); + ictx2->snap_info.begin()->second.parent = librbd::ParentInfo(); } librbd::io::ReadResult read_result{&read_bl}; @@ -739,7 +739,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::parent_info(); + ictx2->snap_info.begin()->second.parent = librbd::ParentInfo(); } librbd::io::ReadResult read_result{&read_bl}; diff --git a/src/test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc b/src/test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc index 5b2ca67d110..4b2b7df258b 100644 --- a/src/test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc +++ b/src/test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc @@ -47,7 +47,7 @@ struct SnapshotCreateRequest { const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::parent_spec &parent_spec, + const librbd::ParentSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { assert(s_instance != nullptr); diff --git a/src/test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc b/src/test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc index b395b3e7763..236bfe4e617 100644 --- a/src/test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc +++ b/src/test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc @@ -107,7 +107,7 @@ public: const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::parent_spec &spec, + const librbd::ParentSpec &spec, uint64_t parent_overlap, Context *on_finish) { return new MockSnapshotCreateRequest(&mock_local_image_ctx, snap_name, snap_namespace, size, diff --git a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h index 0e5d4833e7e..e920498f15f 100644 --- a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h +++ b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.h @@ -7,7 +7,7 @@ #include "include/int_types.h" #include "include/types.h" #include "include/rados/librados.hpp" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include class Context; @@ -89,11 +89,11 @@ private: librados::IoCtx m_remote_parent_io_ctx; ImageCtxT *m_remote_parent_image_ctx = nullptr; - librbd::parent_spec m_remote_parent_spec; + librbd::ParentSpec m_remote_parent_spec; librados::IoCtx m_local_parent_io_ctx; ImageCtxT *m_local_parent_image_ctx = nullptr; - librbd::parent_spec m_local_parent_spec; + librbd::ParentSpec m_local_parent_spec; bufferlist m_out_bl; std::string m_parent_global_image_id; diff --git a/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc b/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc index 028af8bb346..8e9827e4d65 100644 --- a/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc @@ -64,7 +64,7 @@ SnapshotCopyRequest::SnapshotCopyRequest(I *local_image_ctx, template void SnapshotCopyRequest::send() { - librbd::parent_spec remote_parent_spec; + librbd::ParentSpec remote_parent_spec; int r = validate_parent(m_remote_image_ctx, &remote_parent_spec); if (r < 0) { derr << ": remote image parent spec mismatch" << dendl; @@ -318,7 +318,7 @@ void SnapshotCopyRequest::send_snap_create() { uint64_t size = snap_info_it->second.size; m_snap_namespace = snap_info_it->second.snap_namespace; - librbd::parent_spec parent_spec; + librbd::ParentSpec parent_spec; uint64_t parent_overlap = 0; if (snap_info_it->second.parent.spec.pool_id != -1) { parent_spec = m_local_parent_spec; @@ -534,7 +534,7 @@ void SnapshotCopyRequest::compute_snap_map() { template int SnapshotCopyRequest::validate_parent(I *image_ctx, - librbd::parent_spec *spec) { + librbd::ParentSpec *spec) { RWLock::RLocker owner_locker(image_ctx->owner_lock); RWLock::RLocker snap_locker(image_ctx->snap_lock); diff --git a/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.h b/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.h index bd8b7ef932c..1714ad2dd90 100644 --- a/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.h +++ b/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.h @@ -8,7 +8,7 @@ #include "include/rados/librados.hpp" #include "common/snap_types.h" #include "librbd/ImageCtx.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include "librbd/journal/TypeTraits.h" #include "tools/rbd_mirror/BaseRequest.h" #include @@ -106,7 +106,7 @@ private: std::string m_snap_name; cls::rbd::SnapshotNamespace m_snap_namespace; - librbd::parent_spec m_local_parent_spec; + librbd::ParentSpec m_local_parent_spec; Mutex m_lock; bool m_canceled = false; @@ -132,7 +132,7 @@ private: void compute_snap_map(); - int validate_parent(ImageCtxT *image_ctx, librbd::parent_spec *spec); + int validate_parent(ImageCtxT *image_ctx, librbd::ParentSpec *spec); }; diff --git a/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc b/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc index 8caca612f1d..78317e2dda8 100644 --- a/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc @@ -28,7 +28,7 @@ SnapshotCreateRequest::SnapshotCreateRequest(I *local_image_ctx, const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::parent_spec &spec, + const librbd::ParentSpec &spec, uint64_t parent_overlap, Context *on_finish) : m_local_image_ctx(local_image_ctx), m_snap_name(snap_name), diff --git a/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h b/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h index 370b0368dec..ecfe414a2d2 100644 --- a/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h +++ b/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h @@ -8,7 +8,7 @@ #include "include/rados/librados.hpp" #include "common/snap_types.h" #include "librbd/ImageCtx.h" -#include "librbd/parent_types.h" +#include "librbd/Types.h" #include "librbd/journal/TypeTraits.h" #include #include @@ -28,7 +28,7 @@ public: const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::parent_spec &parent_spec, + const librbd::ParentSpec &parent_spec, uint64_t parent_overlap, Context *on_finish) { return new SnapshotCreateRequest(local_image_ctx, snap_name, snap_namespace, size, @@ -39,7 +39,7 @@ public: const std::string &snap_name, const cls::rbd::SnapshotNamespace &snap_namespace, uint64_t size, - const librbd::parent_spec &parent_spec, + const librbd::ParentSpec &parent_spec, uint64_t parent_overlap, Context *on_finish); void send(); @@ -75,7 +75,7 @@ private: std::string m_snap_name; cls::rbd::SnapshotNamespace m_snap_namespace; uint64_t m_size; - librbd::parent_spec m_parent_spec; + librbd::ParentSpec m_parent_spec; uint64_t m_parent_overlap; Context *m_on_finish;