X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Flibrbd%2Fimage%2FRefreshParentRequest.h;fp=src%2Fceph%2Fsrc%2Flibrbd%2Fimage%2FRefreshParentRequest.h;h=ed65b9a7514238caadc901becaaee2c1ab1d1949;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/librbd/image/RefreshParentRequest.h b/src/ceph/src/librbd/image/RefreshParentRequest.h new file mode 100644 index 0000000..ed65b9a --- /dev/null +++ b/src/ceph/src/librbd/image/RefreshParentRequest.h @@ -0,0 +1,99 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H +#define CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H + +#include "include/int_types.h" +#include "librbd/Types.h" + +class Context; + +namespace librbd { + +class ImageCtx; + +namespace image { + +template +class RefreshParentRequest { +public: + static RefreshParentRequest *create(ImageCtxT &child_image_ctx, + 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 ParentInfo &parent_md); + + void send(); + void apply(); + void finalize(Context *on_finish); + +private: + /** + * @verbatim + * + * + * | + * | (open required) + * |----------------> OPEN_PARENT * * * * * * * * * * * * * * * + * | | * + * | v * + * | SET_PARENT_SNAP * * * * * * * + * | | * * + * | v * (on error) * + * \----------------> * * + * | * * + * | (close required) v * + * |-----------------> CLOSE_PARENT * + * | | * + * | v * + * \-----------------> < * * * * + * + * @endverbatim + */ + + RefreshParentRequest(ImageCtxT &child_image_ctx, const ParentInfo &parent_md, + Context *on_finish); + + ImageCtxT &m_child_image_ctx; + ParentInfo m_parent_md; + Context *m_on_finish; + + ImageCtxT *m_parent_image_ctx; + uint64_t m_parent_snap_id; + + int m_error_result; + + static bool is_close_required(ImageCtxT &child_image_ctx, + const ParentInfo &parent_md); + static bool is_open_required(ImageCtxT &child_image_ctx, + const ParentInfo &parent_md); + + void send_open_parent(); + Context *handle_open_parent(int *result); + + void send_set_parent_snap(); + Context *handle_set_parent_snap(int *result); + + void send_close_parent(); + Context *handle_close_parent(int *result); + + void send_complete(int r); + + void save_result(int *result) { + if (m_error_result == 0 && *result < 0) { + m_error_result = *result; + } + } + +}; + +} // namespace image +} // namespace librbd + +extern template class librbd::image::RefreshParentRequest; + +#endif // CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H