Skip to content

Commit 6bb3f7f

Browse files
ouonlineKent Overstreet
authored andcommitted
bcachefs: unlock parent dir if entry is not found in subvolume deletion
Parent dir is locked by user_path_locked_at() before validating the required dentry. It should be unlocked if we can not perform the deletion. This fixes the problem: $ bcachefs subvolume delete not-exist-entry BCH_IOCTL_SUBVOLUME_DESTROY ioctl error: No such file or directory $ bcachefs subvolume delete not-exist-entry the second will stuck because the parent dir is locked in the previous deletion. Signed-off-by: Guoyu Ou <benogy@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent eba38cc commit 6bb3f7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/bcachefs/fs-ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
455455
if (IS_ERR(victim))
456456
return PTR_ERR(victim);
457457

458+
dir = d_inode(path.dentry);
458459
if (victim->d_sb->s_fs_info != c) {
459460
ret = -EXDEV;
460461
goto err;
@@ -463,14 +464,13 @@ static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
463464
ret = -ENOENT;
464465
goto err;
465466
}
466-
dir = d_inode(path.dentry);
467467
ret = __bch2_unlink(dir, victim, true);
468468
if (!ret) {
469469
fsnotify_rmdir(dir, victim);
470470
d_delete(victim);
471471
}
472-
inode_unlock(dir);
473472
err:
473+
inode_unlock(dir);
474474
dput(victim);
475475
path_put(&path);
476476
return ret;

0 commit comments

Comments
 (0)