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_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H
5 #define CEPH_LIBRBD_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H
7 #include "librbd/ImageCtx.h"
17 namespace exclusive_lock {
19 template <typename ImageCtxT = ImageCtx>
20 class PreReleaseRequest {
22 static PreReleaseRequest* create(ImageCtxT &image_ctx, bool shutting_down,
23 AsyncOpTracker &async_op_tracker,
51 * FLUSH_NOTIFIES . . . . . . . . . . . . . .
55 * | (journal disabled, .
56 * v object map enabled) .
57 * CLOSE_OBJECT_MAP < . . . . . . . . . . . .
59 * v (object map disabled) .
60 * <finish> < . . . . . . . . . . . . . . . . .
65 PreReleaseRequest(ImageCtxT &image_ctx, bool shutting_down,
66 AsyncOpTracker &async_op_tracker, Context *on_finish);
68 ImageCtxT &m_image_ctx;
70 AsyncOpTracker &m_async_op_tracker;
73 int m_error_result = 0;
75 decltype(m_image_ctx.object_map) m_object_map = nullptr;
76 decltype(m_image_ctx.journal) m_journal = nullptr;
78 void send_prepare_lock();
79 void handle_prepare_lock(int r);
81 void send_cancel_op_requests();
82 void handle_cancel_op_requests(int r);
84 void send_block_writes();
85 void handle_block_writes(int r);
87 void send_wait_for_ops();
88 void handle_wait_for_ops(int r);
90 void send_invalidate_cache(bool purge_on_error);
91 void handle_invalidate_cache(int r);
93 void send_flush_notifies();
94 void handle_flush_notifies(int r);
96 void send_close_journal();
97 void handle_close_journal(int r);
99 void send_close_object_map();
100 void handle_close_object_map(int r);
106 void save_result(int result) {
107 if (m_error_result == 0 && result < 0) {
108 m_error_result = result;
114 } // namespace exclusive_lock
115 } // namespace librbd
117 #endif // CEPH_LIBRBD_EXCLUSIVE_LOCK_PRE_RELEASE_REQUEST_H