cifs: fix dentry lookups in directory handle cache
authorPaulo Alcantara <pc@manguebit.com>
Fri, 24 Mar 2023 16:56:33 +0000 (13:56 -0300)
committerSteve French <stfrench@microsoft.com>
Fri, 24 Mar 2023 19:37:12 +0000 (14:37 -0500)
commitbe4fde79812f02914e350bde0bc4cfeae8429378
treeb594a846eaf0e5664c8f8286721620f6e3d895f7
parent7e0e76d99079be13c9961dde7c93b2d1ee665af4
cifs: fix dentry lookups in directory handle cache

Get rid of any prefix paths in @path before lookup_positive_unlocked()
as it will call ->lookup() which already adds those prefix paths
through build_path_from_dentry().

This has caused a performance regression when mounting shares with a
prefix path where readdir(2) would end up retrying several times to
open bad directory names that contained duplicate prefix paths.

Fix this by skipping any prefix paths in @path before calling
lookup_positive_unlocked().

Fixes: e4029e072673 ("cifs: find and use the dentry for cached non-root directories also")
Cc: stable@vger.kernel.org # 6.1+
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cached_dir.c