aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r--sys/kern/vfs_syscalls.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 35a56510e9ef..aba3d62936bb 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1370,13 +1370,12 @@ restart:
else {
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
&nd.ni_cnd, &vattr);
- if (error == 0)
- vput(nd.ni_vp);
}
}
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
+ VOP_VPUT_PAIR(nd.ni_dvp, error == 0 && !whiteout ? &nd.ni_vp : NULL,
+ true);
vn_finished_write(mp);
+ NDFREE(&nd, NDF_ONLY_PNBUF);
if (error == ERELOOKUP)
goto restart;
return (error);
@@ -1457,12 +1456,10 @@ restart:
goto out;
#endif
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
- if (error == 0)
- vput(nd.ni_vp);
#ifdef MAC
out:
#endif
- vput(nd.ni_dvp);
+ VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true);
vn_finished_write(mp);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (error == ERELOOKUP)
@@ -1629,10 +1626,10 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path,
return (EAGAIN);
}
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
- VOP_UNLOCK(vp);
- vput(nd.ni_dvp);
+ VOP_VPUT_PAIR(nd.ni_dvp, &vp, true);
vn_finished_write(mp);
NDFREE(&nd, NDF_ONLY_PNBUF);
+ vp = NULL;
} else {
vput(nd.ni_dvp);
NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -1640,7 +1637,8 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path,
return (EAGAIN);
}
}
- vrele(vp);
+ if (vp != NULL)
+ vrele(vp);
return (error);
}
@@ -1710,6 +1708,7 @@ restart:
else
vput(nd.ni_dvp);
vrele(nd.ni_vp);
+ nd.ni_vp = NULL;
error = EEXIST;
goto out;
}
@@ -1730,14 +1729,12 @@ restart:
goto out2;
#endif
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, syspath);
- if (error == 0)
- vput(nd.ni_vp);
#ifdef MAC
out2:
#endif
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
+ VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true);
vn_finished_write(mp);
+ NDFREE(&nd, NDF_ONLY_PNBUF);
if (error == ERELOOKUP)
goto restart;
out:
@@ -3794,9 +3791,7 @@ restart:
out:
#endif
NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
- if (error == 0)
- vput(nd.ni_vp);
+ VOP_VPUT_PAIR(nd.ni_dvp, error == 0 ? &nd.ni_vp : NULL, true);
vn_finished_write(mp);
if (error == ERELOOKUP)
goto restart;