]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: accept_requests helper should accept optional return code
authorJason Dillaman <dillaman@redhat.com>
Fri, 26 May 2017 19:36:47 +0000 (15:36 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 1 Jun 2017 16:23:33 +0000 (12:23 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ExclusiveLock.cc
src/librbd/ExclusiveLock.h
src/librbd/Operations.cc

index a6f8b08cf36cbbf2237f9bfa4e0e4704aa7f3973..1688afca98cf4cf40984bdd8488207e15171c357 100644 (file)
@@ -42,7 +42,9 @@ bool ExclusiveLock<I>::accept_requests(int *ret_val) const {
   bool accept_requests = (!ML<I>::is_state_shutdown() &&
                           ML<I>::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;
index 7b2e63c2bcbdce0edef9a29f0f72e40e8f1fd6ba..3b2a756edc0a45180b45e958cd21ead333624cc8 100644 (file)
@@ -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();
index c70ff6f91112c202243c1e6b255d8ff30a5493b7..af0cb1220d465554b35e4d252cd1ad5ebf7f6f3c 100644 (file)
@@ -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<I>::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<I>::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();
   }