Skip to content

Commit

Permalink
librbd: cleaned up snap/parent lock release in read-from-parent path
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit b7f6ba7)
  • Loading branch information
Jason Dillaman committed May 15, 2019
1 parent c03830c commit 9ee462a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
12 changes: 2 additions & 10 deletions src/librbd/io/CopyupRequest.cc
Expand Up @@ -143,21 +143,18 @@ 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<
CopyupRequest<I>, &CopyupRequest<I>::handle_read_from_parent>(this),
-ENOENT);
return;
} else if (is_deep_copy()) {
// will release locks
deep_copy();
return;
}
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
11 changes: 4 additions & 7 deletions src/librbd/io/ObjectRequest.cc
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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>
Expand Down

0 comments on commit 9ee462a

Please sign in to comment.