]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/exclusive_lock/PreReleaseRequest.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / exclusive_lock / PreReleaseRequest.cc
index 7dbae6c5992e417a625ad72ed5796c98fb222d02..fc833a1c80bcac398d7263735b71aa1d70bbcfd0 100644 (file)
@@ -109,7 +109,7 @@ void PreReleaseRequest<I>::send_block_writes() {
     klass, &klass::handle_block_writes>(this);
 
   {
-    RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
+    std::shared_lock owner_locker{m_image_ctx.owner_lock};
     // setting the lock as required will automatically cause the IO
     // queue to re-request the lock if any IO is queued
     if (m_image_ctx.clone_copy_on_read ||
@@ -165,7 +165,7 @@ void PreReleaseRequest<I>::send_invalidate_cache() {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 10) << dendl;
 
-  RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
+  std::shared_lock owner_lock{m_image_ctx.owner_lock};
   Context *ctx = create_context_callback<
       PreReleaseRequest<I>,
       &PreReleaseRequest<I>::handle_invalidate_cache>(this);
@@ -212,7 +212,7 @@ void PreReleaseRequest<I>::handle_flush_notifies(int r) {
 template <typename I>
 void PreReleaseRequest<I>::send_close_journal() {
   {
-    RWLock::WLocker snap_locker(m_image_ctx.snap_lock);
+    std::unique_lock image_locker{m_image_ctx.image_lock};
     std::swap(m_journal, m_image_ctx.journal);
   }
 
@@ -240,7 +240,8 @@ void PreReleaseRequest<I>::handle_close_journal(int r) {
     lderr(cct) << "failed to close journal: " << cpp_strerror(r) << dendl;
   }
 
-  delete m_journal;
+  m_journal->put();
+  m_journal = nullptr;
 
   send_close_object_map();
 }
@@ -248,7 +249,7 @@ void PreReleaseRequest<I>::handle_close_journal(int r) {
 template <typename I>
 void PreReleaseRequest<I>::send_close_object_map() {
   {
-    RWLock::WLocker snap_locker(m_image_ctx.snap_lock);
+    std::unique_lock image_locker{m_image_ctx.image_lock};
     std::swap(m_object_map, m_image_ctx.object_map);
   }
 
@@ -262,7 +263,7 @@ void PreReleaseRequest<I>::send_close_object_map() {
 
   using klass = PreReleaseRequest<I>;
   Context *ctx = create_context_callback<
-    klass, &klass::handle_close_object_map>(this);
+    klass, &klass::handle_close_object_map>(this, m_object_map);
   m_object_map->close(ctx);
 }
 
@@ -274,8 +275,8 @@ void PreReleaseRequest<I>::handle_close_object_map(int r) {
   if (r < 0) {
     lderr(cct) << "failed to close object map: " << cpp_strerror(r) << dendl;
   }
+  m_object_map->put();
 
-  delete m_object_map;
   send_unlock();
 }