Annotation of wikisrc/users/mlelstv/disk-devices-layered.mdwn, revision 1.4

1.1       mlelstv     1: # Interfaces used by disk devices
                      2: 
                      3: The classical UNIX device interface
                      4: 
                      5: - implement bdevsw
                      6:   - methods
                      7:        - d_open
                      8:        - d_close
                      9:        - d_strategy
                     10:        - d_ioctl
                     11:        - d_psize
                     12:        - d_discard
                     13:   - constants
                     14:        - d_flag
                     15: - implement cdevsw
                     16:   - methods
                     17:        - d_open
                     18:        - d_close
                     19:        - d_read
                     20:        - d_write
                     21:        - d_ioctl
1.4     ! mlelstv    22:        - d_mmap
        !            23:        - d_discard
        !            24:   - other methods not used by disk drivers
1.1       mlelstv    25:        - d_stop
                     26:        - d_tty
                     27:        - d_poll
                     28:        - d_kqfilter
                     29:   - constants
                     30:        - d_flag
                     31: 
                     32: Layering is possible, the dk_lookup function is used to get
                     33: a handle (a vnode) a child device.
                     34: 
                     35: - call each other using vnode layer
                     36:   - methods
                     37:        VOP_IOCTL
                     38:        VOP_STRATEGY
                     39:   - dk_lookup to find vnode
                     40:   - vn_close to release vnode
                     41: 
                     42: 
                     43: Disk drivers use the kernel disk interface to provide information
                     44: for iostat and property lists. There are also helper routines
                     45: to handle partitions and to get a disklabel.
                     46: 
                     47: - kernel disk interface
                     48:   - kern/subr_disk.c
1.2       mlelstv    49:        - driver calls disk_init() to register
1.1       mlelstv    50:        - instrumentation (iostat)
                     51:        - DIOCGDISKINFO
                     52:        - partition support (bounds_check_..)
                     53:        - disklabel routines
                     54:        - low-level routines polluting namespace (disk_read_sectors)
1.2       mlelstv    55:        - registers a callback to strategy and minphys functions,
                     56:          currently there are only one user, dk(4) calls the minphys
                     57:          function.
1.1       mlelstv    58: 
                     59: 
1.2       mlelstv    60: Almost all disk drivers have a regular driver structure that
                     61: is created by the autoconf framework. An exception is the ccd(4)
                     62: driver that hand-crafts its private data without autoconf.
                     63: 
                     64: - autoconf device building
                     65:   - kern/subr_autoconf.c
                     66:        - generic for all device drivers, not only disk drivers
                     67:        - provides common data including a proplib dictionary
                     68:        - the dictionary is used to register unit data, for example
                     69:          a drive geometry.
                     70: 
1.1       mlelstv    71: The disklabel routines are mostly MD, the sun/sparc routines are
                     72: not in arch/* but in dev/sun/*, the i386/amd64 routines (also used
                     73: by other archs) are in kern/subr_disk_mbr.c
                     74: 
                     75: - disklabel routines
                     76:   - really MD, implement readdisklabel, writedisklabel, setdisklabel
                     77:   - kern/subr_disk_mbr.c
                     78:        - more disklabel routines, MBR, ISO9660
                     79:        - writedisklabel
                     80:   - sun/disksubr.c
                     81:        - like subr_disk_mbr.c but different for sun3/sparc/sparc64
1.3       mlelstv    82:   - arch/\*/\*/disksubr.c
1.1       mlelstv    83:        - like subr_disk_mbr.c but different
                     84: 
                     85: 
                     86: A wedge is a layered device on top of the RAW_PART of a standard
                     87: disk device. All disk drivers need to implement ioctls to manually
                     88: attach wedge devices (using dkctl(8)) and need to call dkwedge_discover
                     89: to implement autodetect
                     90: 
                     91: - wedge routines
                     92:   - dev/dkwedge/*
                     93:   - implement dk device
                     94:   - implement scan routines for various labels (MBR,BSD,GPT)
                     95:   - IOCTLs to attach dk devices
                     96:   - scan routines called by each disk driver
                     97: 
                     98: 
                     99: The attempt to refactor disk drivers by collecting common functionality.
                    100: Hardly used, the dk_lookup routine doesn't really belong here (it's
                    101: more a vnode routine).
                    102: 
                    103: - dksubr interface
                    104:   - dk_lookup helper to find vnodes
                    105:   - dk_intf switch implements common parts of
                    106:        - open
                    107:        - close
                    108:        - strategy
                    109:        - size
                    110:        - ioctl
                    111:        - dump
                    112:   - dk_getdisklabel, dk_makedisklabel. fallback routines ?.
                    113:   - used only by cgd, xbd
                    114: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb