X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Flibrbd%2Fimage%2FOpenRequest.h;fp=src%2Fceph%2Fsrc%2Flibrbd%2Fimage%2FOpenRequest.h;h=5dd088770b710ea3bf5b7f4bd4b05887e07aeacd;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/librbd/image/OpenRequest.h b/src/ceph/src/librbd/image/OpenRequest.h new file mode 100644 index 0000000..5dd0887 --- /dev/null +++ b/src/ceph/src/librbd/image/OpenRequest.h @@ -0,0 +1,139 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_IMAGE_OPEN_REQUEST_H +#define CEPH_LIBRBD_IMAGE_OPEN_REQUEST_H + +#include "include/buffer.h" +#include +#include + +class Context; + +namespace librbd { + +class ImageCtx; + +namespace image { + +template +class OpenRequest { +public: + static OpenRequest *create(ImageCtxT *image_ctx, bool skip_open_parent, + Context *on_finish) { + return new OpenRequest(image_ctx, skip_open_parent, on_finish); + } + + void send(); + +private: + /** + * @verbatim + * + * + * | + * | (v1) + * |-----> V1_DETECT_HEADER + * | | + * | \-------------------------------\ + * | (v2) | + * \-----> V2_DETECT_HEADER | + * | | + * v | + * V2_GET_ID|NAME | + * | | + * v | + * V2_GET_NAME_FROM_TRASH | + * | | + * v | + * V2_GET_IMMUTABLE_METADATA | + * | | + * v | + * V2_GET_STRIPE_UNIT_COUNT | + * | | + * v | + * V2_GET_CREATE_TIMESTAMP | + * | | + * v | + * V2_GET_DATA_POOL | + * | | + * v | + * /---> V2_APPLY_METADATA -------------> REGISTER_WATCH (skip if + * | | | read-only) + * \---------/ v + * REFRESH + * | + * v + * SET_SNAP (skip if no snap) + * | + * v + * + * ^ + * (on error) | + * * * * * * * > CLOSE ------------------------/ + * + * @endverbatim + */ + + OpenRequest(ImageCtxT *image_ctx, bool skip_open_parent, Context *on_finish); + + ImageCtxT *m_image_ctx; + bool m_skip_open_parent_image; + Context *m_on_finish; + + bufferlist m_out_bl; + int m_error_result; + + std::string m_last_metadata_key; + std::map m_metadata; + + void send_v1_detect_header(); + Context *handle_v1_detect_header(int *result); + + void send_v2_detect_header(); + Context *handle_v2_detect_header(int *result); + + void send_v2_get_id(); + Context *handle_v2_get_id(int *result); + + void send_v2_get_name(); + Context *handle_v2_get_name(int *result); + + void send_v2_get_name_from_trash(); + Context *handle_v2_get_name_from_trash(int *result); + + void send_v2_get_immutable_metadata(); + Context *handle_v2_get_immutable_metadata(int *result); + + void send_v2_get_stripe_unit_count(); + Context *handle_v2_get_stripe_unit_count(int *result); + + void send_v2_get_create_timestamp(); + Context *handle_v2_get_create_timestamp(int *result); + + void send_v2_get_data_pool(); + Context *handle_v2_get_data_pool(int *result); + + void send_v2_apply_metadata(); + Context *handle_v2_apply_metadata(int *result); + + void send_register_watch(); + Context *handle_register_watch(int *result); + + void send_refresh(); + Context *handle_refresh(int *result); + + Context *send_set_snap(int *result); + Context *handle_set_snap(int *result); + + void send_close_image(int error_result); + Context *handle_close_image(int *result); + +}; + +} // namespace image +} // namespace librbd + +extern template class librbd::image::OpenRequest; + +#endif // CEPH_LIBRBD_IMAGE_OPEN_REQUEST_H