how to do asynchrounous I/O at the device level?

From: Daniel Ellard (ellard_at_eecs.harvard.edu)
Date: 05/29/03

  • Next message: Alexander Langer: "loader tunables for modules"
    Date: Thu, 29 May 2003 08:36:55 -0400 (EDT)
    To: freebsd-fs@freebsd.org, freebsd-hackers@freebsd.org
    
    

    I'm not sure if this a question for fs or hackers, so I apologize if
    you see this twice.

    I'm writing a device driver for a "soft-mirrored" disk. The idea is
    similar to ordinary disk mirroring, except that the focus is entirely
    on higher performance instead of fault tolerance -- the secondary disk
    need not be an exact duplicate of the first. (I have a method for
    keeping track of which blocks on the secondary are actually in sync
    with the primary, and which might contain stale data.)

    What I want to do is an ordinary write to the primary disk and an
    asynchronous write to the secondary, so that it is possible that the
    calling process can continue on its way before the writes are actually
    finished on the secondary.

    I've implemented my scheme with synchronous mirror writes by hacking
    up the CCD driver. (This wasn't a big deal, because CCD already
    implements disk mirroring, but because I'm also futzing around with a
    bunch of other stuff, the resulting code is structured a bit
    differently.) Now I want to make the secondary writes asynchronous.

    The challenge is that I need to make copies of whatever state the
    device underneath CCD needs in order to do the I/Os. As soon as the
    primary writes are finished, the file system is going to deallocate or
    reuse the structures it passed down to CCD. I can't hack the file
    system code to delay this, because I need to hide all this inside the
    device driver.

    I know I need to copy the buffer, and clone the buf struct. My
    questions are:

    1. How to properly clone the buf struct to make a "standalone" buf.

            Just bcopy'ing it will result in it being filled with pointers
            linking it to the rest of the buffer pool, which I suspect
            will lead to horrible problems later -- I'm pretty sure that I
            don't want the buffer manager to know about this buf, or this
            buf to believe it's part of the buffer pool.

    2. Whether there's any other state that I need to preserve.

    If this sort of thing has already been implemented somewhere, just
    point me to it...

    Thanks,
            -Dan

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Alexander Langer: "loader tunables for modules"

    Relevant Pages

    • Re: [RFD] What error should FS return when I/O failure occurs?
      ... and device driver instantly (well.. ... because the file system was R/O before we even tried to talk to the actual ... If the disk disappeared out from under us because it was an unplugged USB ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [RFD] What error should FS return when I/O failure occurs?
      ... > J> This is basically the problem people have had with removable storage for ... > find USB device driver detecting your cable-unplug as soon as you ... did have the capability to detect floppy disk presence. ...
      (Linux-Kernel)
    • Re: InternetDisk for DOS ;)
      ... >(In dos since the windows version has bad sound, and my dos computer has a ... >The bootdisk would contain a device driver. ... >Instead of using RAM to simulate a disk, the device driver would use udp/ip ... They have a small boot ROM (equivalent to your DOS boot disk) which ...
      (comp.lang.asm.x86)
    • Re: Path to current kernels image file on disk?
      ... >> Path to current kernel's image file on disk? ... Brian Catlin, Sannas Consulting 310-944-9492 ... Windows Network, Video, WDM Device Driver Training & Consulting ...
      (microsoft.public.development.device.drivers)
    • Re: Problems with ccd on -cur [i386]
      ... I have two identical 400 GB disks and I am trying to combine them with ccd. ... But if I run disklabel -r -v ccd0 I get these Error: ... Afiak needs ccd a disklabel as a normal disk. ... total sectors: 1562803200 ...
      (comp.unix.bsd.openbsd.misc)