RFC: backporting GEOM to the 4.x branch

Matthew Dillon dillon at apollo.backplane.com
Fri Feb 4 11:30:18 PST 2005


:I know you have other more important priorities, I did not expect you to port
:it instead of me. :-) Is someone already working on such a utility?
:
:>     The current BUF/BIO model is very close to FreeBSD-4.  We haven't done any
:>     of the truely major bits of work on it yet (like changing the block
:>     numbers to 64 bit byte offsets and things of that ilk).
:
:What other major changes that would affect what I would like to implement are
:planned? Anything else I should anticipate?
:
:>     The only big difference relative to FreeBSD-4 is that the actual I/O
:>     sequencing has changed slightly, and the device representing a labeled
:>     disk is no longer overloaded onto the device reprsenting a 'raw' disk.
:
:That would indeed make it easier to implement dGDE, I'll take a closer look
:and study the code.
:
:ALeine

    We've made a lot of little mods here and there, I don't remember them
    all, but the only one that really counts is the new layering, and
    that is mostly hidden by disk_create().

    Check out any of the disk drivers.  so e.g. look at ata-disk.c in
    /usr/src/sys/dev/disk/ata/.  It does this (where 'adp' is basically
    just the softinfo for the driver):

    dev = disk_create(adp->lun, &adp->disk, 0, &ad_cdevsw);
    dev->si_drv1 = adp;
    dev->si_iosize_max = 256 * DEV_BSIZE;
    adp->dev = dev;

    /* construct the disklabel */
    bzero(&adp->disk.d_label, sizeof(struct disklabel));
    adp->disk.d_label.d_secsize = DEV_BSIZE;
    adp->disk.d_label.d_nsectors = adp->sectors;
    adp->disk.d_label.d_ntracks = adp->heads;
    adp->disk.d_label.d_ncylinders = adp->total_secs/(adp->heads*adp->sectors);
    adp->disk.d_label.d_secpercyl = adp->sectors * adp->heads;
    adp->disk.d_label.d_secperunit = adp->total_secs;

    There are a couple of differences between the FreeBSD-5 way and 
    our way.

    * We embed the disk structure in the softstruct rather then call 
      disk_alloc().

    * Second, the disk device is not embedded in the disk structure but
      instead returned by disk_create(), and the cdevsw template ias
      passed to disk_create().

    * We still have major/minor numbers, and will continue to have them
      for some time to come.  Look in ata-disk.c for typical setup of
      the cdevsw structure.  The cdevsw is a major number template.
      The first argument to disk_create() is the unit number.

    After that its almost the same.  The returned 'dev' is purely for the
    use of the block device.  disk_create() will create a *DIFFERENT* dev
    *internally* that is attached to the userland-accessible major,minor
    number.  The block device never touches the internal dev.  So the driver
    just uses the returned dev as the block device, and userland will wind
    up using a different dev created by disk_create() which will do the
    appropriate translation and label management.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list