]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
simple_recursive_removal(): saner interaction with fsnotify
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 6 Mar 2025 23:28:56 +0000 (18:28 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 16 Jun 2025 19:07:34 +0000 (15:07 -0400)
Make it match the real unlink(2)/rmdir(2) - notify *after* the
operation.  And use fsnotify_delete() instead of messing with
fsnotify_unlink()/fsnotify_rmdir().

Currently the only caller that cares is the one in debugfs, and
there the order matching the normal syscalls makes more sense;
it'll get more serious for users introduced later in the series.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/libfs.c

index 9ea0ecc325a81c93a55e584824417789e8d1aea0..42e226af6095a06ca39f899f474da758abda0da9 100644 (file)
@@ -628,12 +628,9 @@ void simple_recursive_removal(struct dentry *dentry,
                        inode_lock(inode);
                        if (simple_positive(victim)) {
                                d_invalidate(victim);   // avoid lost mounts
-                               if (d_is_dir(victim))
-                                       fsnotify_rmdir(inode, victim);
-                               else
-                                       fsnotify_unlink(inode, victim);
                                if (callback)
                                        callback(victim);
+                               fsnotify_delete(inode, d_inode(victim), victim);
                                dput(victim);           // unpin it
                        }
                        if (victim == dentry) {