]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/cls/rbd/cls_rbd_types.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / cls / rbd / cls_rbd_types.h
index f983577b44ffaf09e1befa65eb9196970c62c1bd..bbfc85870b21b0519298fbe4f0f9d67d60774560 100644 (file)
@@ -12,6 +12,7 @@
 #include "include/utime.h"
 #include <iosfwd>
 #include <string>
+#include <set>
 
 #define RBD_GROUP_REF "rbd_group_ref"
 
@@ -23,6 +24,24 @@ namespace rbd {
 static const uint32_t MAX_OBJECT_MAP_OBJECT_COUNT = 256000000;
 static const string RBD_GROUP_IMAGE_KEY_PREFIX = "image_";
 
+enum DirectoryState {
+  DIRECTORY_STATE_READY         = 0,
+  DIRECTORY_STATE_ADD_DISABLED  = 1
+};
+
+inline void encode(DirectoryState state, bufferlist& bl,
+                  uint64_t features=0)
+{
+  ceph::encode(static_cast<uint8_t>(state), bl);
+}
+
+inline void decode(DirectoryState &state, bufferlist::const_iterator& it)
+{
+  uint8_t int_state;
+  ceph::decode(int_state, it);
+  state = static_cast<DirectoryState>(int_state);
+}
+
 enum MirrorMode {
   MIRROR_MODE_DISABLED = 0,
   MIRROR_MODE_IMAGE    = 1,
@@ -37,13 +56,15 @@ enum GroupImageLinkState {
 inline void encode(const GroupImageLinkState &state, bufferlist& bl,
                   uint64_t features=0)
 {
-  ::encode(static_cast<uint8_t>(state), bl);
+  using ceph::encode;
+  encode(static_cast<uint8_t>(state), bl);
 }
 
-inline void decode(GroupImageLinkState &state, bufferlist::iterator& it)
+inline void decode(GroupImageLinkState &state, bufferlist::const_iterator& it)
 {
   uint8_t int_state;
-  ::decode(int_state, it);
+  using ceph::decode;
+  decode(int_state, it);
   state = static_cast<GroupImageLinkState>(int_state);
 }
 
@@ -66,7 +87,7 @@ struct MirrorPeer {
   }
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator &it);
+  void decode(bufferlist::const_iterator &it);
   void dump(Formatter *f) const;
 
   static void generate_test_instances(std::list<MirrorPeer*> &o);
@@ -94,7 +115,7 @@ struct MirrorImage {
   MirrorImageState state = MIRROR_IMAGE_STATE_DISABLING;
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator &it);
+  void decode(bufferlist::const_iterator &it);
   void dump(Formatter *f) const;
 
   static void generate_test_instances(std::list<MirrorImage*> &o);
@@ -121,13 +142,15 @@ enum MirrorImageStatusState {
 inline void encode(const MirrorImageStatusState &state, bufferlist& bl,
                   uint64_t features=0)
 {
-  ::encode(static_cast<uint8_t>(state), bl);
+  using ceph::encode;
+  encode(static_cast<uint8_t>(state), bl);
 }
 
-inline void decode(MirrorImageStatusState &state, bufferlist::iterator& it)
+inline void decode(MirrorImageStatusState &state, bufferlist::const_iterator& it)
 {
   uint8_t int_state;
-  ::decode(int_state, it);
+  using ceph::decode;
+  decode(int_state, it);
   state = static_cast<MirrorImageStatusState>(int_state);
 }
 
@@ -143,7 +166,7 @@ struct MirrorImageStatus {
   bool up = false;
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator &it);
+  void decode(bufferlist::const_iterator &it);
   void dump(Formatter *f) const;
 
   std::string state_to_string() const;
@@ -158,6 +181,80 @@ std::ostream& operator<<(std::ostream& os, const MirrorImageStatusState& state);
 
 WRITE_CLASS_ENCODER(MirrorImageStatus);
 
+struct ParentImageSpec {
+  int64_t pool_id = -1;
+  std::string pool_namespace;
+  std::string image_id;
+  snapid_t snap_id = CEPH_NOSNAP;
+
+  ParentImageSpec() {
+  }
+  ParentImageSpec(int64_t pool_id, const std::string& pool_namespace,
+                  const std::string& image_id, snapid_t snap_id)
+    : pool_id(pool_id), pool_namespace(pool_namespace), image_id(image_id),
+      snap_id(snap_id) {
+  }
+
+  bool exists() const {
+    return (pool_id >= 0 && !image_id.empty() && snap_id != CEPH_NOSNAP);
+  }
+
+  bool operator==(const ParentImageSpec& rhs) const {
+    return ((pool_id == rhs.pool_id) &&
+            (pool_namespace == rhs.pool_namespace) &&
+            (image_id == rhs.image_id) &&
+            (snap_id == rhs.snap_id));
+  }
+
+  bool operator!=(const ParentImageSpec& rhs) const {
+    return !(*this == rhs);
+  }
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::const_iterator &it);
+  void dump(Formatter *f) const;
+
+  static void generate_test_instances(std::list<ParentImageSpec*> &o);
+};
+
+WRITE_CLASS_ENCODER(ParentImageSpec);
+
+struct ChildImageSpec {
+  int64_t pool_id = -1;
+  std::string pool_namespace;
+  std::string image_id;
+
+  ChildImageSpec() {}
+  ChildImageSpec(int64_t pool_id, const std::string& pool_namespace,
+                 const std::string& image_id)
+    : pool_id(pool_id), pool_namespace(pool_namespace), image_id(image_id) {
+  }
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::const_iterator &it);
+  void dump(Formatter *f) const;
+
+  static void generate_test_instances(std::list<ChildImageSpec*> &o);
+
+  inline bool operator==(const ChildImageSpec& rhs) const {
+    return (pool_id == rhs.pool_id &&
+            pool_namespace == rhs.pool_namespace &&
+            image_id == rhs.image_id);
+  }
+  inline bool operator<(const ChildImageSpec& rhs) const {
+    if (pool_id != rhs.pool_id) {
+      return pool_id < rhs.pool_id;
+    }
+    if (pool_namespace != rhs.pool_namespace) {
+      return pool_namespace < rhs.pool_namespace;
+    }
+    return image_id < rhs.image_id;
+  }
+};
+WRITE_CLASS_ENCODER(ChildImageSpec);
+
+typedef std::set<ChildImageSpec> ChildImageSpecs;
+
 struct GroupImageSpec {
   GroupImageSpec() {}
 
@@ -170,13 +267,14 @@ struct GroupImageSpec {
   int64_t pool_id = -1;
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator &it);
+  void decode(bufferlist::const_iterator &it);
   void dump(Formatter *f) const;
 
+  static void generate_test_instances(std::list<GroupImageSpec*> &o);
+
   std::string image_key();
 
 };
-
 WRITE_CLASS_ENCODER(GroupImageSpec);
 
 struct GroupImageStatus {
@@ -194,9 +292,11 @@ struct GroupImageStatus {
   GroupImageLinkState state = GROUP_IMAGE_LINK_STATE_INCOMPLETE;
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator &it);
+  void decode(bufferlist::const_iterator &it);
   void dump(Formatter *f) const;
 
+  static void generate_test_instances(std::list<GroupImageStatus*> &o);
+
   std::string state_to_string() const;
 };
 
@@ -211,24 +311,29 @@ struct GroupSpec {
   int64_t pool_id = -1;
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator &it);
+  void decode(bufferlist::const_iterator &it);
   void dump(Formatter *f) const;
   bool is_valid() const;
+
+  static void generate_test_instances(std::list<GroupSpec *> &o);
 };
 
 WRITE_CLASS_ENCODER(GroupSpec);
 
 enum SnapshotNamespaceType {
-  SNAPSHOT_NAMESPACE_TYPE_USER = 0
+  SNAPSHOT_NAMESPACE_TYPE_USER  = 0,
+  SNAPSHOT_NAMESPACE_TYPE_GROUP = 1,
+  SNAPSHOT_NAMESPACE_TYPE_TRASH = 2
 };
 
 struct UserSnapshotNamespace {
-  static const uint32_t SNAPSHOT_NAMESPACE_TYPE = SNAPSHOT_NAMESPACE_TYPE_USER;
+  static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE =
+    SNAPSHOT_NAMESPACE_TYPE_USER;
 
   UserSnapshotNamespace() {}
 
   void encode(bufferlist& bl) const {}
-  void decode(bufferlist::iterator& it) {}
+  void decode(bufferlist::const_iterator& it) {}
 
   void dump(Formatter *f) const {}
 
@@ -239,94 +344,447 @@ struct UserSnapshotNamespace {
   inline bool operator<(const UserSnapshotNamespace& usn) const {
     return false;
   }
+};
+
+struct GroupSnapshotNamespace {
+  static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE =
+    SNAPSHOT_NAMESPACE_TYPE_GROUP;
+
+  GroupSnapshotNamespace() {}
+
+  GroupSnapshotNamespace(int64_t _group_pool,
+                        const string &_group_id,
+                        const string &_group_snapshot_id)
+    : group_id(_group_id), group_pool(_group_pool),
+      group_snapshot_id(_group_snapshot_id) {}
+
+  string group_id;
+  int64_t group_pool = 0;
+  string group_snapshot_id;
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::const_iterator& it);
+
+  void dump(Formatter *f) const;
+
+  inline bool operator==(const GroupSnapshotNamespace& gsn) const {
+    return group_pool == gsn.group_pool &&
+          group_id == gsn.group_id &&
+          group_snapshot_id == gsn.group_snapshot_id;
+  }
 
+  inline bool operator<(const GroupSnapshotNamespace& gsn) const {
+    if (group_pool < gsn.group_pool) {
+      return true;
+    } else if (group_id < gsn.group_id) {
+      return true;
+    } else {
+      return (group_snapshot_id < gsn.group_snapshot_id);
+    }
+    return false;
+  }
 };
 
