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_SNAP_SET_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_SNAP_SET_REQUEST_H
7 #include "cls/rbd/cls_rbd_client.h"
14 template <typename
> class ExclusiveLock
;
16 template <typename
> class ObjectMap
;
20 template <typename
> class RefreshParentRequest
;
22 template <typename ImageCtxT
= ImageCtx
>
23 class SetSnapRequest
{
25 static SetSnapRequest
*create(ImageCtxT
&image_ctx
,
26 const cls::rbd::SnapshotNamespace
& snap_namespace
,
27 const std::string
&snap_name
,
29 return new SetSnapRequest(image_ctx
, snap_namespace
, snap_name
, on_finish
);
43 * |-----------> BLOCK_WRITES
46 * | SHUTDOWN_EXCLUSIVE_LOCK (skip if lock inactive
49 * | REFRESH_PARENT (skip if no parent
50 * | | or refresh not needed)
52 * | OPEN_OBJECT_MAP (skip if map disabled)
58 * | FINALIZE_REFRESH_PARENT (skip if no parent
59 * | | or refresh not needed)
63 * \-----------> INIT_EXCLUSIVE_LOCK (skip if active or
66 * REFRESH_PARENT (skip if no parent
67 * | or refresh not needed)
72 * FINALIZE_REFRESH_PARENT (skip if no parent
73 * | or refresh not needed)
80 SetSnapRequest(ImageCtxT
&image_ctx
, const cls::rbd::SnapshotNamespace
& snap_namespace
,
81 const std::string
&snap_name
,
84 ImageCtxT
&m_image_ctx
;
85 cls::rbd::SnapshotNamespace m_snap_namespace
;
86 std::string m_snap_name
;
90 ExclusiveLock
<ImageCtxT
> *m_exclusive_lock
;
91 ObjectMap
<ImageCtxT
> *m_object_map
;
92 RefreshParentRequest
<ImageCtxT
> *m_refresh_parent
;
94 bool m_writes_blocked
;
96 void send_block_writes();
97 Context
*handle_block_writes(int *result
);
99 void send_init_exclusive_lock();
100 Context
*handle_init_exclusive_lock(int *result
);
102 Context
*send_shut_down_exclusive_lock(int *result
);
103 Context
*handle_shut_down_exclusive_lock(int *result
);
105 Context
*send_refresh_parent(int *result
);
106 Context
*handle_refresh_parent(int *result
);
108 Context
*send_open_object_map(int *result
);
109 Context
*handle_open_object_map(int *result
);
111 Context
*send_finalize_refresh_parent(int *result
);
112 Context
*handle_finalize_refresh_parent(int *result
);
116 void send_complete();
120 } // namespace librbd
122 extern template class librbd::image::SetSnapRequest
<librbd::ImageCtx
>;
124 #endif // CEPH_LIBRBD_IMAGE_SNAP_SET_REQUEST_H