tmpfs: resolve deadlock between rename and unmount.

Top-level kern_renameat() increases the writecount on the mount point,
which, together with tmpfs unmount suspending the mount, already
ensures that unmount cannot proceed while rename unlocks and relocks
all operated vnodes.

Remove vfs_busy() call from tmpfs_rename() which was done while
holding a vnode lock, creating the deadlock.  The only intent of the
busy operation seems to be the prevention of unmount, which is already
ensured.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
kib 2019-11-24 19:06:38 +00:00
parent 372acbf63e
commit fc20114fc5

View File

@ -792,7 +792,6 @@ tmpfs_rename(struct vop_rename_args *v)
struct vnode *tdvp = v->a_tdvp;
struct vnode *tvp = v->a_tvp;
struct componentname *tcnp = v->a_tcnp;
struct mount *mp = NULL;
char *newname;
struct tmpfs_dirent *de;
struct tmpfs_mount *tmp;
@ -829,18 +828,10 @@ tmpfs_rename(struct vop_rename_args *v)
*/
if (fdvp != tdvp && fdvp != tvp) {
if (vn_lock(fdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
mp = tdvp->v_mount;
error = vfs_busy(mp, 0);
if (error != 0) {
mp = NULL;
goto out;
}
error = tmpfs_rename_relock(fdvp, &fvp, tdvp, &tvp,
fcnp, tcnp);
if (error != 0) {
vfs_unbusy(mp);
if (error != 0)
return (error);
}
ASSERT_VOP_ELOCKED(fdvp,
"tmpfs_rename: fdvp not locked");
ASSERT_VOP_ELOCKED(tdvp,
@ -1084,9 +1075,6 @@ out:
vrele(fdvp);
vrele(fvp);
if (mp != NULL)
vfs_unbusy(mp);
return (error);
}