]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: avoid acquiring the wrlock twice for a single request 61839/head
authorXiubo Li <xiubli@redhat.com>
Mon, 8 Jul 2024 07:53:28 +0000 (15:53 +0800)
committerVenky Shankar <vshankar@redhat.com>
Mon, 17 Feb 2025 07:14:50 +0000 (12:44 +0530)
In case the current request has lock cache attached and then the
lock cache must have already acquired the wrlock of filelock. So
currently the path_traverse() will acquire the wrlock twice and
possibly caused deadlock by itself.

Fixes: https://tracker.ceph.com/issues/65607
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Sunnatillo <sunnat.samadov@est.tech>
(cherry picked from commit 276b81a55d391b52f9772fc76b86b845eb3854a6)

Conflicts:
    src/mds/MDSRank.cc

This commit moves around the config `mds_allow_async_dirops` in
the tracked keys which caused the conflict - avoid the move.

src/mds/MDCache.cc

index 34d83d50de3704ddc380d4d5c24e3f2bdb2a8e1e..dcdab4c0a0556c4a6a44fb242654323af641e586 100644 (file)
@@ -8447,8 +8447,11 @@ int MDCache::path_traverse(MDRequestRef& mdr, MDSContextFactory& cf,
          lov.add_xlock(&dn->lock);
        } else {
          // force client to flush async dir operation if necessary
-         if (cur->filelock.is_cached())
+         if (cur->filelock.is_cached() &&
+             !(mdr->lock_cache &&
+               static_cast<const MutationImpl*>(mdr->lock_cache)->is_wrlocked(&cur->filelock))) {
            lov.add_wrlock(&cur->filelock);
+         }
          lov.add_rdlock(&dn->lock);
        }
        if (!mds->locker->acquire_locks(mdr, lov)) {
@@ -8568,8 +8571,11 @@ int MDCache::path_traverse(MDRequestRef& mdr, MDSContextFactory& cf,
                lov.add_xlock(&dn->lock);
              } else {
                // force client to flush async dir operation if necessary
-               if (cur->filelock.is_cached())
+               if (cur->filelock.is_cached() &&
+                   !(mdr->lock_cache &&
+                     static_cast<const MutationImpl*>(mdr->lock_cache)->is_wrlocked(&cur->filelock))) {
                  lov.add_wrlock(&cur->filelock);
+               }
                lov.add_rdlock(&dn->lock);
              }
              if (!mds->locker->acquire_locks(mdr, lov)) {