This resolves the potential for an assertion failure in the cache
constructors that occurs when the data IoCtx is not valid. Errors
are deferred until actual IOs are issued against the invalid data
pool.
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
template <typename I>
Context *OpenRequest<I>::send_init_cache(int *result) {
- // cache is disabled or parent image context
- if (!m_image_ctx->cache || m_image_ctx->child != nullptr) {
+ if (!m_image_ctx->cache || m_image_ctx->child != nullptr ||
+ !m_image_ctx->data_ctx.is_valid()) {
return send_register_watch(result);
}
m_image_ctx = image_ctx;
bool parent_cache_enabled = m_image_ctx->config.template get_val<bool>(
"rbd_parent_cache_enabled");
- if (m_image_ctx->child == nullptr || !parent_cache_enabled) {
+ if (m_image_ctx->child == nullptr || !parent_cache_enabled ||
+ !m_image_ctx->data_ctx.is_valid()) {
on_finish->complete(0);
return;
}