]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: avoid acquiring the wrlock twice for a single request
authorXiubo Li <xiubli@redhat.com>
Mon, 8 Jul 2024 07:53:28 +0000 (15:53 +0800)
committerSunnatillo <sunnat.samadov@est.tech>
Tue, 7 Jan 2025 09:34:57 +0000 (11:34 +0200)
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>
src/mds/MDCache.cc
src/mds/MDSRank.cc

index 3af0d8c6b1ec5ff19f5eca2cb6f090c0fe67a6b0..cbe7c94bf09988b442a5a344c0dddae744a970f5 100644 (file)
@@ -8515,8 +8515,11 @@ int MDCache::path_traverse(const 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)) {
@@ -8635,8 +8638,11 @@ int MDCache::path_traverse(const 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)) {
index 9448e63749f14bd2db65627a1d6c4e8f3f636e70..b1e0d987194f221f784070914c51e3262633bb28 100644 (file)
@@ -4041,6 +4041,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const
     "clog_to_syslog_level", \
     "fsid", \
     "host", \
+    "mds_allow_async_dirops", \
     "mds_alternate_name_max", \
     "mds_bal_export_pin", \
     "mds_bal_fragment_dirs", \
@@ -4116,8 +4117,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const
     "mds_session_cap_acquisition_throttle", \
     "mds_session_max_caps_throttle_ratio", \
     "mds_session_metadata_threshold", \
-    "mds_symlink_recovery", \
-    "mds_allow_async_dirops"
+    "mds_symlink_recovery"
 
   constexpr bool is_sorted = [] () constexpr {
     constexpr auto arr = std::to_array<std::string_view>({KEYS});