Ignore the statically configured vfs type numbers and assign vfs

type numbers in vfs attach order (modulo incomplete reuse of old
numbers after vfs LKMs are unloaded).  This requires reinitializing
the sysctl tree (or at least the vfs subtree) for vfs's that support
sysctls (currently only nfs).  sysctl_order() already handled
reinitialization reasonably except it checked for annulled self
references in the wrong place.

Fixed sysctls for vfs LKMs.
This commit is contained in:
Bruce Evans 1998-09-05 17:13:28 +00:00
parent 5f8d88ddd6
commit e99ea9ec2b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=38869
6 changed files with 73 additions and 25 deletions

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_lkm.c,v 1.53 1998/08/10 14:27:34 bde Exp $
* $Id: kern_lkm.c,v 1.54 1998/08/15 22:42:20 bde Exp $
*/
#include "opt_devfs.h"
@ -44,6 +44,7 @@
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/exec.h>
#include <sys/lkm.h>
@ -78,6 +79,16 @@ static int lkm_state = LKMS_IDLE;
static struct lkm_table lkmods[MAXLKMS]; /* table of loaded modules */
static struct lkm_table *curp; /* global for in-progress ops */
/*
* XXX this bloat just exands the sysctl__vfs linker set a little so that
* we can attach sysctls for VFS LKMs without expanding the linker set.
* Currently (1998/09/06), only one VFS uses sysctls, so 2 extra linker
* set slots are more than sufficient.
*/
extern struct linker_set sysctl__vfs;
SYSCTL_INT(_vfs, OID_AUTO, lkm0, CTLFLAG_RD, &lkm_v, 0, "");
SYSCTL_INT(_vfs, OID_AUTO, lkm1, CTLFLAG_RD, &lkm_v, 0, "");
static int _lkm_dev __P((struct lkm_table *lkmtp, int cmd));
static int _lkm_exec __P((struct lkm_table *lkmtp, int cmd));
static int _lkm_vfs __P((struct lkm_table *lkmtp, int cmd));
@ -600,6 +611,8 @@ _lkm_vfs(lkmtp, cmd)
int cmd;
{
struct lkm_vfs *args = lkmtp->private.lkm_vfs;
struct linker_set *l;
struct sysctl_oid **oidpp;
struct vfsconf *vfc = args->lkm_vfsconf;
struct vfsconf *vfsp, *prev_vfsp;
int i, maxtypenum;
@ -617,14 +630,21 @@ _lkm_vfs(lkmtp, cmd)
}
}
i = args->lkm_offset = vfc->vfc_typenum;
if (i < 0) {
i = maxvfsconf;
args->lkm_offset = vfc->vfc_typenum = maxvfsconf++;
if (vfc->vfc_vfsops->vfs_oid != NULL) {
l = &sysctl__vfs;
for (i = l->ls_length,
oidpp = (struct sysctl_oid **)l->ls_items;
i--; oidpp++) {
if (!*oidpp || *oidpp == &sysctl___vfs_lkm0 ||
*oidpp == &sysctl___vfs_lkm1) {
*oidpp = vfc->vfc_vfsops->vfs_oid;
(*oidpp)->oid_number = vfc->vfc_typenum;
sysctl_order_all();
break;
}
}
}
args->lkm_offset = vfc->vfc_typenum = i;
if (maxvfsconf <= i)
maxvfsconf = i + 1;
vfsp->vfc_next = vfc;
vfc->vfc_next = NULL;
@ -665,6 +685,19 @@ _lkm_vfs(lkmtp, cmd)
prev_vfsp->vfc_next = vfsp->vfc_next;
if (vfsp->vfc_vfsops->vfs_oid != NULL) {
l = &sysctl__vfs;
for (i = l->ls_length,
oidpp = (struct sysctl_oid **)l->ls_items;
i--; oidpp++) {
if (*oidpp == vfsp->vfc_vfsops->vfs_oid) {
*oidpp = NULL;
sysctl_order_all();
break;
}
}
}
/*
* Maintain maxvfsconf.
*/

View File

@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
* $Id: kern_sysctl.c,v 1.75 1998/08/24 08:39:38 dfr Exp $
* $Id: kern_sysctl.c,v 1.76 1998/09/05 14:30:10 bde Exp $
*/
#include "opt_compat.h"
@ -100,11 +100,13 @@ sysctl_order(void *arg)
j = l->ls_length;
oidpp = (struct sysctl_oid **) l->ls_items;
for (k = 0; j--; oidpp++) {
if (!*oidpp)
continue;
if ((*oidpp)->oid_arg1 == arg) {
*oidpp = 0;
continue;
}
if (*oidpp && (*oidpp)->oid_number > k)
if ((*oidpp)->oid_number > k)
k = (*oidpp)->oid_number;
}
@ -132,6 +134,12 @@ sysctl_order(void *arg)
SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_order, &sysctl_);
void
sysctl_order_all(void)
{
sysctl_order(&sysctl_);
}
/*
* "Staff-functions"
*

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_init.c 8.3 (Berkeley) 1/4/94
* $Id: vfs_init.c,v 1.31 1997/10/26 20:26:33 phk Exp $
* $Id: vfs_init.c,v 1.32 1998/02/09 06:09:33 eivind Exp $
*/
@ -44,6 +44,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/vnode.h>
#include <sys/malloc.h>
#include <vm/vm_zone.h>
@ -228,7 +229,7 @@ static void
vfsinit(dummy)
void *dummy;
{
struct vfsconf **vfc;
struct vfsconf **vfc, *vfsp;
int maxtypenum;
namei_zone = zinit("NAMEI", MAXPATHLEN, 0, 0, 2);
@ -252,14 +253,15 @@ vfsinit(dummy)
vattr_null(&va_null);
maxtypenum = 0;
vfc = (struct vfsconf **)vfs_set.ls_items;
vfsconf = *vfc; /* simulate Lite2 vfsconf array */
while (*vfc) {
struct vfsconf *vfsp = *vfc;
vfc++;
vfsp->vfc_next = *vfc;
if (maxtypenum <= vfsp->vfc_typenum)
maxtypenum = vfsp->vfc_typenum + 1;
vfsconf = *vfc;
for (; *vfc != NULL; maxtypenum++, vfc++) {
vfsp = *vfc;
vfsp->vfc_next = *(vfc + 1);
vfsp->vfc_typenum = maxtypenum;
if (vfsp->vfc_vfsops->vfs_oid != NULL) {
vfsp->vfc_vfsops->vfs_oid->oid_number = maxtypenum;
sysctl_order_all();
}
(*vfsp->vfc_vfsops->vfs_init)(vfsp);
}
/* next vfc_typenum to be used */

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
* $Id: nfs_vfsops.c,v 1.72 1998/06/07 17:12:30 dfr Exp $
* $Id: nfs_vfsops.c,v 1.73 1998/08/12 20:17:42 bde Exp $
*/
#include <sys/param.h>
@ -131,7 +131,9 @@ static struct vfsops nfs_vfsops = {
nfs_vget,
nfs_fhtovp,
nfs_vptofh,
nfs_init
nfs_init,
0,
&sysctl___vfs_nfs
};
VFS_SET(nfs_vfsops, nfs, MOUNT_NFS, VFCF_NETWORK);

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
* $Id: nfs_vfsops.c,v 1.72 1998/06/07 17:12:30 dfr Exp $
* $Id: nfs_vfsops.c,v 1.73 1998/08/12 20:17:42 bde Exp $
*/
#include <sys/param.h>
@ -131,7 +131,9 @@ static struct vfsops nfs_vfsops = {
nfs_vget,
nfs_fhtovp,
nfs_vptofh,
nfs_init
nfs_init,
0,
&sysctl___vfs_nfs
};
VFS_SET(nfs_vfsops, nfs, MOUNT_NFS, VFCF_NETWORK);

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
* $Id: sysctl.h,v 1.63 1998/09/05 12:42:56 bde Exp $
* $Id: sysctl.h,v 1.64 1998/09/05 14:13:35 bde Exp $
*/
#ifndef _SYS_SYSCTL_H_
@ -463,6 +463,7 @@ extern char ostype[];
int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old,
size_t *oldlenp, void *new, size_t newlen,
size_t *retval);
void sysctl_order_all(void);
int userland_sysctl(struct proc *p, int *name, u_int namelen, void *old,
size_t *oldlenp, int inkernel, void *new, size_t newlen,
size_t *retval);