Skip to content

Commit 0546849

Browse files
neilbrownbrauner
authored andcommitted
ovl: narrow locking in ovl_rename()
Drop the rename lock immediately after the rename, and use ovl_cleanup_unlocked() for cleanup. This makes way for future changes where locks are taken on individual dentries rather than the whole directory. Signed-off-by: NeilBrown <neil@brown.name> Link: https://lore.kernel.org/20250716004725.1206467-10-neil@brown.name Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 76342c9 commit 0546849

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

fs/overlayfs/dir.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,11 +1263,12 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
12631263

12641264
err = ovl_do_rename(ofs, old_upperdir, olddentry,
12651265
new_upperdir, newdentry, flags);
1266+
unlock_rename(new_upperdir, old_upperdir);
12661267
if (err)
1267-
goto out_unlock;
1268+
goto out_revert_creds;
12681269

12691270
if (cleanup_whiteout)
1270-
ovl_cleanup(ofs, old_upperdir->d_inode, newdentry);
1271+
ovl_cleanup_unlocked(ofs, old_upperdir, newdentry);
12711272

12721273
if (overwrite && d_inode(new)) {
12731274
if (new_is_dir)
@@ -1286,8 +1287,6 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
12861287
if (d_inode(new) && ovl_dentry_upper(new))
12871288
ovl_copyattr(d_inode(new));
12881289

1289-
out_unlock:
1290-
unlock_rename(new_upperdir, old_upperdir);
12911290
out_revert_creds:
12921291
ovl_revert_creds(old_cred);
12931292
if (update_nlink)
@@ -1300,6 +1299,10 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
13001299
dput(opaquedir);
13011300
ovl_cache_free(&list);
13021301
return err;
1302+
1303+
out_unlock:
1304+
unlock_rename(new_upperdir, old_upperdir);
1305+
goto out_revert_creds;
13031306
}
13041307

13051308
static int ovl_create_tmpfile(struct file *file, struct dentry *dentry,

0 commit comments

Comments
 (0)