From 0b89d978463f7fd74185659a4376bf2c9634e908 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Sat, 6 Dec 2025 09:32:08 +0100 Subject: [PATCH] librbd: add ExclusiveLock::accept_request() overload Make ret_val out parameter required for the existing method and introduce an overload taking just request_type to compensate. Signed-off-by: Ilya Dryomov (cherry picked from commit 3327001c8f65aebf9eb08fe5d28c8e344f338d4d) --- src/librbd/ExclusiveLock.cc | 14 +++++++++----- src/librbd/ExclusiveLock.h | 1 + src/librbd/Operations.cc | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc index bc148b1f5cd..fc2d2186ea8 100644 --- a/src/librbd/ExclusiveLock.cc +++ b/src/librbd/ExclusiveLock.cc @@ -41,6 +41,12 @@ ExclusiveLock::ExclusiveLock(I &image_ctx) ML::set_state_uninitialized(); } +template +bool ExclusiveLock::accept_request(OperationRequestType request_type) const { + int ret_val; // ignored + return accept_request(request_type, &ret_val); +} + template bool ExclusiveLock::accept_request(OperationRequestType request_type, int *ret_val) const { @@ -51,12 +57,10 @@ bool ExclusiveLock::accept_request(OperationRequestType request_type, (m_request_blocked_count == 0 || m_image_ctx.get_exclusive_lock_policy()->accept_blocked_request( request_type))); - if (ret_val != nullptr) { - *ret_val = accept_request ? 0 : m_request_blocked_ret_val; - } + *ret_val = accept_request ? 0 : m_request_blocked_ret_val; - ldout(m_image_ctx.cct, 20) << "=" << accept_request << " (request_type=" - << request_type << ")" << dendl; + ldout(m_image_ctx.cct, 20) << "=" << accept_request << " ret_val=" << *ret_val + << " (request_type=" << request_type << ")" << dendl; return accept_request; } diff --git a/src/librbd/ExclusiveLock.h b/src/librbd/ExclusiveLock.h index 9915262f9d9..34490eda098 100644 --- a/src/librbd/ExclusiveLock.h +++ b/src/librbd/ExclusiveLock.h @@ -26,6 +26,7 @@ public: ExclusiveLock(ImageCtxT &image_ctx); + bool accept_request(exclusive_lock::OperationRequestType request_type) const; bool accept_request(exclusive_lock::OperationRequestType request_type, int *ret_val) const; bool accept_ops() const; diff --git a/src/librbd/Operations.cc b/src/librbd/Operations.cc index e3cf3df3d95..6cea202dbbc 100644 --- a/src/librbd/Operations.cc +++ b/src/librbd/Operations.cc @@ -256,7 +256,7 @@ struct C_InvokeAsyncRequest : public Context { } if (image_ctx.exclusive_lock->is_lock_owner() && - image_ctx.exclusive_lock->accept_request(request_type, nullptr)) { + image_ctx.exclusive_lock->accept_request(request_type)) { send_local_request(); owner_lock.unlock_shared(); return; @@ -1849,7 +1849,7 @@ int Operations::prepare_image_update( std::unique_lock 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_request(request_type, nullptr))) { + !m_image_ctx.exclusive_lock->accept_request(request_type))) { attempting_lock = true; m_image_ctx.exclusive_lock->block_requests(0); -- 2.47.3