From: Xiubo Li Date: Mon, 8 Jul 2024 07:53:28 +0000 (+0800) Subject: mds: avoid acquiring the wrlock twice for a single request X-Git-Tag: testing/wip-vshankar-testing-20250523.134245-squid-debug~60^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d5d623382da886a008f87a570e631b4ba4a6b7f5;p=ceph-ci.git mds: avoid acquiring the wrlock twice for a single request 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 Signed-off-by: Sunnatillo (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. --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index f00e588c7a2..ead3868520e 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -8509,8 +8509,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(mdr->lock_cache)->is_wrlocked(&cur->filelock))) { lov.add_wrlock(&cur->filelock); + } lov.add_rdlock(&dn->lock); } if (!mds->locker->acquire_locks(mdr, lov)) { @@ -8630,8 +8633,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(mdr->lock_cache)->is_wrlocked(&cur->filelock))) { lov.add_wrlock(&cur->filelock); + } lov.add_rdlock(&dn->lock); } if (!mds->locker->acquire_locks(mdr, lov)) {