cvs commit: src/sys/sys conf.h src/sys/kern kern_conf.c
src/sys/fs/devfs devfs.h devfs_devs.c devfs_int.h devfs_rule.c
phk at FreeBSD.org
Mon Sep 19 12:56:49 PDT 2005
phk 2005-09-19 19:56:48 UTC
FreeBSD src repository
sys/fs/devfs devfs.h devfs_devs.c devfs_int.h
devfs_rule.c devfs_vfsops.c devfs_vnops.c
Rewamp DEVFS internals pretty severely .
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
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
Lots of shuffling of stuff and churn of bits for no good reason.
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)
 You are not supposed to understand anything past this point.
 This line should simplify life for the peanut gallery.
Revision Changes Path
1.27 +9 -33 src/sys/fs/devfs/devfs.h
1.44 +289 -253 src/sys/fs/devfs/devfs_devs.c
1.2 +22 -0 src/sys/fs/devfs/devfs_int.h
1.19 +11 -12 src/sys/fs/devfs/devfs_rule.c
1.47 +25 -33 src/sys/fs/devfs/devfs_vfsops.c
1.126 +79 -113 src/sys/fs/devfs/devfs_vnops.c
1.193 +27 -39 src/sys/kern/kern_conf.c
1.228 +1 -2 src/sys/sys/conf.h
More information about the cvs-src