]> git.itanic.dy.fi Git - linux-stable/commit
fs: Establish locking order for unrelated directories
authorJan Kara <jack@suse.cz>
Thu, 1 Jun 2023 10:58:24 +0000 (12:58 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 2 Jun 2023 13:00:17 +0000 (15:00 +0200)
commitf23ce757185319886ca80c4864ce5f81ac6cc9e9
treeae04f92b793f5952307ccc1dc00de2a6a06ac757
parentcde3c9d7e2a359e337216855dcb333a19daaa436
fs: Establish locking order for unrelated directories

Currently the locking order of inode locks for directories that are not
in ancestor relationship is not defined because all operations that
needed to lock two directories like this were serialized by
sb->s_vfs_rename_mutex. However some filesystems need to lock two
subdirectories for RENAME_EXCHANGE operations and for this we need the
locking order established even for two tree-unrelated directories.
Provide a helper function lock_two_inodes() that establishes lock
ordering for any two inodes and use it in lock_two_directories().

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20230601105830.13168-4-jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/inode.c
fs/internal.h
fs/namei.c