From: Patrick Donnelly Date: Fri, 5 Jan 2024 20:06:20 +0000 (-0500) Subject: mds: add comment on locking order rules X-Git-Tag: testing/wip-root-testing-20240411.174241~89^2~56 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=48be885ae1e56cf3eb034773b8e1bc7b441d5213;p=ceph-ci.git mds: add comment on locking order rules From a past commit. Signed-off-by: Patrick Donnelly (cherry picked from commit 32a544f9a71aa68547db5bb0fdd517cafbf7d928) --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index f79e806494b..5022b23dd0f 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -8240,6 +8240,24 @@ void MDCache::dispatch(const cref_t &m) } } +/** + * In 246f647566095c173e5e0e54661696cea230f96e, an updated rule for locking order + * was established (differing from past strategies): + * + * [The helper function is for requests that operate on two paths. It + * ensures that the two paths get locks in proper order.] The rule is: + * + * 1. Lock directory inodes or dentries according to which trees they + * are under. Lock objects under fs root before objects under mdsdir. + * 2. Lock directory inodes or dentries according to their depth, in + * ascending order. + * 3. Lock directory inodes or dentries according to inode numbers or + * dentries' parent inode numbers, in ascending order. + * 4. Lock dentries in the same directory in order of their keys. + * 5. Lock non-directory inodes according to inode numbers, in ascending + * order. + */ + int MDCache::path_traverse(const MDRequestRef& mdr, MDSContextFactory& cf, const filepath& path, int flags, vector *pdnvec, CInode **pin)