Device layer rollup commit.
authorMatthew Dillon <dillon@dragonflybsd.org>
Wed, 19 May 2004 22:53:06 +0000 (22:53 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Wed, 19 May 2004 22:53:06 +0000 (22:53 +0000)
commite4c9c0c82658e0eca11c3e516c41021ba48b0093
tree3b8d1bfd77f543f9f241fad4bded574ea3764293
parent0af0c3d94cbb32166b14747193c1a24c466ae453
Device layer rollup commit.

* cdevsw_add() is now required.  cdevsw_add() and cdevsw_remove() may specify
  a mask/match indicating the range of supported minor numbers.  Multiple
  cdevsw_add()'s using the same major number, but distinctly different
  ranges, may be issued.  All devices that failed to call cdevsw_add() before
  now do.

* cdevsw_remove() now automatically marks all devices within its supported
  range as being destroyed.

* vnode->v_rdev is no longer resolved when the vnode is created.  Instead,
  only v_udev (a newly added field) is resolved.  v_rdev is resolved when
  the vnode is opened and cleared on the last close.

* A great deal of code was making rather dubious assumptions with regards
  to the validity of devices associated with vnodes, primarily due to
  the persistence of a device structure due to being indexed by (major, minor)
  instead of by (cdevsw, major, minor).  In particular, if you run a program
  which connects to a USB device and then you pull the USB device and plug
  it back in, the vnode subsystem will continue to believe that the device
  is open when, in fact, it isn't (because it was destroyed and recreated).

  In particular, note that all the VFS mount procedures now check devices
  via v_udev instead of v_rdev prior to calling VOP_OPEN(), since v_rdev
  is NULL prior to the first open.

* The disk layer's device interaction has been rewritten.  The disk layer
  (i.e. the slice and disklabel management layer) no longer overloads
  its data onto the device structure representing the underlying physical
  disk.  Instead, the disk layer uses the new cdevsw_add() functionality
  to register its own cdevsw using the underlying device's major number,
  and simply does NOT register the underlying device's cdevsw.  No
  confusion is created because the device hash is now based on
  (cdevsw,major,minor) rather then (major,minor).

  NOTE: This also means that underlying raw disk devices may use the entire
  device minor number instead of having to reserve the bits used by the disk
  layer, and also means that can we (theoretically) stack a fully
  disklabel-supported 'disk' on top of any block device.

* The new reference counting scheme prevents this by associating a device
  with a cdevsw and disconnecting the device from its cdevsw when the cdevsw
  is removed.  Additionally, all udev2dev() lookups run through the cdevsw
  mask/match and only successfully find devices still associated with an
  active cdevsw.

* Major work on MFS:  MFS no longer shortcuts vnode and device creation.  It
  now creates a real vnode and a real device and implements real open and
  close VOPs.  Additionally, due to the disk layer changes, MFS is no longer
  limited to 255 mounts.  The new limit is 16 million.  Since MFS creates a
  real device node, mount_mfs will now create a real /dev/mfs<PID> device
  that can be read from userland (e.g. so you can dump an MFS filesystem).

* BUF AND DEVICE STRATEGY changes.  The struct buf contains a b_dev field.
  In order to properly handle stacked devices we now require that the b_dev
  field be initialized before the device strategy routine is called.  This
  required some additional work in various VFS implementations.  To enforce
  this requirement, biodone() now sets b_dev to NODEV.  The new disk layer
  will adjust b_dev before forwarding a request to the actual physical
  device.

* A bug in the ISO CD boot sequence which resulted in a panic has been fixed.

Testing by: lots of people, but David Rhodus found the most aggregious bugs.
193 files changed:
sbin/newfs/newfs.8
sbin/newfs/newfs.c
sys/bus/cam/cam_xpt.c
sys/bus/cam/scsi/scsi_cd.c
sys/bus/cam/scsi/scsi_ch.c
sys/bus/cam/scsi/scsi_da.c
sys/bus/cam/scsi/scsi_pass.c
sys/bus/cam/scsi/scsi_pt.c
sys/bus/cam/scsi/scsi_sa.c
sys/bus/cam/scsi/scsi_ses.c
sys/bus/cam/scsi/scsi_target.c
sys/bus/firewire/firewire.h
sys/bus/firewire/fwdev.c
sys/bus/iicbus/iic.c
sys/bus/isa/vga_isa.c
sys/bus/pci/pci.c
sys/bus/smbus/smb.c
sys/bus/usb/usb.c
sys/contrib/ipfilter/netinet/mlfk_ipl.c
sys/dev/acpica/Osd/OsdSynch.c
sys/dev/acpica/acpi.c
sys/dev/acpica5/acpi.c
sys/dev/agp/agp.c
sys/dev/agp/agppriv.h
sys/dev/disk/ata/ata-all.c
sys/dev/disk/ata/ata-disk.c
sys/dev/disk/ata/ata-raid.h
sys/dev/disk/ata/atapi-cd.c
sys/dev/disk/ata/atapi-tape.c
sys/dev/disk/ata/atapi-tape.h
sys/dev/disk/ccd/ccd.c
sys/dev/disk/fd/fd.c
sys/dev/disk/isp/isp_freebsd.c
sys/dev/disk/mcd/mcd.c
sys/dev/disk/scd/scd.c
sys/dev/disk/vn/vn.c
sys/dev/disk/wt/wt.c
sys/dev/drm/drm_drv.h
sys/dev/misc/gpib/gpib.c
sys/dev/misc/joy/joy.c
sys/dev/misc/kbd/kbd.c
sys/dev/misc/labpc/labpc.c
sys/dev/misc/lpt/lpt.c
sys/dev/misc/mse/mse.c
sys/dev/misc/nmdm/nmdm.c
sys/dev/misc/pcfclock/pcfclock.c
sys/dev/misc/ppi/ppi.c
sys/dev/misc/pps/pps.c
sys/dev/misc/psm/psm.c
sys/dev/misc/snp/snp.c
sys/dev/misc/spic/spic.c
sys/dev/misc/spigot/spigot.c
sys/dev/misc/streams/streams.c
sys/dev/misc/syscons/syscons.c
sys/dev/misc/syscons/syscons.h
sys/dev/misc/syscons/sysmouse.c
sys/dev/misc/tw/tw.c
sys/dev/misc/xrpu/xrpu.c
sys/dev/netif/cx/cx.c
sys/dev/netif/cx/if_cx.c
sys/dev/raid/aac/aac.c
sys/dev/raid/aac/aac_disk.c
sys/dev/raid/amr/amr.c
sys/dev/raid/amr/amr_disk.c
sys/dev/raid/asr/asr.c
sys/dev/raid/ciss/ciss.c
sys/dev/raid/dpt/dpt_control.c
sys/dev/raid/ida/ida_disk.c
sys/dev/raid/iir/iir_ctrl.c
sys/dev/raid/ips/ips.c
sys/dev/raid/ips/ips.h
sys/dev/raid/mlx/mlx.c
sys/dev/raid/mlx/mlxvar.h
sys/dev/raid/mly/mly.c
sys/dev/raid/twa/twa.h
sys/dev/raid/twa/twa_freebsd.c
sys/dev/raid/twe/twe_compat.h
sys/dev/raid/twe/twe_freebsd.c
sys/dev/raid/vinum/vinum.c
sys/dev/raid/vinum/vinumext.h
sys/dev/raid/vinum/vinumio.c
sys/dev/raid/vinum/vinumvar.h
sys/dev/serial/cy/cy.c
sys/dev/serial/dgb/dgm.c
sys/dev/serial/rc/rc.c
sys/dev/serial/rp/rp.c
sys/dev/serial/rp/rpreg.h
sys/dev/serial/rp2/rp.c
sys/dev/serial/si/si.c
sys/dev/serial/sio/sio.c
sys/dev/serial/stl/stallion.c
sys/dev/serial/stli/istallion.c
sys/dev/sound/isa/i386/pca/pcaudio.c
sys/dev/sound/isa/i386/soundcard.c
sys/dev/sound/isa/i386/spkr/spkr.c
sys/dev/sound/pcm/dsp.c
sys/dev/sound/pcm/mixer.c
sys/dev/sound/pcm/sndstat.c
sys/dev/usbmisc/ucom/ucom.c
sys/dev/usbmisc/ufm/ufm.c
sys/dev/usbmisc/ugen/ugen.c
sys/dev/usbmisc/uhid/uhid.c
sys/dev/usbmisc/ulpt/ulpt.c
sys/dev/usbmisc/ums/ums.c
sys/dev/usbmisc/urio/urio.c
sys/dev/usbmisc/uscanner/uscanner.c
sys/dev/video/bktr/bktr_os.c
sys/dev/video/bktr/bktr_reg.h
sys/dev/video/ctx/ctx.c
sys/dev/video/fb/fb.c
sys/dev/video/fb/vgareg.h
sys/dev/video/gfb/gfb_pci.c
sys/dev/video/gsc/gsc.c
sys/dev/video/meteor/meteor.c
sys/dev/video/pcvt/i386/pcvt_drv.c
sys/dev/video/pcvt/i386/pcvt_hdr.h
sys/dev/video/pcvt/i386/pcvt_kbd.c
sys/dev/video/tga/tga_pci.c
sys/emulation/linux/linux_stats.c
sys/emulation/svr4/svr4_types.h
sys/i386/acpica/acpi_machdep.c
sys/i386/acpica5/acpi_machdep.c
sys/i386/apm/apm.c
sys/i386/gnu/isa/dgb.c
sys/i386/i386/autoconf.c
sys/i386/i386/elan-mmcr.c
sys/i386/i386/mem.c
sys/i386/i386/perfmon.c
sys/i386/isa/asc.c
sys/kern/kern_conf.c
sys/kern/kern_descrip.c
sys/kern/kern_device.c
sys/kern/kern_memio.c
sys/kern/subr_disk.c
sys/kern/subr_log.c
sys/kern/subr_xxx.c
sys/kern/tty_cons.c
sys/kern/tty_pty.c
sys/kern/tty_tty.c
sys/kern/vfs_bio.c
sys/kern/vfs_conf.c
sys/kern/vfs_default.c
sys/kern/vfs_subr.c
sys/kern/vfs_syscalls.c
sys/kern/vfs_vnops.c
sys/net/bpf.c
sys/net/i4b/driver/i4b_ctl.c
sys/net/i4b/driver/i4b_rbch.c
sys/net/i4b/driver/i4b_tel.c
sys/net/i4b/driver/i4b_trace.c
sys/net/i4b/layer4/i4b_i4bdrv.c
sys/net/tap/if_tap.c
sys/net/tun/if_tun.c
sys/netgraph/ng_device.c
sys/netproto/smb/smb_dev.c
sys/opencrypto/cryptodev.c
sys/platform/pc32/acpica/acpi_machdep.c
sys/platform/pc32/acpica5/acpi_machdep.c
sys/platform/pc32/apm/apm.c
sys/platform/pc32/gnu/isa/dgb.c
sys/platform/pc32/i386/autoconf.c
sys/platform/pc32/i386/elan-mmcr.c
sys/platform/pc32/i386/mem.c
sys/platform/pc32/i386/perfmon.c
sys/platform/pc32/isa/asc.c
sys/sys/conf.h
sys/sys/device.h
sys/sys/disk.h
sys/sys/disklabel.h
sys/sys/disklabel32.h
sys/sys/odisklabel.h
sys/sys/systm.h
sys/sys/vnode.h
sys/vfs/coda/coda_fbsd.c
sys/vfs/coda/coda_vfsops.c
sys/vfs/gnu/ext2fs/ext2_vfsops.c
sys/vfs/hpfs/hpfs_vfsops.c
sys/vfs/isofs/cd9660/cd9660_vfsops.c
sys/vfs/mfs/mfs_vfsops.c
sys/vfs/mfs/mfs_vnops.c
sys/vfs/mfs/mfsnode.h
sys/vfs/msdosfs/msdosfs_vfsops.c
sys/vfs/nfs/nfs_subs.c
sys/vfs/nfs/nfs_vfsops.c
sys/vfs/ntfs/ntfs_vfsops.c
sys/vfs/nullfs/null_subr.c
sys/vfs/specfs/spec_vnops.c
sys/vfs/udf/udf_vfsops.c
sys/vfs/ufs/ffs_softdep.c
sys/vfs/ufs/ffs_vfsops.c
sys/vfs/ufs/ffs_vnops.c
sys/vm/vm_extern.h
sys/vm/vm_swap.c