From f8a9aeffcdaf8e8de4cbb993d62c80a518754573 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 25 Nov 2015 14:09:25 -0500 Subject: [PATCH] librbd: snap create doesn't properly handle race conditions The ESTALE result code was being filtered out, preventing the retry logic. Signed-off-by: Jason Dillaman --- src/librbd/operation/SnapshotCreateRequest.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librbd/operation/SnapshotCreateRequest.cc b/src/librbd/operation/SnapshotCreateRequest.cc index 545a7ba9953d8..37f2841422e69 100644 --- a/src/librbd/operation/SnapshotCreateRequest.cc +++ b/src/librbd/operation/SnapshotCreateRequest.cc @@ -69,6 +69,7 @@ bool SnapshotCreateRequest::should_complete(int r) { CephContext *cct = image_ctx.cct; ldout(cct, 5) << this << " " << __func__ << ": state=" << m_state << ", " << "r=" << r << dendl; + int orig_result = r; r = filter_state_return_code(r); if (r < 0) { lderr(cct) << "encountered error: " << cpp_strerror(r) << dendl; @@ -94,11 +95,11 @@ bool SnapshotCreateRequest::should_complete(int r) { send_create_snap(); break; case STATE_CREATE_SNAP: - if (r == 0) { + if (orig_result == 0) { update_snap_context(); finished = send_create_object_map(); } else { - assert(r == -ESTALE); + assert(orig_result == -ESTALE); send_allocate_snap_id(); } break; -- 2.39.5