]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: skip cache initialization if data IoCtx is invalid 37674/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 21 Sep 2020 18:05:17 +0000 (14:05 -0400)
committerVicente Cheng <freeze.bilsted@gmail.com>
Thu, 15 Oct 2020 09:12:19 +0000 (09:12 +0000)
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>
(cherry picked from commit ad1016b014d4c33dee3be66376bf9f3394160501)

Conflicts:
src/librbd/plugin/ParentCache.cc
  - parent_cache_enabled is not split to above file.
    We just add another data ioctx checking before
    sending parent cache

src/librbd/image/OpenRequest.cc

index 2e30242e8f425faa7924c114c6956e7ed0ceab53..2edf2b14fe13566946952a56ace041debe1dd18a 100644 (file)
@@ -534,7 +534,8 @@ Context* OpenRequest<I>::send_parent_cache(int *result) {
   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()) {
     return send_init_cache(result);
   }
 
@@ -563,8 +564,8 @@ Context* OpenRequest<I>::handle_parent_cache(int* result) {
 
 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);
   }