From: Jason Dillaman Date: Thu, 4 Apr 2019 15:23:58 +0000 (-0400) Subject: librbd: cleaned up snap/parent lock release in read-from-parent path X-Git-Tag: v14.2.2~183^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9ee462a8df372384c5b15510d016b41c95d12ad7;p=ceph.git librbd: cleaned up snap/parent lock release in read-from-parent path Signed-off-by: Jason Dillaman (cherry picked from commit b7f6ba710d2855ea8f223d205a55a1e425167afd) --- diff --git a/src/librbd/io/CopyupRequest.cc b/src/librbd/io/CopyupRequest.cc index 37fa3d00e0c..d2727dd7d64 100644 --- a/src/librbd/io/CopyupRequest.cc +++ b/src/librbd/io/CopyupRequest.cc @@ -143,13 +143,11 @@ void CopyupRequest::send() { template void CopyupRequest::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::read_from_parent() { -ENOENT); return; } else if (is_deep_copy()) { - // will release locks deep_copy(); return; } @@ -175,9 +172,6 @@ void CopyupRequest::read_from_parent() { ImageRequest::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 @@ -230,8 +224,6 @@ void CopyupRequest::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 diff --git a/src/librbd/io/ObjectRequest.cc b/src/librbd/io/ObjectRequest.cc index 2d45173a702..57bd7291c68 100644 --- a/src/librbd/io/ObjectRequest.cc +++ b/src/librbd/io/ObjectRequest.cc @@ -266,8 +266,8 @@ template void ObjectReadRequest::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::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::read_parent() { ImageRequest::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