]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd/cache/pwl: supplement error handle
authorYin Congmin <congmin.yin@intel.com>
Mon, 5 Jul 2021 07:43:56 +0000 (15:43 +0800)
committerYin Congmin <congmin.yin@intel.com>
Fri, 9 Jul 2021 10:42:22 +0000 (18:42 +0800)
add return after error handling and clean bdev before return

Signed-off-by: Yin Congmin <congmin.yin@intel.com>
src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/ssd/WriteLog.cc

index 884e6065706007a0f0976b8a272df93bcb35950a..1284cc486662a2b0db703c50e46e1bfc1531f036 100644 (file)
@@ -528,6 +528,7 @@ void AbstractWriteLog<I>::pwl_init(Context *on_finish, DeferredContexts &later)
              (access(m_log_pool_name.c_str(), F_OK) != 0)) {
     ldout(cct, 5) << "Can't find the existed pool file " << m_log_pool_name << dendl;
     on_finish->complete(-errno);
+    return;
   }
 
   bool succeeded = initialize_pool(on_finish, later);
index 1b76ddc8f591d3eb7f8588453609f7633b035a98..9b7cfc9fc74ffe3f1a8525c3bd3c5cf4158bf9d2 100644 (file)
@@ -124,8 +124,9 @@ bool WriteLog<I>::initialize_pool(Context *on_finish,
                                nullptr, nullptr, nullptr);
     int r = bdev->open(this->m_log_pool_name);
     if (r < 0) {
+      lderr(m_image_ctx.cct) << "fail to open block device." << dendl;
       delete bdev;
-      on_finish->complete(-1);
+      on_finish->complete(r);
       return false;
     }
     m_cache_state->present = true;
@@ -156,7 +157,10 @@ bool WriteLog<I>::initialize_pool(Context *on_finish,
     if (r != 0) {
       lderr(m_image_ctx.cct) << "failed to initialize pool ("
                              << this->m_log_pool_name << ")" << dendl;
+      bdev->close();
+      delete bdev;
       on_finish->complete(r);
+      return false;
     }
   } else {
     m_cache_state->present = true;