From: Venky Shankar Date: Thu, 5 Apr 2018 10:43:19 +0000 (-0400) Subject: rbd: do not create temporary objects whenever possible X-Git-Tag: v15.1.0~867^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=80b1ef465694b25b4a14a57acdd7129e83943b92;p=ceph.git rbd: do not create temporary objects whenever possible .. for Journal, ExclusiveLock and ObjectMap class, and in case that cannot be avoided, then make sure to destruct the object by calling ->put(). Signed-off-by: Venky Shankar --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 00505b264c2..d0f258740a0 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1118,14 +1118,19 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { CephContext *cct = ictx->cct; ldout(cct, 20) << __func__ << ": ictx=" << ictx << dendl; - if (!ictx->test_features(RBD_FEATURE_EXCLUSIVE_LOCK)) { - lderr(cct) << "exclusive-lock feature is not enabled" << dendl; - return -EINVAL; - } - managed_lock::Locker locker; C_SaferCond get_owner_ctx; - ExclusiveLock<>(*ictx).get_locker(&locker, &get_owner_ctx); + { + std::shared_lock owner_locker{ictx->owner_lock}; + + if (ictx->exclusive_lock == nullptr) { + lderr(cct) << "exclusive-lock feature is not enabled" << dendl; + return -EINVAL; + } + + ictx->exclusive_lock->get_locker(&locker, &get_owner_ctx); + } + int r = get_owner_ctx.wait(); if (r == -ENOENT) { return r;