git: 821467b5a087 - releng/13.1 - Mostly revert a5970a529c2d95271: Make files opened with O_PATH to not block non-forced unmount

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 19 Apr 2022 21:03:47 UTC
The branch releng/13.1 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=821467b5a087bbe5ee7eac5345dbddaf7c799e7c

commit 821467b5a087bbe5ee7eac5345dbddaf7c799e7c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-04-13 00:47:45 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-04-19 21:03:16 +0000

    Mostly revert a5970a529c2d95271: Make files opened with O_PATH to not block non-forced unmount
    
    Approved by:    re (gjb)
    
    (cherry picked from commit bf13db086b84c29ce901145f2800c561dcbf4d1e)
    (cherry picked from commit 6daddc54debbf590cae17bead4864c7f640c07d0)
---
 lib/libc/sys/open.2     | 5 +----
 sys/kern/kern_descrip.c | 2 +-
 sys/kern/vfs_syscalls.c | 2 --
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index f6b061079ddf..876a4ce1e57d 100644
--- a/lib/libc/sys/open.2
+++ b/lib/libc/sys/open.2
@@ -28,7 +28,7 @@
 .\"     @(#)open.2	8.2 (Berkeley) 11/16/93
 .\" $FreeBSD$
 .\"
-.Dd October 9, 2021
+.Dd April 22, 2022
 .Dt OPEN 2
 .Os
 .Sh NAME
@@ -351,9 +351,6 @@ But operations like
 and any other that operate on file and not on file descriptor (except
 .Xr fstat 2 ),
 are not allowed.
-File opened with the
-.Dv O_PATH
-flag does not prevent non-forced unmount of the volume it belongs to.
 .Pp
 A file descriptor created with the
 .Dv O_PATH
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 8764e1562c56..d584c54403b3 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -5200,7 +5200,7 @@ path_close(struct file *fp, struct thread *td)
 {
 	MPASS(fp->f_type == DTYPE_VNODE);
 	fp->f_ops = &badfileops;
-	vdrop(fp->f_vnode);
+	vrele(fp->f_vnode);
 	return (0);
 }
 
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 32868eb7a4d5..d90dd72c8ead 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1208,8 +1208,6 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
 		if ((flags & O_PATH) != 0) {
 			finit(fp, (flags & FMASK) | (fp->f_flag & FKQALLOWED),
 			    DTYPE_VNODE, NULL, &path_fileops);
-			vhold(vp);
-			vunref(vp);
 		} else {
 			finit_vnode(fp, flags, NULL, &vnops);
 		}