1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H
7 #include "include/int_types.h"
8 #include "librbd/Types.h"
18 template <typename ImageCtxT = ImageCtx>
19 class RefreshParentRequest {
21 static RefreshParentRequest *create(ImageCtxT &child_image_ctx,
22 const ParentInfo &parent_md,
24 return new RefreshParentRequest(child_image_ctx, parent_md, on_finish);
27 static bool is_refresh_required(ImageCtxT &child_image_ctx,
28 const ParentInfo &parent_md);
32 void finalize(Context *on_finish);
41 * |----------------> OPEN_PARENT * * * * * * * * * * * * * * *
44 * | SET_PARENT_SNAP * * * * * * *
47 * \----------------> <apply> * *
49 * | (close required) v *
50 * |-----------------> CLOSE_PARENT *
53 * \-----------------> <finish> < * * * *
58 RefreshParentRequest(ImageCtxT &child_image_ctx, const ParentInfo &parent_md,
61 ImageCtxT &m_child_image_ctx;
62 ParentInfo m_parent_md;
65 ImageCtxT *m_parent_image_ctx;
66 uint64_t m_parent_snap_id;
70 static bool is_close_required(ImageCtxT &child_image_ctx,
71 const ParentInfo &parent_md);
72 static bool is_open_required(ImageCtxT &child_image_ctx,
73 const ParentInfo &parent_md);
75 void send_open_parent();
76 Context *handle_open_parent(int *result);
78 void send_set_parent_snap();
79 Context *handle_set_parent_snap(int *result);
81 void send_close_parent();
82 Context *handle_close_parent(int *result);
84 void send_complete(int r);
86 void save_result(int *result) {
87 if (m_error_result == 0 && *result < 0) {
88 m_error_result = *result;
97 extern template class librbd::image::RefreshParentRequest<librbd::ImageCtx>;
99 #endif // CEPH_LIBRBD_IMAGE_REFRESH_PARENT_REQUEST_H