]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: cleaned up snap/parent lock release in read-from-parent path
authorJason Dillaman <dillaman@redhat.com>
Thu, 4 Apr 2019 15:23:58 +0000 (11:23 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 15 May 2019 20:05:50 +0000 (16:05 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit b7f6ba710d2855ea8f223d205a55a1e425167afd)

src/librbd/io/CopyupRequest.cc
src/librbd/io/ObjectRequest.cc

index 37fa3d00e0ca9700b0124cbf2f6ec352035296de..d2727dd7d64ba0b6fb4086c990efcdb0fc34a1d9 100644 (file)
@@ -143,13 +143,11 @@ void CopyupRequest<I>::send() {
 template <typename I>
 void CopyupRequest<I>::read_from_parent() {
   auto cct = m_image_ctx->cct;
-  m_image_ctx->snap_lock.get_read();
-  m_image_ctx->parent_lock.get_read();
+  RWLock::RLocker snap_locker(m_image_ctx->snap_lock);
+  RWLock::RLocker parent_locker(m_image_ctx->parent_lock);
 
   if (m_image_ctx->parent == nullptr) {
     ldout(cct, 5) << "parent detached" << dendl;
-    m_image_ctx->parent_lock.put_read();
-    m_image_ctx->snap_lock.put_read();
 
     m_image_ctx->op_work_queue->queue(
       util::create_context_callback<
@@ -157,7 +155,6 @@ void CopyupRequest<I>::read_from_parent() {
       -ENOENT);
     return;
   } else if (is_deep_copy()) {
-    // will release locks
     deep_copy();
     return;
   }
@@ -175,9 +172,6 @@ void CopyupRequest<I>::read_from_parent() {
   ImageRequest<I>::aio_read(m_image_ctx->parent, comp,
                             std::move(m_image_extents),
                             ReadResult{&m_copyup_data}, 0, m_trace);
-
-  m_image_ctx->parent_lock.put_read();
-  m_image_ctx->snap_lock.put_read();
 }
 
 template <typename I>
@@ -230,8 +224,6 @@ void CopyupRequest<I>::deep_copy() {
     m_object_no, m_flatten, ctx);
 
   req->send();
-  m_image_ctx->parent_lock.put_read();
-  m_image_ctx->snap_lock.put_read();
 }
 
 template <typename I>
index 2d45173a7022061e995ce10c3296a09d3ef10f95..57bd7291c6824575029a6a17a9ac215a72dbcc4c 100644 (file)
@@ -266,8 +266,8 @@ template <typename I>
 void ObjectReadRequest<I>::read_parent() {
   I *image_ctx = this->m_ictx;
 
-  image_ctx->snap_lock.get_read();
-  image_ctx->parent_lock.get_read();
+  RWLock::RLocker snap_locker(image_ctx->snap_lock);
+  RWLock::RLocker parent_locker(image_ctx->parent_lock);
 
   // calculate reverse mapping onto the image
   Extents parent_extents;
@@ -284,8 +284,8 @@ void ObjectReadRequest<I>::read_parent() {
   }
 
   if (object_overlap == 0) {
-    image_ctx->parent_lock.put_read();
-    image_ctx->snap_lock.put_read();
+    parent_locker.unlock();
+    snap_locker.unlock();
 
     this->finish(-ENOENT);
     return;
@@ -299,9 +299,6 @@ void ObjectReadRequest<I>::read_parent() {
   ImageRequest<I>::aio_read(image_ctx->parent, parent_completion,
                             std::move(parent_extents), ReadResult{m_read_data},
                             0, this->m_trace);
-
-  image_ctx->parent_lock.put_read();
-  image_ctx->snap_lock.put_read();
 }
 
 template <typename I>