mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
ovl: narrow locking in ovl_check_rename_whiteout()
ovl_check_rename_whiteout() now only holds the directory lock when needed, and takes it again if necessary. This makes way for future changes where locks are taken on individual dentries rather than the whole directory. Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: NeilBrown <neil@brown.name> Link: https://lore.kernel.org/20250716004725.1206467-20-neil@brown.name Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
8afa0a7367
commit
09d56cc88c
|
|
@ -556,7 +556,6 @@ static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
|
|||
static int ovl_check_rename_whiteout(struct ovl_fs *ofs)
|
||||
{
|
||||
struct dentry *workdir = ofs->workdir;
|
||||
struct inode *dir = d_inode(workdir);
|
||||
struct dentry *temp;
|
||||
struct dentry *dest;
|
||||
struct dentry *whiteout;
|
||||
|
|
@ -577,19 +576,22 @@ static int ovl_check_rename_whiteout(struct ovl_fs *ofs)
|
|||
err = PTR_ERR(dest);
|
||||
if (IS_ERR(dest)) {
|
||||
dput(temp);
|
||||
goto out_unlock;
|
||||
ovl_parent_unlock(workdir);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Name is inline and stable - using snapshot as a copy helper */
|
||||
take_dentry_name_snapshot(&name, temp);
|
||||
err = ovl_do_rename(ofs, workdir, temp, workdir, dest, RENAME_WHITEOUT);
|
||||
ovl_parent_unlock(workdir);
|
||||
if (err) {
|
||||
if (err == -EINVAL)
|
||||
err = 0;
|
||||
goto cleanup_temp;
|
||||
}
|
||||
|
||||
whiteout = ovl_lookup_upper(ofs, name.name.name, workdir, name.name.len);
|
||||
whiteout = ovl_lookup_upper_unlocked(ofs, name.name.name,
|
||||
workdir, name.name.len);
|
||||
err = PTR_ERR(whiteout);
|
||||
if (IS_ERR(whiteout))
|
||||
goto cleanup_temp;
|
||||
|
|
@ -598,18 +600,15 @@ static int ovl_check_rename_whiteout(struct ovl_fs *ofs)
|
|||
|
||||
/* Best effort cleanup of whiteout and temp file */
|
||||
if (err)
|
||||
ovl_cleanup(ofs, dir, whiteout);
|
||||
ovl_cleanup_unlocked(ofs, workdir, whiteout);
|
||||
dput(whiteout);
|
||||
|
||||
cleanup_temp:
|
||||
ovl_cleanup(ofs, dir, temp);
|
||||
ovl_cleanup_unlocked(ofs, workdir, temp);
|
||||
release_dentry_name_snapshot(&name);
|
||||
dput(temp);
|
||||
dput(dest);
|
||||
|
||||
out_unlock:
|
||||
ovl_parent_unlock(workdir);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user