From: Jason Dillaman Date: Fri, 26 May 2017 19:36:47 +0000 (-0400) Subject: librbd: accept_requests helper should accept optional return code X-Git-Tag: ses5-milestone6~8^2~5^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b348758be75e29f2d8461f515f2a4a204a67f4b8;p=ceph.git librbd: accept_requests helper should accept optional return code Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc index a6f8b08cf36c..1688afca98cf 100644 --- a/src/librbd/ExclusiveLock.cc +++ b/src/librbd/ExclusiveLock.cc @@ -42,7 +42,9 @@ bool ExclusiveLock::accept_requests(int *ret_val) const { bool accept_requests = (!ML::is_state_shutdown() && ML::is_state_locked() && m_request_blocked_count == 0); - *ret_val = m_request_blocked_ret_val; + if (ret_val != nullptr) { + *ret_val = m_request_blocked_ret_val; + } ldout(m_image_ctx.cct, 20) << "=" << accept_requests << dendl; return accept_requests; diff --git a/src/librbd/ExclusiveLock.h b/src/librbd/ExclusiveLock.h index 7b2e63c2bcbd..3b2a756edc0a 100644 --- a/src/librbd/ExclusiveLock.h +++ b/src/librbd/ExclusiveLock.h @@ -18,7 +18,7 @@ public: ExclusiveLock(ImageCtxT &image_ctx); - bool accept_requests(int *ret_val) const; + bool accept_requests(int *ret_val = nullptr) const; void block_requests(int r); void unblock_requests(); diff --git a/src/librbd/Operations.cc b/src/librbd/Operations.cc index c70ff6f91112..af0cb1220d46 100644 --- a/src/librbd/Operations.cc +++ b/src/librbd/Operations.cc @@ -192,9 +192,8 @@ struct C_InvokeAsyncRequest : public Context { return; } - int r; if (image_ctx.exclusive_lock->is_lock_owner() && - image_ctx.exclusive_lock->accept_requests(&r)) { + image_ctx.exclusive_lock->accept_requests()) { send_local_request(); owner_lock.put_read(); return; @@ -1473,7 +1472,6 @@ int Operations::prepare_image_update() { } // need to upgrade to a write lock - int r = 0; bool trying_lock = false; C_SaferCond ctx; m_image_ctx.owner_lock.put_read(); @@ -1481,12 +1479,13 @@ int Operations::prepare_image_update() { RWLock::WLocker owner_locker(m_image_ctx.owner_lock); if (m_image_ctx.exclusive_lock != nullptr && (!m_image_ctx.exclusive_lock->is_lock_owner() || - !m_image_ctx.exclusive_lock->accept_requests(&r))) { + !m_image_ctx.exclusive_lock->accept_requests())) { m_image_ctx.exclusive_lock->try_acquire_lock(&ctx); trying_lock = true; } } + int r = 0; if (trying_lock) { r = ctx.wait(); }