]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: do not create temporary objects whenever possible
authorVenky Shankar <vshankar@redhat.com>
Thu, 5 Apr 2018 10:43:19 +0000 (06:43 -0400)
committerMahati Chamarthy <mahati.chamarthy@intel.com>
Mon, 11 Nov 2019 07:57:09 +0000 (13:27 +0530)
.. 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 <vshankar@redhat.com>
src/librbd/internal.cc

index 00505b264c21a37e9bee4baa5440a31ae9d73c0d..d0f258740a0f0d61094cfb42929993ebac9b5892 100644 (file)
@@ -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;