From a5970a529c2d952714f20e4bc6e529c74fd2b3b5 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 3 Apr 2021 21:55:11 +0300 Subject: Make files opened with O_PATH to not block non-forced unmount by only keeping hold count on the vnode, instead of the use count. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29323 --- sys/kern/vfs_syscalls.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sys/kern/vfs_syscalls.c') diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 5a1efcdec467..9130843f6761 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -896,7 +896,7 @@ sys_fchdir(struct thread *td, struct fchdir_args *uap) if (error != 0) return (error); vp = fp->f_vnode; - vrefact(vp); + vref(vp); fdrop(fp, td); vn_lock(vp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(vp); @@ -1191,8 +1191,13 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, if (fp->f_ops == &badfileops) { KASSERT(vp->v_type != VFIFO || (flags & O_PATH) != 0, ("Unexpected fifo fp %p vp %p", fp, vp)); - finit_vnode(fp, flags, NULL, (flags & O_PATH) != 0 ? - &path_fileops : &vnops); + if ((flags & O_PATH) != 0) { + finit_vnode(fp, flags, NULL, &path_fileops); + vhold(vp); + vunref(vp); + } else { + finit_vnode(fp, flags, NULL, &vnops); + } } VOP_UNLOCK(vp); -- cgit v1.2.3