]> git.hungrycats.org Git - linux/commit
fs: better handle deep ancestor chains in is_subdir()
authorChristian Brauner <brauner@kernel.org>
Tue, 2 Jul 2024 19:03:26 +0000 (21:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:39 +0000 (09:53 +0200)
commiteb8558103b823fc00ab002e1a477ab6b9297825a
tree971e64846e0996aae1f7701ab7f031dd90799e6b
parent437c04320666e8c19dde52f1ba8cea8656c2aa91
fs: better handle deep ancestor chains in is_subdir()

[ Upstream commit 391b59b045004d5b985d033263ccba3e941a7740 ]

Jan reported that 'cd ..' may take a long time in deep directory
hierarchies under a bind-mount. If concurrent renames happen it is
possible to livelock in is_subdir() because it will keep retrying.

Change is_subdir() from simply retrying over and over to retry once and
then acquire the rename lock to handle deep ancestor chains better. The
list of alternatives to this approach were less then pleasant. Change
the scope of rcu lock to cover the whole walk while at it.

A big thanks to Jan and Linus. Both Jan and Linus had proposed
effectively the same thing just that one version ended up being slightly
more elegant.

Reported-by: Jan Kara <jack@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/dcache.c