ovl: change ovl_create_index() to take dir locks
authorNeilBrown <neil@brown.name>
Wed, 16 Jul 2025 00:44:13 +0000 (10:44 +1000)
committerChristian Brauner <brauner@kernel.org>
Fri, 18 Jul 2025 09:10:40 +0000 (11:10 +0200)
commitc4f8f862b31ccd3d633475fe3982490c744b6565
treefb7a9c2fc1e48cc37d6aa9afed1ba1a6ece05d65
parent9d23967b18c64b058cc0a03a8932413bcb37ebb9
ovl: change ovl_create_index() to take dir locks

ovl_copy_up_workdir() currently take a rename lock on two directories,
then use the lock to both create a file in one directory, perform a
rename, and possibly unlink the file for cleanup.  This is incompatible
with proposed changes which will lock just the dentry of objects being
acted on.

This patch moves the call to ovl_create_index() earlier in
ovl_copy_up_workdir() to before the lock is taken.

ovl_create_index() then takes the required lock only when needed.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://lore.kernel.org/20250716004725.1206467-3-neil@brown.name
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/copy_up.c