]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ovl: narrow locking in ovl_cleanup_whiteouts()
authorNeilBrown <neil@brown.name>
Wed, 16 Jul 2025 00:44:21 +0000 (10:44 +1000)
committerChristian Brauner <brauner@kernel.org>
Fri, 18 Jul 2025 09:10:41 +0000 (11:10 +0200)
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>
fs/overlayfs/readdir.c

index 68cca52ae2acb9321ed9ed73b6dccd0c7aa4fab0..2a222b8185a345e3884dade747fcd1f1542c88fa 100644 (file)
@@ -1034,14 +1034,13 @@ void ovl_cleanup_whiteouts(struct ovl_fs *ofs, struct dentry *upper,
 {
        struct ovl_cache_entry *p;
 
-       inode_lock_nested(upper->d_inode, I_MUTEX_CHILD);
        list_for_each_entry(p, list, l_node) {
                struct dentry *dentry;
 
                if (WARN_ON(!p->is_whiteout || !p->is_upper))
                        continue;
 
-               dentry = ovl_lookup_upper(ofs, p->name, upper, p->len);
+               dentry = ovl_lookup_upper_unlocked(ofs, p->name, upper, p->len);
                if (IS_ERR(dentry)) {
                        pr_err("lookup '%s/%.*s' failed (%i)\n",
                               upper->d_name.name, p->len, p->name,
@@ -1049,10 +1048,9 @@ void ovl_cleanup_whiteouts(struct ovl_fs *ofs, struct dentry *upper,
                        continue;
                }
                if (dentry->d_inode)
-                       ovl_cleanup(ofs, upper->d_inode, dentry);
+                       ovl_cleanup_unlocked(ofs, upper, dentry);
                dput(dentry);
        }
-       inode_unlock(upper->d_inode);
 }
 
 static bool ovl_check_d_type(struct dir_context *ctx, const char *name,