Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Guoyu Ou and committed by
Kent Overstreet
6bb3f7f4 eba38cc7

+2 -2
+2 -2
fs/bcachefs/fs-ioctl.c
··· 455 455 if (IS_ERR(victim)) 456 456 return PTR_ERR(victim); 457 457 458 + dir = d_inode(path.dentry); 458 459 if (victim->d_sb->s_fs_info != c) { 459 460 ret = -EXDEV; 460 461 goto err; ··· 464 463 ret = -ENOENT; 465 464 goto err; 466 465 } 467 - dir = d_inode(path.dentry); 468 466 ret = __bch2_unlink(dir, victim, true); 469 467 if (!ret) { 470 468 fsnotify_rmdir(dir, victim); 471 469 d_delete(victim); 472 470 } 473 - inode_unlock(dir); 474 471 err: 472 + inode_unlock(dir); 475 473 dput(victim); 476 474 path_put(&path); 477 475 return ret;