-std::ostream& operator<<(std::ostream& os, const UserSnapshotNamespace& ns);
+struct TrashSnapshotNamespace {
+  static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE =
+    SNAPSHOT_NAMESPACE_TYPE_TRASH;
+
+  std::string original_name;
+  SnapshotNamespaceType original_snapshot_namespace_type =
+    SNAPSHOT_NAMESPACE_TYPE_USER;
+
+  TrashSnapshotNamespace() {}
+  TrashSnapshotNamespace(SnapshotNamespaceType original_snapshot_namespace_type,
+                         const std::string& original_name)
+    : original_name(original_name),
+      original_snapshot_namespace_type(original_snapshot_namespace_type) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::const_iterator& it);
+  void dump(Formatter *f) const;
+
+  inline bool operator==(const TrashSnapshotNamespace& usn) const {
+    return true;
+  }
+  inline bool operator<(const TrashSnapshotNamespace& usn) const {
+    return false;
+  }
+};
 
 struct UnknownSnapshotNamespace {
-  static const uint32_t SNAPSHOT_NAMESPACE_TYPE = static_cast<uint32_t>(-1);
+  static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE =
+    static_cast<SnapshotNamespaceType>(-1);
 
   UnknownSnapshotNamespace() {}
 
   void encode(bufferlist& bl) const {}
-  void decode(bufferlist::iterator& it) {}
+  void decode(bufferlist::const_iterator& it) {}
   void dump(Formatter *f) const {}
+
   inline bool operator==(const UnknownSnapshotNamespace& gsn) const {
     return true;
   }
 
-  inline bool operator<(const UnknownSnapshotNamespace& usn) const {
+  inline bool operator<(const UnknownSnapshotNamespace& gsn) const {
     return false;
   }
 };
 
+std::ostream& operator<<(std::ostream& os, const SnapshotNamespaceType& type);
+std::ostream& operator<<(std::ostream& os, const UserSnapshotNamespace& ns);
+std::ostream& operator<<(std::ostream& os, const GroupSnapshotNamespace& ns);
+std::ostream& operator<<(std::ostream& os, const TrashSnapshotNamespace& ns);
 std::ostream& operator<<(std::ostream& os, const UnknownSnapshotNamespace& ns);
 
-typedef boost::variant<UserSnapshotNamespace, UnknownSnapshotNamespace> SnapshotNamespace;
+typedef boost::variant<UserSnapshotNamespace,
+                       GroupSnapshotNamespace,
+                       TrashSnapshotNamespace,
+                       UnknownSnapshotNamespace> SnapshotNamespaceVariant;
+
+struct SnapshotNamespace : public SnapshotNamespaceVariant {
+  SnapshotNamespace() {
+  }
+
+  template <typename T>
+  SnapshotNamespace(T&& t) : SnapshotNamespaceVariant(std::forward<T>(t)) {
+  }
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::const_iterator& it);
+  void dump(Formatter *f) const;
 
+  static void generate_test_instances(std::list<SnapshotNamespace*> &o);
 
-struct SnapshotNamespaceOnDisk {
+  inline bool operator==(const SnapshotNamespaceVariant& sn) const {
+    return static_cast<const SnapshotNamespaceVariant&>(*this) == sn;
+  }
+  inline bool operator<(const SnapshotNamespaceVariant& sn) const {
+    return static_cast<const SnapshotNamespaceVariant&>(*this) < sn;
+  }
+};
+WRITE_CLASS_ENCODER(SnapshotNamespace);
 
-  SnapshotNamespaceOnDisk() : snapshot_namespace(UnknownSnapshotNamespace()) {}
-  SnapshotNamespaceOnDisk(const SnapshotNamespace &sn) : snapshot_namespace(sn) {}
+SnapshotNamespaceType get_snap_namespace_type(
+    const SnapshotNamespace& snapshot_namespace);
 
-  SnapshotNamespace snapshot_namespace;
+struct SnapshotInfo {
+  snapid_t id = CEPH_NOSNAP;
+  cls::rbd::SnapshotNamespace snapshot_namespace = {UserSnapshotNamespace{}};
+  std::string name;
+  uint64_t image_size = 0;
+  utime_t timestamp;
+  uint32_t child_count = 0;
 
-  SnapshotNamespaceType get_namespace_type() const;
+  SnapshotInfo() {
+  }
+  SnapshotInfo(snapid_t id,
+               const cls::rbd::SnapshotNamespace& snapshot_namespace,
+               const std::string& name, uint64_t image_size,
+               const utime_t& timestamp, uint32_t child_count)
+    : id(id), snapshot_namespace(snapshot_namespace),
+      name(name), image_size(image_size), timestamp(timestamp),
+      child_count(child_count) {
+  }
 
   void encode(bufferlist& bl) const;
-  void decode(bufferlist::iterator& it);
+  void decode(bufferlist::const_iterator& it);
   void dump(Formatter *f) const;
 
-  static void generate_test_instances(std::list<SnapshotNamespaceOnDisk *> &o);
+  static void generate_test_instances(std::list<SnapshotInfo*> &o);
+};
+WRITE_CLASS_ENCODER(SnapshotInfo);
 
-  inline bool operator==(const SnapshotNamespaceOnDisk& gsn) const {
-    return snapshot_namespace == gsn.snapshot_namespace;
-  }
+enum GroupSnapshotState {
+  GROUP_SNAPSHOT_STATE_INCOMPLETE = 0,
+  GROUP_SNAPSHOT_STATE_COMPLETE = 1,
 };
-WRITE_CLASS_ENCODER(SnapshotNamespaceOnDisk);
 
+inline void encode(const GroupSnapshotState &state, bufferlist& bl, uint64_t features=0)
+{
+  using ceph::encode;
+  encode(static_cast<uint8_t>(state), bl);
+}
+
+inline void decode(GroupSnapshotState &state, bufferlist::const_iterator& it)
+{
+  using ceph::decode;
+  uint8_t int_state;
+  decode(int_state, it);
+  state = static_cast<GroupSnapshotState>(int_state);
+}
+
+struct ImageSnapshotSpec {
+  int64_t pool;
+  string image_id;
+  snapid_t snap_id;
+
+  ImageSnapshotSpec() {}
+  ImageSnapshotSpec(int64_t _pool,
+                   string _image_id,
+                   snapid_t _snap_id) : pool(_pool),
+                                        image_id(_image_id),
+                                        snap_id(_snap_id) {}
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::const_iterator& it);
+
+  void dump(Formatter *f) const;
+
+  static void generate_test_instances(std::list<ImageSnapshotSpec *> &o);
+};
+WRITE_CLASS_ENCODER(ImageSnapshotSpec);
+
+struct GroupSnapshot {
+  std::string id;
+  std::string name;
+  GroupSnapshotState state = GROUP_SNAPSHOT_STATE_INCOMPLETE;
+
+  GroupSnapshot() {}
+  GroupSnapshot(std::string _id,
+               std::string _name,
+               GroupSnapshotState _state) : id(_id),
+                                            name(_name),
+                                            state(_state) {}
+
+  vector<ImageSnapshotSpec> snaps;
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::const_iterator& it);
+  void dump(Formatter *f) const;
+
+  static void generate_test_instances(std::list<GroupSnapshot *> &o);
+};
+WRITE_CLASS_ENCODER(GroupSnapshot);
 enum TrashImageSource {
   TRASH_IMAGE_SOURCE_USER = 0,
-  TRASH_IMAGE_SOURCE_MIRRORING = 1
+  TRASH_IMAGE_SOURCE_MIRRORING = 1,
+  TRASH_IMAGE_SOURCE_MIGRATION = 2,
+  TRASH_IMAGE_SOURCE_REMOVING = 3,
 };
 
