freebsd-nq/sys
Poul-Henning Kamp e606a3c63e Rewamp DEVFS internals pretty severely [1].
Give DEVFS a proper inode called struct cdev_priv.  It is important
to keep in mind that this "inode" is shared between all DEVFS
mountpoints, therefore it is protected by the global device mutex.

Link the cdev_priv's into a list, protected by the global device
mutex.  Keep track of each cdev_priv's state with a flag bit and
of references from mountpoints with a dedicated usecount.

Reap the benefits of much improved kernel memory allocator and the
generally better defined device driver APIs to get rid of the tables
of pointers + serial numbers, their overflow tables,  the atomics
to muck about in them and all the trouble that resulted in.

This makes RAM the only limit on how many devices we can have.

The cdev_priv is actually a super struct containing the normal cdev
as the "public" part, and therefore allocation and freeing has moved
to devfs_devs.c from kern_conf.c.

The overall responsibility is (to be) split such that kern/kern_conf.c
is the stuff that deals with drivers and struct cdev and fs/devfs
handles filesystems and struct cdev_priv and their private liason
exposed only in devfs_int.h.

Move the inode number from cdev to cdev_priv and allocate inode
numbers properly with unr.  Local dirents in the mountpoints
(directories, symlinks) allocate inodes from the same pool to
guarantee against overlaps.

Various other fields are going to migrate from cdev to cdev_priv
in the future in order to hide them.  A few fields may migrate
from devfs_dirent to cdev_priv as well.

Protect the DEVFS mountpoint with an sx lock instead of lockmgr,
this lock also protects the directory tree of the mountpoint.

Give each mountpoint a unique integer index, allocated with unr.
Use it into an array of devfs_dirent pointers in each cdev_priv.
Initially the array points to a single element also inside cdev_priv,
but as more devfs instances are mounted, the array is extended with
malloc(9) as necessary when the filesystem populates its directory
tree.

Retire the cdev alias lists, the cdev_priv now know about all the
relevant devfs_dirents (and their vnodes) and devfs_revoke() will
pick them up from there.  We still spelunk into other mountpoints
and fondle their data without 100% good locking.  It may make better
sense to vector the revoke event into the tty code and there do a
destroy_dev/make_dev on the tty's devices, but that's for further
study.

Lots of shuffling of stuff and churn of bits for no good reason[2].

XXX: There is still nothing preventing the dev_clone EVENTHANDLER
from being invoked at the same time in two devfs mountpoints.  It
is not obvious what the best course of action is here.

XXX: comment out an if statement that lost its body, until I can
find out what should go there so it doesn't do damage in the meantime.

XXX: Leave in a few extra malloc types and KASSERTS to help track
down any remaining issues.

Much testing provided by:		Kris
Much confusion caused by (races in):	md(4)

[1] You are not supposed to understand anything past this point.

