]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add comment on locking order rules
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 5 Jan 2024 20:06:20 +0000 (15:06 -0500)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 20 Mar 2024 14:56:51 +0000 (10:56 -0400)
From a past commit.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDCache.cc

index f79e806494bf6752aa78de0e6a96265daa5f8901..5022b23dd0f33c6ea2fab38e4c97955551ae147a 100644 (file)
@@ -8240,6 +8240,24 @@ void MDCache::dispatch(const cref_t<Message> &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<CDentry*> *pdnvec, CInode **pin)