The branch main has been updated by mjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=62a573d9537c717b2d373f26ba90e4b142823466

commit 62a573d9537c717b2d373f26ba90e4b142823466
Author:     Mateusz Guzik <m...@freebsd.org>
AuthorDate: 2023-03-16 17:21:59 +0000
Commit:     Mateusz Guzik <m...@freebsd.org>
CommitDate: 2023-03-17 16:21:45 +0000

    vfs: retire KERN_VNODE
    
    It got disabled in 2003:
    
    commit acb18acfec97aa7fe26ff48f80a5c3f89c9b542d
    Author: Poul-Henning Kamp <p...@freebsd.org>
    Date:   Sun Feb 23 18:09:05 2003 +0000
    
        Bracket the kern.vnode sysctl in #ifdef notyet because it results
        in massive locking issues on diskless systems.
    
        It is also not clear that this sysctl is non-dangerous in its
        requirements for locked down memory on large RAM systems.
    
    There does not seem to be practical use for it and the disabled routine
    does not work anyway.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D39127
---
 lib/libc/gen/sysctl.3               | 11 +----
 sys/kern/kern_xxx.c                 |  9 +---
 sys/kern/vfs_subr.c                 | 97 -------------------------------------
 sys/security/audit/audit_bsm_klib.c |  1 -
 sys/sys/sysctl.h                    |  2 +-
 sys/sys/vnode.h                     | 30 ------------
 6 files changed, 3 insertions(+), 147 deletions(-)

diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index c4883e0aeb4d..4f805d45790a 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -28,7 +28,7 @@
 .\"    @(#)sysctl.3    8.4 (Berkeley) 5/9/95
 .\" $FreeBSD$
 .\"
-.Dd October 18, 2021
+.Dd March 16, 2023
 .Dt SYSCTL 3
 .Os
 .Sh NAME
@@ -354,7 +354,6 @@ information.
 .It Dv KERN_SECURELVL Ta integer Ta raise only
 .It Dv KERN_UPDATEINTERVAL Ta integer Ta no
 .It Dv KERN_VERSION Ta string Ta no
-.It Dv KERN_VNODE Ta struct xvnode Ta no
 .El
 .Bl -tag -width 6n
 .It Li KERN_ARGMAX
@@ -487,14 +486,6 @@ This level may be raised by processes with appropriate 
privilege.
 It may not be lowered.
 .It Li KERN_VERSION
 The system version string.
-.It Li KERN_VNODE
-Return the entire vnode table.
-Note, the vnode table is not necessarily a consistent snapshot of
-the system.
-The returned data consists of an array whose size depends on the
-current number of such objects in the system.
-Each element of the array consists of a
-.Va struct xvnode .
 .El
 .Ss CTL_NET
 The string and integer information available for the CTL_NET level
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index f95246f1cf38..b0026777a389 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -111,7 +111,7 @@ oquota(struct thread *td, struct oquota_args *uap)
 
 #define        KINFO_PROC              (0<<8)
 #define        KINFO_RT                (1<<8)
-#define        KINFO_VNODE             (2<<8)
+/* UNUSED, was KINFO_VNODE (2<<8) */
 #define        KINFO_FILE              (3<<8)
 #define        KINFO_METER             (4<<8)
 #define        KINFO_LOADAVG           (5<<8)
@@ -184,13 +184,6 @@ ogetkerninfo(struct thread *td, struct ogetkerninfo_args 
*uap)
                        0, 0, 0, &size, 0);
                break;
 
-       case KINFO_VNODE:
-               name[0] = CTL_KERN;
-               name[1] = KERN_VNODE;
-               error = userland_sysctl(td, name, 2, uap->where, uap->size,
-                       0, 0, 0, &size, 0);
-               break;
-
        case KINFO_PROC:
                name[0] = CTL_KERN;
                name[1] = KERN_PROC;
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 0b9d7ca9778f..c117ada017c9 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -4704,103 +4704,6 @@ sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS)
 #endif /* 1 || COMPAT_PRELITE2 */
 #endif /* !BURN_BRIDGES */
 
