]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovl: Simplify ovl_lookup_real_one()
authorNeilBrown <neil@brown.name>
Tue, 24 Feb 2026 22:16:54 +0000 (09:16 +1100)
committerChristian Brauner <brauner@kernel.org>
Fri, 6 Mar 2026 09:24:12 +0000 (10:24 +0100)
commit2c3a9eb1b4f711c00c4358c16a036a2390d9e57c
tree48f67bbd2acb9ade546e824d07980079b433f034
parent336faf5d9115ca6982b82cf122e68738ea8c4173
ovl: Simplify ovl_lookup_real_one()

The primary purpose of this patch is to remove the locking from
ovl_lookup_real_one() as part of centralising all locking of directories
for name operations.

The locking here isn't needed.  By performing consistency tests after
the lookup we can be sure that the result of the lookup was valid at
least for a moment, which is all the original code promised.

lookup_noperm_unlocked() is used for the lookup and it will take the
lock if needed only where it is needed.

Also:
 - don't take a reference to real->d_parent.  The parent is
   only use for a pointer comparison, and no reference is needed for
   that.
 - Several "if" statements have a "goto" followed by "else" - the
   else isn't needed: the following statement can directly follow
   the "if" as a new statement
 - Use a consistent pattern of setting "err" before performing a test
   and possibly going to "fail".
 - remove the "out" label (now that we don't need to dput(parent) or
   unlock) and simply return from fail:.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://patch.msgid.link/20260224222542.3458677-10-neilb@ownmail.net
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/overlayfs/export.c