From: Alex Hornung Date: Tue, 1 Sep 2009 06:55:15 +0000 (+0100) Subject: Use pseudo-device to specify number of precreated devs X-Git-Url: https://gitweb.dragonflybsd.org/~polachok/dragonfly.git/commitdiff_plain/95db3aac46e4848403464168e363dfc738549735 Use pseudo-device to specify number of precreated devs * use pseudo-device in the kernel config to specify the number of devices to precreate () for snp, tun, vn, bpf. * The full rationale (for vn, snp, bpf and tun) is: - if NO pseudo-device foo is specified, 4 devices will be precreated. - if pseudo-device foo is specified, 4 devices will be precreated. - if pseudo-device foo N, where N > 1 is specified, N devices will be precreated. --- diff --git a/sys/dev/disk/vn/vn.c b/sys/dev/disk/vn/vn.c index d10312d9ed..a751fad339 100644 --- a/sys/dev/disk/vn/vn.c +++ b/sys/dev/disk/vn/vn.c @@ -57,6 +57,7 @@ * NOTE 2: Doesn't interact with leases, should it? */ +#include "use_vn.h" #include #include #include @@ -93,7 +94,12 @@ static d_strategy_t vnstrategy; static d_clone_t vnclone; DEVFS_DECLARE_CLONE_BITMAP(vn); + +#if NVN <= 1 #define VN_PREALLOCATED_UNITS 4 +#else +#define VN_PREALLOCATED_UNITS NVN +#endif #define CDEV_MAJOR 43 diff --git a/sys/dev/misc/snp/snp.c b/sys/dev/misc/snp/snp.c index f33b502292..c9e798728b 100644 --- a/sys/dev/misc/snp/snp.c +++ b/sys/dev/misc/snp/snp.c @@ -16,6 +16,7 @@ * $DragonFly: src/sys/dev/misc/snp/snp.c,v 1.19 2007/05/08 02:31:41 dillon Exp $ */ +#include "use_snp.h" #include #include #include @@ -41,7 +42,12 @@ static d_ioctl_t snpioctl; static d_poll_t snppoll; static d_clone_t snpclone; DEVFS_DECLARE_CLONE_BITMAP(snp); + +#if NSNP <= 1 #define SNP_PREALLOCATED_UNITS 4 +#else +#define SNP_PREALLOCATED_UNITS NSNP +#endif #define CDEV_MAJOR 53 static struct dev_ops snp_ops = { diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 97cad23e99..b85999bbff 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -85,7 +85,12 @@ struct netmsg_bpf_output { MALLOC_DEFINE(M_BPF, "BPF", "BPF data"); DEVFS_DECLARE_CLONE_BITMAP(bpf); + +#if NBPF <= 1 #define BPF_PREALLOCATED_UNITS 4 +#else +#define BPF_PREALLOCATED_UNITS NBPF +#endif #if NBPF > 0 diff --git a/sys/net/tun/if_tun.c b/sys/net/tun/if_tun.c index e7d6b78533..91d55c0efe 100644 --- a/sys/net/tun/if_tun.c +++ b/sys/net/tun/if_tun.c @@ -17,6 +17,7 @@ * $DragonFly: src/sys/net/tun/if_tun.c,v 1.37 2008/06/05 18:06:32 swildner Exp $ */ +#include "use_tun.h" #include "opt_atalk.h" #include "opt_inet.h" #include "opt_inet6.h" @@ -85,7 +86,12 @@ static d_poll_t tunpoll; static d_clone_t tunclone; DEVFS_DECLARE_CLONE_BITMAP(tun); + +#if NTUN <= 1 #define TUN_PREALLOCATED_UNITS 4 +#else +#define TUN_PREALLOCATED_UNITS NTUN +#endif #define CDEV_MAJOR 52 static struct dev_ops tun_ops = {