-#define KINFO_VNODESLOP                10
-#ifdef notyet
-/*
- * Dump vnode list (via sysctl).
- */
-/* ARGSUSED */
-static int
-sysctl_vnode(SYSCTL_HANDLER_ARGS)
-{
-       struct xvnode *xvn;
-       struct mount *mp;
-       struct vnode *vp;
-       int error, len, n;
-
-       /*
-        * Stale numvnodes access is not fatal here.
-        */
-       req->lock = 0;
-       len = (numvnodes + KINFO_VNODESLOP) * sizeof *xvn;
-       if (!req->oldptr)
-               /* Make an estimate */
-               return (SYSCTL_OUT(req, 0, len));
-
-       error = sysctl_wire_old_buffer(req, 0);
-       if (error != 0)
-               return (error);
-       xvn = malloc(len, M_TEMP, M_ZERO | M_WAITOK);
-       n = 0;
-       mtx_lock(&mountlist_mtx);
-       TAILQ_FOREACH(mp, &mountlist, mnt_list) {
-               if (vfs_busy(mp, MBF_NOWAIT | MBF_MNTLSTLOCK))
-                       continue;
-               MNT_ILOCK(mp);
-               TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) {
-                       if (n == len)
-                               break;
-                       vref(vp);
-                       xvn[n].xv_size = sizeof *xvn;
-                       xvn[n].xv_vnode = vp;
-                       xvn[n].xv_id = 0;       /* XXX compat */
-#define XV_COPY(field) xvn[n].xv_##field = vp->v_##field
-                       XV_COPY(usecount);
-                       XV_COPY(writecount);
-                       XV_COPY(holdcnt);
-                       XV_COPY(mount);
-                       XV_COPY(numoutput);
-                       XV_COPY(type);
-#undef XV_COPY
-                       xvn[n].xv_flag = vp->v_vflag;
-
-                       switch (vp->v_type) {
-                       case VREG:
-                       case VDIR:
-                       case VLNK:
-                               break;
-                       case VBLK:
-                       case VCHR:
-                               if (vp->v_rdev == NULL) {
-                                       vrele(vp);
-                                       continue;
-                               }
-                               xvn[n].xv_dev = dev2udev(vp->v_rdev);
-                               break;
-                       case VSOCK:
-                               xvn[n].xv_socket = vp->v_socket;
-                               break;
-                       case VFIFO:
-                               xvn[n].xv_fifo = vp->v_fifoinfo;
-                               break;
-                       case VNON:
-                       case VBAD:
-                       default:
-                               /* shouldn't happen? */
-                               vrele(vp);
-                               continue;
-                       }
-                       vrele(vp);
-                       ++n;
-               }
-               MNT_IUNLOCK(mp);
-               mtx_lock(&mountlist_mtx);
-               vfs_unbusy(mp);
-               if (n == len)
-                       break;
-       }
-       mtx_unlock(&mountlist_mtx);
-
-       error = SYSCTL_OUT(req, xvn, n * sizeof *xvn);
-       free(xvn, M_TEMP);
-       return (error);
-}
-
-SYSCTL_PROC(_kern, KERN_VNODE, vnode, CTLTYPE_OPAQUE | CTLFLAG_RD |
-    CTLFLAG_MPSAFE, 0, 0, sysctl_vnode, "S,xvnode",
-    "");
-#endif
-
 static void
 unmount_or_warn(struct mount *mp)
 {
diff --git a/sys/security/audit/audit_bsm_klib.c 
b/sys/security/audit/audit_bsm_klib.c
index 31a9bf29265d..9dde8362ce9c 100644
--- a/sys/security/audit/audit_bsm_klib.c
+++ b/sys/security/audit/audit_bsm_klib.c
@@ -182,7 +182,6 @@ audit_ctlname_to_sysctlevent(int name[], uint64_t valid_arg)
        case KERN_HOSTID:
        case KERN_SECURELVL:
        case KERN_HOSTNAME:
-       case KERN_VNODE:
        case KERN_PROC:
        case KERN_FILE:
        case KERN_PROF:
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 79da4772615f..9cfd759166bd 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -972,7 +972,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
 #define        KERN_HOSTNAME           10      /* string: hostname */
 #define        KERN_HOSTID             11      /* int: host identifier */
 #define        KERN_CLOCKRATE          12      /* struct: struct clockrate */
-#define        KERN_VNODE              13      /* struct: vnode structures */
+/* was: #define        KERN_VNODE      13      ; disabled in 2003 and removed 
in 2023 */
 #define        KERN_PROC               14      /* struct: process entries */
 #define        KERN_FILE               15      /* struct: file entries */
 #define        KERN_PROF               16      /* node: kernel profiling info 
*/
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 04596a7184ee..a3eb00f0fe7c 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -199,36 +199,6 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size 
crosses 448 bytes");
 /* XXX: These are temporary to avoid a source sweep at this time */
 #define v_object       v_bufobj.bo_object
 
-/*
- * Userland version of struct vnode, for sysctl.
- */
-struct xvnode {
-       size_t  xv_size;                        /* sizeof(struct xvnode) */
-       void    *xv_vnode;                      /* address of real vnode */
-       u_long  xv_flag;                        /* vnode vflags */
-       int     xv_usecount;                    /* reference count of users */
-       int     xv_writecount;                  /* reference count of writers */
-       int     xv_holdcnt;                     /* page & buffer references */
-       u_long  xv_id;                          /* capability identifier */
-       void    *xv_mount;                      /* address of parent mount */
-       long    xv_numoutput;                   /* num of writes in progress */
-       enum    vtype xv_type;                  /* vnode type */
-       union {
-               void    *xvu_socket;            /* unpcb, if VSOCK */
-               void    *xvu_fifo;              /* fifo, if VFIFO */
-               dev_t   xvu_rdev;               /* maj/min, if VBLK/VCHR */
-               struct {
-                       dev_t   xvu_dev;        /* device, if VDIR/VREG/VLNK */
-                       ino_t   xvu_ino;        /* id, if VDIR/VREG/VLNK */
-               } xv_uns;
-       } xv_un;
-};
-#define xv_socket      xv_un.xvu_socket
-#define xv_fifo                xv_un.xvu_fifo
-#define xv_rdev                xv_un.xvu_rdev
-#define xv_dev         xv_un.xv_uns.xvu_dev
-#define xv_ino         xv_un.xv_uns.xvu_ino
-
 /* We don't need to lock the knlist */
 #define        VN_KNLIST_EMPTY(vp) ((vp)->v_pollinfo == NULL ||        \
            KNLIST_EMPTY(&(vp)->v_pollinfo->vpi_selinfo.si_note))

Reply via email to