]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerDeepika Upadhyay <dupadhya@redhat.com>
Fri, 5 Nov 2021 09:22:01 +0000 (14:52 +0530)
add return after error handling and clean bdev before return

trivial fix:
<<<<<<< head
      on_finish->complete(-1);
      return;
=======
      on_finish->complete(r);
      return false;
>>>>>>> 2cd9881116a (librbd/cache/pwl: supplement error handle)

picked second patch
Signed-off-by: Yin Congmin <congmin.yin@intel.com>
(cherry picked from commit 2cd9881116a47794051615fcf0a95a5e879ae7e6)

src/librbd/cache/pwl/AbstractWriteLog.cc
src/librbd/cache/pwl/ssd/WriteLog.cc

index 5332424d42af2e37db436de9db1a7bd0b2cca9dd..62fadc3331cf690a1b1d377f62df753300c2f099 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;
   }
 
   initialize_pool(on_finish, later);
index 89ed6c3958b2688ce744fdf6024eb0faa3a298cc..36a1f9357827a60f8aa8aeb065a499432d84ea8c 100644 (file)
@@ -124,9 +124,10 @@ void 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);
-      return;
+      on_finish->complete(r);
+      return false;
     }
     m_cache_state->present = true;
     m_cache_state->clean = true;
@@ -153,7 +154,10 @@ void 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;