X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftools%2Frbd_mirror%2Fimage_sync%2FSnapshotCreateRequest.h;fp=src%2Fceph%2Fsrc%2Ftools%2Frbd_mirror%2Fimage_sync%2FSnapshotCreateRequest.h;h=503a164a0d5966af106b88c6c4f5616e1814f3dc;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h b/src/ceph/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h new file mode 100644 index 0000000..503a164 --- /dev/null +++ b/src/ceph/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h @@ -0,0 +1,108 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef RBD_MIRROR_IMAGE_SYNC_SNAPSHOT_CREATE_REQUEST_H +#define RBD_MIRROR_IMAGE_SYNC_SNAPSHOT_CREATE_REQUEST_H + +#include "include/int_types.h" +#include "include/rados/librados.hpp" +#include "common/snap_types.h" +#include "librbd/ImageCtx.h" +#include "librbd/Types.h" +#include "librbd/journal/TypeTraits.h" +#include +#include +#include +#include + +class Context; + +namespace rbd { +namespace mirror { +namespace image_sync { + +template +class SnapshotCreateRequest { +public: + static SnapshotCreateRequest* create(ImageCtxT *local_image_ctx, + const std::string &snap_name, + const cls::rbd::SnapshotNamespace &snap_namespace, + uint64_t size, + const librbd::ParentSpec &parent_spec, + uint64_t parent_overlap, + Context *on_finish) { + return new SnapshotCreateRequest(local_image_ctx, snap_name, snap_namespace, size, + parent_spec, parent_overlap, on_finish); + } + + SnapshotCreateRequest(ImageCtxT *local_image_ctx, + const std::string &snap_name, + const cls::rbd::SnapshotNamespace &snap_namespace, + uint64_t size, + const librbd::ParentSpec &parent_spec, + uint64_t parent_overlap, Context *on_finish); + + void send(); + +private: + /** + * @verbatim + * + * + * | + * v (skip if not needed) + * SET_SIZE + * | + * v (skip if not needed) + * REMOVE_PARENT + * | + * v (skip if not needed) + * SET_PARENT + * | + * v + * CREATE_SNAP + * | + * v (skip if not needed) + * CREATE_OBJECT_MAP + * | + * v + * + * + * @endverbatim + */ + + ImageCtxT *m_local_image_ctx; + std::string m_snap_name; + cls::rbd::SnapshotNamespace m_snap_namespace; + uint64_t m_size; + librbd::ParentSpec m_parent_spec; + uint64_t m_parent_overlap; + Context *m_on_finish; + + void send_set_size(); + void handle_set_size(int r); + + void send_remove_parent(); + void handle_remove_parent(int r); + + void send_set_parent(); + void handle_set_parent(int r); + + void send_snap_create(); + void handle_snap_create(int r); + + void send_create_object_map(); + void handle_create_object_map(int r); + + Context *start_local_op(); + + void finish(int r); +}; + +} // namespace image_sync +} // namespace mirror +} // namespace rbd + +extern template class rbd::mirror::image_sync::SnapshotCreateRequest; + +#endif // RBD_MIRROR_IMAGE_SYNC_SNAPSHOT_CREATE_REQUEST_H