[2] This line should simplify life for the peanut gallery.
2005-09-19 19:56:48 +00:00
..
alpha Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
amd64 Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
arm Move the prototypes of db_md_set_watchpoint(), db_md_clr_watchpoint() 2005-09-10 03:01:25 +00:00
boot Remove EPSON PC-386 note A/W/AE/WR support. 2005-09-14 12:39:06 +00:00
bsm For consistency with more system include files, add a trailing '_' to 2005-05-29 16:11:34 +00:00
cam Make the exploring of all luns supported by an HBA more of a 2005-09-16 01:26:17 +00:00
coda Merge the dev_clone and dev_clone_cred event handlers into a single 2005-08-08 19:55:32 +00:00
compat Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
conf Fix genassym.o dependencies. 2005-09-19 15:13:33 +00:00
contrib Fix "struct ifnet" leak if attach() fails in the middle. 2005-09-16 12:49:06 +00:00
crypto Add VIA/ACE "PadLock" support as a crypto(9) driver. 2005-08-18 00:30:22 +00:00
ddb Move the prototypes of db_md_set_watchpoint(), db_md_clr_watchpoint() 2005-09-10 03:01:25 +00:00
dev Use phk's kernel unit number allocator to associate unique ids to neighbors 2005-09-19 18:59:04 +00:00
doc
fs Rewamp DEVFS internals pretty severely [1]. 2005-09-19 19:56:48 +00:00
gdb check return value of gdb_rx_varhex 2005-03-28 18:31:18 +00:00
geom o Don't cause a panic when the control request lacks a verb. 2005-09-18 23:54:40 +00:00
gnu Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
i4b Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
i386 Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
ia64 Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
isa Add pnp and location info for the ISA bus. The pnp info is the 2005-08-01 07:03:10 +00:00
isofs/cd9660 - restore the ability to mount cd9660 filesystems as root by inverting 2005-08-14 04:19:36 +00:00
kern Rewamp DEVFS internals pretty severely [1]. 2005-09-19 19:56:48 +00:00
libkern - Fix checking range of strings of struct iconv_add_in in libsmb and libkiconv, 2005-08-24 12:38:26 +00:00
modules Fix the module build for snp(4). 2005-09-19 10:14:05 +00:00
net Drop current rtentry lock before calling rt_getifa(). This fixes a LOR 2005-09-19 16:27:22 +00:00
net80211 Properly set ic_curchan before calling back to device driver to do channel 2005-08-30 14:27:47 +00:00
netatalk Forward declare atalkdomain with static linkage, not extern, since 2005-09-11 16:04:56 +00:00
netatm Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and 2005-08-09 10:20:02 +00:00
netgraph Dej'a vu of revision 1.35 2005-09-19 11:49:54 +00:00
netinet Take a first cut at cleaning up ifnet removal and multicast socket 2005-09-18 17:36:28 +00:00
netinet6 plugged a possible memory leak 2005-09-16 01:42:50 +00:00
netipsec Correct typo in a comment describing vshiftl(). 2005-06-02 23:56:10 +00:00
netipx Forward declaring static variables as extern is invalid ISO-C. Now that 2005-09-07 10:06:14 +00:00
netkey SADB_UPDATE did not return an error when key length is invalid. 2005-08-22 07:05:14 +00:00
netnatm Forward declaring static variables as extern is invalid ISO-C. Now that 2005-09-07 10:06:14 +00:00
netncp Change API of mb_copy_t in libmchain so that netsmb can handle 2005-07-29 13:22:37 +00:00
netsmb Merge the dev_clone and dev_clone_cred event handlers into a single 2005-08-08 19:55:32 +00:00
nfs Fixes for NFS crashes on architectures that require strict alignment. 2005-07-14 20:08:27 +00:00
nfs4client - We want if (mrep != NULL) not if (m_freem != NULL). m_freem will never 2005-04-25 05:11:19 +00:00
nfsclient Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
nfsserver NFS write gathering defers execution of NFS server write requests to wait 2005-04-17 16:25:36 +00:00
opencrypto Fix bogus check. It was possible to panic the kernel by giving 0 length. 2005-08-18 11:58:03 +00:00
pc98 Introduce a kernel config for the Mandatory Access Control framework. 2005-09-18 03:15:36 +00:00
pccard Change a directory layout for pc98. 2005-05-10 12:02:18 +00:00
pci Add a new AGP driver for ATI IGP chipsets. The driver is based on reading of 2005-09-17 03:36:47 +00:00
posix4 Introduce MAC Framework and MAC Policy entry points to label and control 2005-05-04 10:39:15 +00:00
powerpc Introduce a kernel config for the Mandatory Access Control framework. 2005-09-18 03:15:36 +00:00
rpc Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
security Add #include <sys/sx.h>, devfs is going to require this shortly. 2005-09-19 18:52:51 +00:00
sparc64 Introduce a kernel config for the Mandatory Access Control framework. 2005-09-18 03:15:36 +00:00
sys Rewamp DEVFS internals pretty severely [1]. 2005-09-19 19:56:48 +00:00
tools Allow EVFILT_VNODE events to work on every filesystem type, not just 2005-06-09 20:20:31 +00:00
ufs Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(), 2005-09-19 16:51:43 +00:00
vm Introduce a new lock for the purpose of synchronizing access to the 2005-09-09 06:03:08 +00:00
Makefile When building cscopnamefile, default architecture to ${MACHINE}, not i386. 2005-03-08 00:09:41 +00:00