template <typename I>
void CloseRequest<I>::send() {
- send_shut_down_update_watchers();
+ send_block_image_watcher();
}
template <typename I>
-void CloseRequest<I>::send_shut_down_update_watchers() {
+void CloseRequest<I>::send_block_image_watcher() {
+ if (m_image_ctx->image_watcher == nullptr) {
+ send_shut_down_update_watchers();
+ return;
+ }
+
CephContext *cct = m_image_ctx->cct;
ldout(cct, 10) << this << " " << __func__ << dendl;
- m_image_ctx->state->shut_down_update_watchers(create_async_context_callback(
- *m_image_ctx, create_context_callback<
- CloseRequest<I>, &CloseRequest<I>::handle_shut_down_update_watchers>(this)));
+ // prevent incoming requests from our peers
+ m_image_ctx->image_watcher->block_notifies(create_context_callback<
+ CloseRequest<I>, &CloseRequest<I>::handle_block_image_watcher>(this));
}
template <typename I>
-void CloseRequest<I>::handle_shut_down_update_watchers(int r) {
+void CloseRequest<I>::handle_block_image_watcher(int r) {
CephContext *cct = m_image_ctx->cct;
ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
- save_result(r);
- if (r < 0) {
- lderr(cct) << "failed to shut down update watchers: " << cpp_strerror(r)
- << dendl;
- }
-
- send_unregister_image_watcher();
+ send_shut_down_update_watchers();
}
template <typename I>
-void CloseRequest<I>::send_unregister_image_watcher() {
- if (m_image_ctx->image_watcher == nullptr) {
- send_shut_down_io_queue();
- return;
- }
-
+void CloseRequest<I>::send_shut_down_update_watchers() {
CephContext *cct = m_image_ctx->cct;
ldout(cct, 10) << this << " " << __func__ << dendl;
- // prevent incoming requests from our peers
- m_image_ctx->image_watcher->unregister_watch(create_context_callback<
- CloseRequest<I>, &CloseRequest<I>::handle_unregister_image_watcher>(this));
+ m_image_ctx->state->shut_down_update_watchers(create_async_context_callback(
+ *m_image_ctx, create_context_callback<
+ CloseRequest<I>, &CloseRequest<I>::handle_shut_down_update_watchers>(this)));
}
template <typename I>
-void CloseRequest<I>::handle_unregister_image_watcher(int r) {
+void CloseRequest<I>::handle_shut_down_update_watchers(int r) {
CephContext *cct = m_image_ctx->cct;
ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
save_result(r);
if (r < 0) {
- lderr(cct) << "failed to unregister image watcher: " << cpp_strerror(r)
+ lderr(cct) << "failed to shut down update watchers: " << cpp_strerror(r)
<< dendl;
}
lderr(cct) << "failed to shut down exclusive lock: " << cpp_strerror(r)
<< dendl;
}
- send_flush_readahead();
+
+ send_unregister_image_watcher();
}
template <typename I>
if (r < 0) {
lderr(cct) << "failed to flush IO: " << cpp_strerror(r) << dendl;
}
+ send_unregister_image_watcher();
+}
+
+template <typename I>
+void CloseRequest<I>::send_unregister_image_watcher() {
+ if (m_image_ctx->image_watcher == nullptr) {
+ send_flush_readahead();
+ return;
+ }
+
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ m_image_ctx->image_watcher->unregister_watch(create_context_callback<
+ CloseRequest<I>, &CloseRequest<I>::handle_unregister_image_watcher>(this));
+}
+
+template <typename I>
+void CloseRequest<I>::handle_unregister_image_watcher(int r) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
+
+ save_result(r);
+ if (r < 0) {
+ lderr(cct) << "failed to unregister image watcher: " << cpp_strerror(r)
+ << dendl;
+ }
+
send_flush_readahead();
}