+inline std::ostream& operator<<(std::ostream& os,
+                                const TrashImageSource& source) {
+  switch (source) {
+  case TRASH_IMAGE_SOURCE_USER:
+    os << "user";
+    break;
+  case TRASH_IMAGE_SOURCE_MIRRORING:
+    os << "mirroring";
+    break;
+  case TRASH_IMAGE_SOURCE_MIGRATION:
+    os << "migration";
+    break;
+  case TRASH_IMAGE_SOURCE_REMOVING:
+    os << "removing";
+    break;
+  default:
+    os << "unknown (" << static_cast<uint32_t>(source) << ")";
+    break;
+  }
+  return os;
+}
+
 inline void encode(const TrashImageSource &source, bufferlist& bl,
                   uint64_t features=0)
 {
-  ::encode(static_cast<uint8_t>(source), bl);
+  using ceph::encode;
+  encode(static_cast<uint8_t>(source), bl);
 }
 
-inline void decode(TrashImageSource &source, bufferlist::iterator& it)
+inline void decode(TrashImageSource &source, bufferlist::const_iterator& it)
 {
   uint8_t int_source;
-  ::decode(int_source, it);
+  using ceph::decode;
+  decode(int_source, it);
   source = static_cast<TrashImageSource>(int_source);
 }
 
