summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMartin Natano <natano@cvs.openbsd.org>2016-04-05 19:26:16 +0000
committerMartin Natano <natano@cvs.openbsd.org>2016-04-05 19:26:16 +0000
commite0990bcfecaebb108e8932c737deb1429a10f906 (patch)
tree179934b2d74d28d8ec65c0c46ba84d48b350f484 /sys/kern
parenta4fe4239a973554f58c98f2dd3bb4c305c535cba (diff)
Increase size of the clone bitmap (revised diff after revert). I have
tested this with fuse _and_ drm on amd64 and macppc. Also tested with cloning bpf (not in the tree) on macppc. ok mikeb "looks correct to me" millert The original commit message is as follows: Increase size of the clone bitmap. A limit of only 64 device clones turned out to be too low for the upcoming work on cloning bpf. The new limit is 1024 device clones. As part of the size increase, the bitmap has been changed to be allocated separately to avoid bloating all device nodes, as suggested by guenther, millert and deraadt. ok millert mikeb
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/spec_vnops.c6
-rw-r--r--sys/kern/vfs_subr.c15
2 files changed, 16 insertions, 5 deletions
diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c
index c8754e7a80b..b2e104fc28e 100644
--- a/sys/kern/spec_vnops.c
+++ b/sys/kern/spec_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spec_vnops.c,v 1.88 2016/04/01 11:51:55 mikeb Exp $ */
+/* $OpenBSD: spec_vnops.c,v 1.89 2016/04/05 19:26:15 natano Exp $ */
/* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */
/*
@@ -707,13 +707,13 @@ spec_open_clone(struct vop_open_args *ap)
if (minor(vp->v_rdev) >= (1 << CLONE_SHIFT))
return (ENXIO);
- for (i = 1; i < sizeof(vp->v_specbitmap) * NBBY; i++)
+ for (i = 1; i < CLONE_MAPSZ * NBBY; i++)
if (isclr(vp->v_specbitmap, i)) {
setbit(vp->v_specbitmap, i);
break;
}
- if (i == sizeof(vp->v_specbitmap) * NBBY)
+ if (i == CLONE_MAPSZ * NBBY)
return (EBUSY); /* too many open instances */
error = cdevvp(makedev(major(vp->v_rdev),
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 629429b7e72..38b0f520572 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.242 2016/04/01 11:51:55 mikeb Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.243 2016/04/05 19:26:15 natano Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -555,7 +555,13 @@ loop:
nvp->v_specnext = *vpp;
nvp->v_specmountpoint = NULL;
nvp->v_speclockf = NULL;
- memset(nvp->v_specbitmap, 0, sizeof(nvp->v_specbitmap));
+ nvp->v_specbitmap = NULL;
+ if (nvp->v_type == VCHR &&
+ (cdevsw[major(nvp_rdev)].d_flags & D_CLONE) &&
+ (minor(nvp_rdev) >> CLONE_SHIFT == 0)) {
+ nvp->v_specbitmap = malloc(CLONE_MAPSZ, M_VNODE,
+ M_WAITOK | M_ZERO);
+ }
*vpp = nvp;
if (vp != NULLVP) {
nvp->v_flag |= VALIASED;
@@ -1093,6 +1099,11 @@ vgonel(struct vnode *vp, struct proc *p)
vx->v_flag &= ~VALIASED;
vp->v_flag &= ~VALIASED;
}
+ if (vp->v_type == VCHR &&
+ (cdevsw[major(vp->v_rdev)].d_flags & D_CLONE) &&
+ (minor(vp->v_rdev) >> CLONE_SHIFT == 0)) {
+ free(vp->v_specbitmap, M_VNODE, CLONE_MAPSZ);
+ }
free(vp->v_specinfo, M_VNODE, sizeof(struct specinfo));
vp->v_specinfo = NULL;
}