]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: rename parent_spec/parent_info type to match code style specs
authorJason Dillaman <dillaman@redhat.com>
Thu, 2 Feb 2017 17:05:47 +0000 (12:05 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 8 Mar 2017 16:40:02 +0000 (11:40 -0500)
This also includes a consolidation of SnapInfo, ParentSpec, and ParentInfo
into a single header.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
35 files changed:
src/cls/rbd/cls_rbd.h
src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h
src/include/rbd_types.h
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/SnapInfo.h [deleted file]
src/librbd/Types.h [new file with mode: 0644]
src/librbd/image/RefreshParentRequest.cc
src/librbd/image/RefreshParentRequest.h
src/librbd/image/RefreshRequest.cc
src/librbd/image/RefreshRequest.h
src/librbd/image/RemoveRequest.cc
src/librbd/image/SetSnapRequest.cc
src/librbd/internal.cc
src/librbd/internal.h
src/librbd/operation/FlattenRequest.h
src/librbd/operation/SnapshotCreateRequest.h
src/librbd/operation/SnapshotRemoveRequest.cc
src/librbd/operation/SnapshotRemoveRequest.h
src/librbd/operation/SnapshotUnprotectRequest.cc
src/librbd/parent_types.h [deleted file]
src/librbd/type.h [deleted file]
src/test/cls_rbd/test_cls_rbd.cc
src/test/librbd/image/test_mock_RefreshRequest.cc
src/test/librbd/mock/MockImageCtx.h
src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc
src/test/librbd/test_internal.cc
src/test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc
src/test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc
src/tools/rbd_mirror/image_replayer/CreateImageRequest.h
src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc
src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.h
src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc
src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h

index 88f0bbccd93e1a6f2b88f7f3a4b1cca06f409a39..c1f17b845e5e5e6c68262a27ff47ebbfa461991d 100644 (file)
@@ -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
index ca1768710ed56042b0410b45227286f618cebc2e..ed60a2f3a991586404dae3e5ab1cd2edacef6ec6 100644 (file)
@@ -83,7 +83,7 @@ namespace librbd {
                                     std::map<rados::cls::lock::locker_id_t,
                                              rados::cls::lock::locker_info_t> *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<string>& children)
+                    const ParentSpec &pspec, set<string>& children)
     {
       librados::ObjectReadOperation op;
       get_children_start(&op, pspec);
@@ -542,7 +542,7 @@ namespace librbd {
                              const std::vector<snapid_t> &ids,
                              std::vector<string> *names,
                              std::vector<uint64_t> *sizes,
-                             std::vector<parent_info> *parents,
+                             std::vector<ParentInfo> *parents,
                              std::vector<uint8_t> *protection_statuses)
     {
       names->resize(ids.size());
@@ -575,7 +575,7 @@ namespace librbd {
                      const std::vector<snapid_t> &ids,
                      std::vector<string> *names,
                      std::vector<uint64_t> *sizes,
-                     std::vector<parent_info> *parents,
+                     std::vector<ParentInfo> *parents,
                      std::vector<uint8_t> *protection_statuses)
     {
       librados::ObjectReadOperation op;
index 6e928dcee44d7eec003f6dc42667ff687041766f..81f799b04a8ef308014109267e1e5b51123c20b1 100644 (file)
@@ -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 <string>
 #include <vector>
@@ -35,7 +35,7 @@ namespace librbd {
                                     std::map<rados::cls::lock::locker_id_t,
                                              rados::cls::lock::locker_info_t> *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<snapid_t> &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<string> *children);
     int get_children(librados::IoCtx *ioctx, const std::string &oid,
-                      parent_spec pspec, set<string>& children);
+                      const ParentSpec &pspec, set<string>& 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<snapid_t> &ids,
                              std::vector<string> *names,
                              std::vector<uint64_t> *sizes,
-                             std::vector<parent_info> *parents,
+                             std::vector<ParentInfo> *parents,
                              std::vector<uint8_t> *protection_statuses);
     void snapshot_timestamp_list_start(librados::ObjectReadOperation *op,
                                        const std::vector<snapid_t> &ids);
@@ -134,7 +134,7 @@ namespace librbd {
                      const std::vector<snapid_t> &ids,
                      std::vector<string> *names,
                      std::vector<uint64_t> *sizes,
-                     std::vector<parent_info> *parents,
+                     std::vector<ParentInfo> *parents,
                      std::vector<uint8_t> *protection_statuses);
 
     void snapshot_namespace_list_start(librados::ObjectReadOperation *op,
index 845a94e1ebd03d37fa6484b466b2789454ac9811..cb00d3db48d07d114356abc3adbe3cbe4d2a5cf8 100644 (file)
@@ -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
index 0dcd7880b86bd11ca28289516ea139d4c89fa267..0fe40b5166bd505cd061f4a66f96c40995762098 100644 (file)
@@ -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;
index bd9465dabb0e8452f9fd43015abdd7088e32778b..e264fbb5759ec67dfaf17bec8e56f0e171cc6319 100644 (file)
@@ -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 (file)
index f5de553..0000000
+++ /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 (file)
index 0000000..8efe8a7
--- /dev/null
@@ -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 <string>
+
+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
index 28058abe7b557f620eddd7b850979920c02ccfe7..31d079b22590bec8a0f8d78b2d8c1c756f06755a 100644 (file)
@@ -24,7 +24,7 @@ using util::create_context_callback;
 
 template <typename I>
 RefreshParentRequest<I>::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<I>::RefreshParentRequest(I &child_image_ctx,
 
 template <typename I>
 bool RefreshParentRequest<I>::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<I>::is_refresh_required(I &child_image_ctx,
 
 template <typename I>
 bool RefreshParentRequest<I>::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 <typename I>
 bool RefreshParentRequest<I>::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 ||
index 3fe653952c9d8ca7eb56a85f41598bc49e0f9c81..ed65b9a7514238caadc901becaaee2c1ab1d1949 100644 (file)
@@ -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 <typename ImageCtxT = ImageCtx>
 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);
index 214824831f54d3912b60739cf075ef299a562a45..86691b5baa714e0ccd1864dcf3db06bf4e63bcc0 100644 (file)
@@ -541,7 +541,7 @@ void RefreshRequest<I>::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<I>::is_refresh_required(m_image_ctx, parent_md))) {
@@ -1044,7 +1044,7 @@ void RefreshRequest<I>::apply() {
       uint8_t protection_status = m_image_ctx.old_format ?
         static_cast<uint8_t>(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<I>::apply() {
 
 template <typename I>
 int RefreshRequest<I>::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;
index 8bc57ae10d7b6174e109aca45826b63b28b63e8b..286703e39d57d9e14e2aad51aee8a51aca6274fd 100644 (file)
@@ -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 <string>
 #include <vector>
 
@@ -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<std::string> m_snap_names;
   std::vector<cls::rbd::SnapshotNamespace> m_snap_namespaces;
   std::vector<uint64_t> m_snap_sizes;
-  std::vector<parent_info> m_snap_parents;
+  std::vector<ParentInfo> m_snap_parents;
   std::vector<uint8_t> m_snap_protection;
   std::vector<uint64_t> m_snap_flags;
   std::vector<utime_t> 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
index ccccc68ac7edbf37ac9787bf6b01bce53fba3a21..64b83efffc0da6b8dd74aebe23cc049a968250ce 100644 (file)
@@ -332,7 +332,7 @@ void RemoveRequest<I>::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;
index 1b851eb748719b94f23010d9cb30bc65b971f12f..495c3adcfb3f08481b98fcfecfbf4ddb117385f6 100644 (file)
@@ -175,13 +175,13 @@ template <typename I>
 Context *SetSnapRequest<I>::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;
index 1286727f0831811412fa2015e64c43ae447b2301..f32d0935d056f0959bdc3dacda3c9adae12097c7 100644 (file)
@@ -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<int64_t, string>, set<string> > 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<int64_t, string>, set<string> > 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<int64_t, string >, set<string> >& 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<string, bufferlist> 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<librados::snap_t, SnapInfo> 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<int64_t, string>, set<string> > image_info;
 
           r = list_children_info(ictx, parent_spec, image_info);
index 9a21161a3d79e3ba01bf96f38bf417ec69e912a4..28a3c3875281df342e836de035260875e85bc48e 100644 (file)
@@ -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<std::string>& names);
   int list_children(ImageCtx *ictx,
                    std::set<std::pair<std::string, std::string> > & 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::pair<int64_t, std::string >, std::set<std::string> >& image_info);
   int create(librados::IoCtx& io_ctx, const char *imgname, uint64_t size,
             int *order);
index bc1531ddcc7f318add18225313d09e4ce0d18461..19637ba2e0a53287e3cc41d29743368ff07eae46 100644 (file)
@@ -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();
index e1e4beb550346e9c959a7c02155d3cc9f9bd118d..b0f5f06428a3281d8ef1b5de0a278e31fcb79d01 100644 (file)
@@ -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 <string>
 
 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);
index e056fe45de31a47372335c5aefffc825ad920056..70bbf60e3d988ccc49cc52a0b94f7a048688e3b1 100644 (file)
@@ -132,7 +132,7 @@ void SnapshotRemoveRequest<I>::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<I>::remove_snap_context() {
 }
 
 template <typename I>
-int SnapshotRemoveRequest<I>::scan_for_parents(parent_spec &pspec) {
+int SnapshotRemoveRequest<I>::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());
index 40c12c5c923a03237daa83f676df57cfb8686305..a3f1d0ed62ba7b008c131712f811808d025d2652 100644 (file)
@@ -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 <string>
 
 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);
 
 };
 
index 0660deddb6b54aaa0fd429a176b8e0e3a2407024..944b7b9e18b45ea38f3cb2057ed6ca775cd3a46b 100644 (file)
@@ -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 <list>
 #include <set>
@@ -56,7 +56,7 @@ template <typename I>
 class C_ScanPoolChildren : public C_AsyncObjectThrottle<I> {
 public:
   C_ScanPoolChildren(AsyncObjectThrottle<I> &throttle, I *image_ctx,
-                     const parent_spec &pspec, const Pools &pools,
+                     const ParentSpec &pspec, const Pools &pools,
                      size_t pool_idx)
     : C_AsyncObjectThrottle<I>(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<I>::send_scan_pool_children() {
   std::list<Pool> 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 (file)
index 69598b7..0000000
+++ /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 <string>
-
-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 (file)
index 20be5c2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#ifndef LIBRBD_TYPE_H
-#define LIBRBD_TYPE_H
-
-#include <errno.h>
-
-#endif
index 97fc597a9a5032a97d9e1460d43f6c9f405a1623..472ea6ffcc04f6b9b545b2d6ed3bf7e446ae01ca 100644 (file)
@@ -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";
   set<string>children;
-  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<cls::rbd::SnapshotNamespace> snap_namespaces;
   vector<uint64_t> snap_sizes;
   SnapContext snapc;
-  vector<parent_info> parents;
+  vector<ParentInfo> parents;
   vector<uint8_t> protection_status;
   vector<utime_t> 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,
index ea5a5dd270599a3470a2334cf64cf08ebe72f03f..d5454785fd4f820ddaba68dd5d739706078e3e99 100644 (file)
@@ -37,14 +37,14 @@ template <>
 struct RefreshParentRequest<MockRefreshImageCtx> {
   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();
   }
index 4d1fc06debe5b9c1caab33eb29a2d5196e141193..61ca316515ce08042b1b70dc8cf1cd6890da5618 100644 (file)
@@ -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;
 
index db31a83573c5e036b0ad1c40260581d6a650df70..3209859dd987b1c7354ee8d596f635d0dc52a3cc 100644 (file)
@@ -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)));
     }
index c262a070527ea0c0908c3c30650389e61915cd0b..db3bbbffaca9d6088e118054ccf8cc3d88e37f54 100644 (file)
@@ -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};
index 5b2ca67d1108ec74c19a57b302b1c79a89c6737c..4b2b7df258b442ada5fe08d6c63ef5960c60ce26 100644 (file)
@@ -47,7 +47,7 @@ struct SnapshotCreateRequest<librbd::MockTestImageCtx> {
                                        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);