+enum TrashImageState {
+  TRASH_IMAGE_STATE_NORMAL    = 0,
+  TRASH_IMAGE_STATE_MOVING    = 1,
+  TRASH_IMAGE_STATE_REMOVING  = 2,
+  TRASH_IMAGE_STATE_RESTORING = 3
+};
+
+inline void encode(const TrashImageState &state, bufferlist &bl)
+{
+  using ceph::encode;
+  encode(static_cast<uint8_t>(state), bl);
+}
+
+inline void decode(TrashImageState &state, bufferlist::const_iterator &it)
+{
+  uint8_t int_state;
+  using ceph::decode;
+  decode(int_state, it);
+  state = static_cast<TrashImageState>(int_state);
+}
+
 struct TrashImageSpec {
   TrashImageSource source = TRASH_IMAGE_SOURCE_USER;
   std::string name;
   utime_t deletion_time; // time of deletion
   utime_t deferment_end_time;
+  TrashImageState state = TRASH_IMAGE_STATE_NORMAL;
 
   TrashImageSpec() {}
   TrashImageSpec(TrashImageSource source, const std::string &name,
-                   utime_t deletion_time, utime_t deferment_end_time) :
-    source(source), name(name), deletion_time(deletion_time),
-    deferment_end_time(deferment_end_time) {}
+                 const utime_t& deletion_time,
+                 const utime_t& deferment_end_time)
+    : source(source), name(name), deletion_time(deletion_time),
+      deferment_end_time(deferment_end_time) {
+  }
 
   void encode(bufferlist &bl) const;
