]> git.ipfire.org Git - thirdparty/linux.git/commit
smb/server: simplify ksmbd_vfs_kern_path_locked()
authorNeilBrown <neil@brown.name>
Sat, 19 Jul 2025 09:46:42 +0000 (18:46 +0900)
committerSteve French <stfrench@microsoft.com>
Mon, 21 Jul 2025 00:17:13 +0000 (19:17 -0500)
commita5dc90a9c355a30300ea4b4b25f0732270568d83
tree4e88f97716959ec1280a0bc5dd681e75a2eda815
parent09f124b2871b3cf1e04fcdd3aff7932ecc8c125c
smb/server: simplify ksmbd_vfs_kern_path_locked()

ksmbd_vfs_kern_path_locked() first tries to look up the path with the
given case.  When this fails, if caseless is set, it loops over the
components in the path, opening the relevant directory and searching
for a name which matches.  This name is copied over the original and the
the process repeats.  Each time a lookup with the newly updated path is
repeated from the top (vfs_path_lookup()).

When the last component has been case-corrected the simplest next step
is to repeat the original lookup with ksmbd_vfs_path_lookup_locked().
If this works it gives exactly what we want, if it fails it gives the
correct failure.

This observation allows the code to be simplified, in particular
removing the ksmbd_vfs_lock_parent() call.

This patch also removes the duplication of name and filepath (two
names for the one thing) and calls path_put(parent_path) sooner so
parent_path can be passed directly to vfs_path_lookup avoiding the need
to store it temporarily in path and then copying into parent_path.

This patch removes one user of ksmbd_vfs_lock_parent() which will
simplify a future patch.

Signed-off-by: NeilBrown <neil@brown.name>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/vfs.c