index b395b3e77636cfd944ebf3e5f26c4b1df19a2c12..236bfe4e617f8bced871d43fa63e8a66b03fc2ee 100644 (file)
@@ -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,
index 0e5d4833e7edbe078c3febaaa73fd618642a3b03..e920498f15fba34bf565802e6f69afa2a75b0b50 100644 (file)
@@ -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 <string>
 
 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;
index 028af8bb34674faf0d58bb03749f41769c7ab07a..8e9827e4d652d0686f344fd407b8393856604abd 100644 (file)
@@ -64,7 +64,7 @@ SnapshotCopyRequest<I>::SnapshotCopyRequest(I *local_image_ctx,
 
 template <typename I>
 void SnapshotCopyRequest<I>::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<I>::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<I>::compute_snap_map() {
 
 template <typename I>
 int SnapshotCopyRequest<I>::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);
 
index bd8b7ef932c5eb2e45514be3aa8bc2831603075e..1714ad2dd90dffbcc7b25bc34142e9e92f789370 100644 (file)
@@ -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 <map>
@@ -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);
 
 };
 
index 8caca612f1d28ddeec7de422ef2c5a8f7d216e01..78317e2dda8f75b485709282d4e7f44b592cb76d 100644 (file)
@@ -28,7 +28,7 @@ SnapshotCreateRequest<I>::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),
index 370b0368deca3764297ce3f7791be209b7321637..ecfe414a2d2ee64a945108aa718277c9fe1aefb6 100644 (file)
@@ -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 <map>
 #include <set>
@@ -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;