Skip to content

Commit 7dfb072

Browse files
neilbrownbrauner
authored andcommitted
ovl: narrow locking in ovl_cleanup_whiteouts()
Rather than lock the directory for the whole operation, use ovl_lookup_upper_unlocked() and ovl_cleanup_unlocked() to take the lock only when needed. 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-11-neil@brown.name Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 0546849 commit 7dfb072

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

fs/overlayfs/readdir.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,25 +1034,23 @@ void ovl_cleanup_whiteouts(struct ovl_fs *ofs, struct dentry *upper,
10341034
{
10351035
struct ovl_cache_entry *p;
10361036

1037-
inode_lock_nested(upper->d_inode, I_MUTEX_CHILD);
10381037
list_for_each_entry(p, list, l_node) {
10391038
struct dentry *dentry;
10401039

10411040
if (WARN_ON(!p->is_whiteout || !p->is_upper))
10421041
continue;
10431042

1044-
dentry = ovl_lookup_upper(ofs, p->name, upper, p->len);
1043+
dentry = ovl_lookup_upper_unlocked(ofs, p->name, upper, p->len);
10451044
if (IS_ERR(dentry)) {
10461045
pr_err("lookup '%s/%.*s' failed (%i)\n",
10471046
upper->d_name.name, p->len, p->name,
10481047
(int) PTR_ERR(dentry));
10491048
continue;
10501049
}
10511050
if (dentry->d_inode)
1052-
ovl_cleanup(ofs, upper->d_inode, dentry);
1051+
ovl_cleanup_unlocked(ofs, upper, dentry);
10531052
dput(dentry);
10541053
}
1055-
inode_unlock(upper->d_inode);
10561054
}
10571055

10581056
static bool ovl_check_d_type(struct dir_context *ctx, const char *name,

0 commit comments

Comments
 (0)