When shrinking an image, it's possible that the op flush callback
will be from within the cache callback context. This would result
in a deadlock when attempting to re-lock the cache lock in order to
invalidate the cache.
Fixes: #11743
Backport: hammer
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit
726d699b7790c7e371279281ab32cd3aeb8ece7b)
return new FunctionContext(boost::bind(&AsyncRequest::complete, this, _1));
}
+Context *AsyncRequest::create_async_callback_context() {
+ return new FunctionContext(boost::bind(&AsyncRequest::async_complete, this,
+ _1));;
+}
+
} // namespace librbd
librados::AioCompletion *create_callback_completion();
Context *create_callback_context();
+ Context *create_async_callback_context();
void async_complete(int r);
m_state = STATE_FLUSH;
// with clipping adjusted, ensure that write / copy-on-read operations won't
- // (re-)create objects that we just removed
- m_image_ctx.flush_async_operations(create_callback_context());
+ // (re-)create objects that we just removed. need async callback to ensure
+ // we don't have cache_lock already held
+ m_image_ctx.flush_async_operations(create_async_callback_context());
}
void AsyncResizeRequest::send_invalidate_cache() {