Skip to content

Commit 8290fb4

Browse files
neilbrownbrauner
authored andcommitted
ovl: narrow locking in ovl_cleanup_index()
ovl_cleanup_index() takes a lock on the directory and then does a lookup and possibly one of two different cleanups. This patch narrows the locking to use the _unlocked() versions of the lookup and one cleanup, and just takes the lock for the other cleanup. A subsequent patch will take the lock into the cleanup. Signed-off-by: NeilBrown <neil@brown.name> Link: https://lore.kernel.org/20250716004725.1206467-12-neil@brown.name Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 7dfb072 commit 8290fb4

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

fs/overlayfs/util.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,6 @@ static void ovl_cleanup_index(struct dentry *dentry)
10781078
{
10791079
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
10801080
struct dentry *indexdir = ovl_indexdir(dentry->d_sb);
1081-
struct inode *dir = indexdir->d_inode;
10821081
struct dentry *lowerdentry = ovl_dentry_lower(dentry);
10831082
struct dentry *upperdentry = ovl_dentry_upper(dentry);
10841083
struct dentry *index = NULL;
@@ -1114,21 +1113,22 @@ static void ovl_cleanup_index(struct dentry *dentry)
11141113
goto out;
11151114
}
11161115

1117-
inode_lock_nested(dir, I_MUTEX_PARENT);
1118-
index = ovl_lookup_upper(ofs, name.name, indexdir, name.len);
1116+
index = ovl_lookup_upper_unlocked(ofs, name.name, indexdir, name.len);
11191117
err = PTR_ERR(index);
11201118
if (IS_ERR(index)) {
11211119
index = NULL;
11221120
} else if (ovl_index_all(dentry->d_sb)) {
11231121
/* Whiteout orphan index to block future open by handle */
1124-
err = ovl_cleanup_and_whiteout(OVL_FS(dentry->d_sb),
1125-
indexdir, index);
1122+
err = ovl_parent_lock(indexdir, index);
1123+
if (!err) {
1124+
err = ovl_cleanup_and_whiteout(OVL_FS(dentry->d_sb),
1125+
indexdir, index);
1126+
ovl_parent_unlock(indexdir);
1127+
}
11261128
} else {
11271129
/* Cleanup orphan index entries */
1128-
err = ovl_cleanup(ofs, dir, index);
1130+
err = ovl_cleanup_unlocked(ofs, indexdir, index);
11291131
}
1130-
1131-
inode_unlock(dir);
11321132
if (err)
11331133
goto fail;
11341134

0 commit comments

Comments
 (0)