On Fri, Jul 11, 2025 at 1:21 AM NeilBrown <neil@xxxxxxxxxx> wrote: > > Drop the directory lock immediately after the ovl_create_real() call and > take a separate lock later for cleanup in ovl_cleanup_unlocked() - if > needed. > > This makes way for future changes where locks are taken on individual > dentries rather than the whole directory. > > Signed-off-by: NeilBrown <neil@xxxxxxxxxx> > --- > fs/overlayfs/dir.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c > index 144e1753d0c9..fa438e13e8b1 100644 > --- a/fs/overlayfs/dir.c > +++ b/fs/overlayfs/dir.c > @@ -326,9 +326,9 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode, > ovl_lookup_upper(ofs, dentry->d_name.name, > upperdir, dentry->d_name.len), > attr); > - err = PTR_ERR(newdentry); > + inode_unlock(udir); > if (IS_ERR(newdentry)) > - goto out_unlock; > + return PTR_ERR(newdentry); > > if (ovl_type_merge(dentry->d_parent) && d_is_dir(newdentry) && > !ovl_allow_offline_changes(ofs)) { > @@ -340,14 +340,12 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode, > err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink, NULL); > if (err) > goto out_cleanup; > -out_unlock: > - inode_unlock(udir); > - return err; > + return 0; > > out_cleanup: > - ovl_cleanup(ofs, udir, newdentry); > + ovl_cleanup_unlocked(ofs, upperdir, newdentry); > dput(newdentry); > - goto out_unlock; > + return err; > } > Thank you for getting rid of this goto chain! Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx> Thanks, Amir.