bcachefs: Delete dentry when deleting snapshots
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 21 Oct 2021 00:50:07 +0000 (20:50 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:14 +0000 (17:09 -0400)
This fixes a bug where subsequently doing creates with the same name
fails.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/fs-ioctl.c

index ae402d350d4c8332417bb2d10dbb8d3337c814d7..a12b591ec9caa7a1faa61493b903d231f89d431a 100644 (file)
@@ -422,6 +422,7 @@ static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
                                struct bch_ioctl_subvolume arg)
 {
        struct path path;
+       struct inode *dir;
        int ret = 0;
 
        if (arg.flags)
@@ -438,7 +439,13 @@ static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
                return -EXDEV;
        }
 
-       ret = __bch2_unlink(path.dentry->d_parent->d_inode, path.dentry, 1);
+       dir = path.dentry->d_parent->d_inode;
+
+       ret = __bch2_unlink(dir, path.dentry, 1);
+       if (!ret) {
+               fsnotify_rmdir(dir, path.dentry);
+               d_delete(path.dentry);
+       }
        path_put(&path);
 
        return ret;