-  void decode(bufferlist::iterator& it);
+  void decode(bufferlist::const_iterator& it);
   void dump(Formatter *f) const;
+
+  inline bool operator==(const TrashImageSpec& rhs) const {
+    return (source == rhs.source &&
+            name == rhs.name &&
+            deletion_time == rhs.deletion_time &&
+            deferment_end_time == rhs.deferment_end_time);
+  }
 };
 WRITE_CLASS_ENCODER(TrashImageSpec);
 
+struct MirrorImageMap {
+  MirrorImageMap() {
+  }
+
+  MirrorImageMap(const std::string &instance_id, utime_t mapped_time,
+                 const bufferlist &data)
+    : instance_id(instance_id),
+      mapped_time(mapped_time),
+      data(data) {
+  }
+
+  std::string instance_id;
+  utime_t mapped_time;
+  bufferlist data;
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::const_iterator &it);
+  void dump(Formatter *f) const;
+
+  static void generate_test_instances(std::list<MirrorImageMap*> &o);
+
+  bool operator==(const MirrorImageMap &rhs) const;
+  bool operator<(const MirrorImageMap &rhs) const;
+};
+
+std::ostream& operator<<(std::ostream& os, const MirrorImageMap &image_map);
+
+WRITE_CLASS_ENCODER(MirrorImageMap);
+
+enum MigrationHeaderType {
+  MIGRATION_HEADER_TYPE_SRC = 1,
+  MIGRATION_HEADER_TYPE_DST = 2,
+};
+
+inline void encode(const MigrationHeaderType &type, bufferlist& bl) {
+  using ceph::encode;
+  encode(static_cast<uint8_t>(type), bl);
+}
+
+inline void decode(MigrationHeaderType &type, bufferlist::const_iterator& it) {
+  uint8_t int_type;
+  using ceph::decode;
+  decode(int_type, it);
+  type = static_cast<MigrationHeaderType>(int_type);
+}
+
+enum MigrationState {
+  MIGRATION_STATE_ERROR = 0,
+  MIGRATION_STATE_PREPARING = 1,
+  MIGRATION_STATE_PREPARED = 2,
+  MIGRATION_STATE_EXECUTING = 3,
+  MIGRATION_STATE_EXECUTED = 4,
+};
+
+inline void encode(const MigrationState &state, bufferlist& bl) {
+  using ceph::encode;
+  encode(static_cast<uint8_t>(state), bl);
+}
+
+inline void decode(MigrationState &state, bufferlist::const_iterator& it) {
+  uint8_t int_state;
+  using ceph::decode;
+  decode(int_state, it);
+  state = static_cast<MigrationState>(int_state);
+}
+
+std::ostream& operator<<(std::ostream& os,
+                         const MigrationState& migration_state);
+
+struct MigrationSpec {
+  MigrationHeaderType header_type = MIGRATION_HEADER_TYPE_SRC;
+  int64_t pool_id = -1;
+  std::string pool_namespace;
+  std::string image_name;
+  std::string image_id;
+  std::map<uint64_t, uint64_t> snap_seqs;
+  uint64_t overlap = 0;
+  bool flatten = false;
+  bool mirroring = false;
+  MigrationState state = MIGRATION_STATE_ERROR;
+  std::string state_description;
+
+  MigrationSpec() {
+  }
+  MigrationSpec(MigrationHeaderType header_type, int64_t pool_id,
+                const std::string& pool_namespace,
+                const std::string &image_name, const std::string &image_id,
+                const std::map<uint64_t, uint64_t> &snap_seqs, uint64_t overlap,
+                bool mirroring, bool flatten, MigrationState state,
+                const std::string &state_description)
+    : header_type(header_type), pool_id(pool_id),
+      pool_namespace(pool_namespace), image_name(image_name),
+      image_id(image_id), snap_seqs(snap_seqs), overlap(overlap),
+      flatten(flatten), mirroring(mirroring), state(state),
+      state_description(state_description) {
+  }
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::const_iterator& it);
+  void dump(Formatter *f) const;
+
+  static void generate_test_instances(std::list<MigrationSpec*> &o);
+
+  inline bool operator==(const MigrationSpec& ms) const {
+    return header_type == ms.header_type && pool_id == ms.pool_id &&
+      pool_namespace == ms.pool_namespace && image_name == ms.image_name &&
+      image_id == ms.image_id && snap_seqs == ms.snap_seqs &&
+      overlap == ms.overlap && flatten == ms.flatten &&
+      mirroring == ms.mirroring && state == ms.state &&
+      state_description == ms.state_description;
+  }
+};
+
+std::ostream& operator<<(std::ostream& os, const MigrationSpec& migration_spec);
+
+WRITE_CLASS_ENCODER(MigrationSpec);
+
+enum AssertSnapcSeqState {
+  ASSERT_SNAPC_SEQ_GT_SNAPSET_SEQ = 0,
+  ASSERT_SNAPC_SEQ_LE_SNAPSET_SEQ = 1,
+};
+
+inline void encode(const AssertSnapcSeqState &state, bufferlist& bl) {
+  using ceph::encode;
+  encode(static_cast<uint8_t>(state), bl);
+}
+
+inline void decode(AssertSnapcSeqState &state, bufferlist::const_iterator& it) {
+  uint8_t int_state;
+  using ceph::decode;
+  decode(int_state, it);
+  state = static_cast<AssertSnapcSeqState>(int_state);
+}
+
+std::ostream& operator<<(std::ostream& os, const AssertSnapcSeqState& state);
+
 } // namespace rbd
 } // namespace cls
 
-using cls::rbd::encode;
-using cls::rbd::decode;
-
 #endif // CEPH_CLS_RBD_TYPES_H