tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

new shutdown order



I have made NetBSD detach devices at shutdown.  I have also started
to finish or repair the driver hooks that let us detach and re-attach
drivers while the system is running.  These changes are in support of
the goals that I describe below.  There are a few things that you can do
to help; I have described those, too.

Detaching devices at shutdown is one step toward two broad goals:

1 Restore devices to their condition before NetBSD attached them, or
  else as close as possible to that condition, so that the system BIOS
  can take over their control from NetBSD without a hitch.  Detaching
  a device is the most sensible way to restore a device to initial
  conditions.

2 Tear down stacks of devices and filesystems in an orderly fashion
  during shutdown. raid(4) pseudo-devices can stack on top of each
  other and on top of other disk devices, including vnd(4). vnd(4)
  can be "sandwiched" between two filesystems. ccd(4) and cgd(4)
  can overlay any block device.  I aim to flush outstanding writes
  to nonvolatile storage through an arbitrary stack of filesystems
  and block devices, meanwhile disassembling the stack, using the
  general-purpose algorithm:

        1 Try to "gently" unmount all filesystems.

        2 Try to detach all devices and pseudo-devices.

        3 If step 1 or step 2 detached any device or filesystem, goto
          step 1.  Otherwise, continue.

        4 Try to forcefully unmount a filesystem.

        5 Try to detach all devices and pseudo-devices.

        6 If step 4 or step 5 detached any device or filesystem, goto
          step 4.  Otherwise, end.

I have started to fix drivers that cannot detach themselves or re-attach
their children.  In doing so, I hope to

1 make device detachment at shutdown work, :-)

2 let the operator detach a driver, unload and reload its kernel module,
  and then re-attach the driver to its device,

3 support the wholesale reconfiguration of a system's PCI buses.  (More
  on that goal at some later time.)

Here are some ways to contribute to this on-going work:

1 Write and test detach hooks for the disk pseudo-devices: ccd(4),
  cgd(4), raid(4), vnd(4), et cetera.

2 Add DVF_DETACH_SHUTDOWN to the CFATTACH_DECL()s if you know that it is
  safe to detach it at shutdown.

3 Make more drivers (safely) detachable.  Some drivers lack detach
  hooks, or else detaching the driver remains problematic.

  * Drivers for PCI IDE controllers, such as piixide(4), are
    not detachable: one reason why is that drivers do not
    provide a "chip_unmap" counterpart to "chip_map" in struct
    pciide_product_desc.

  Andrew Doran has detected a lot of problems with device detachment
  already:

  * Interrupt and timecounter disestablishment have problems especially
    on SMP and non-x86 systems:

        http://mail-index.netbsd.org/port-i386/2009/04/19/msg001326.html
        http://mail-index.netbsd.org/source-changes-d/2009/04/08/msg000250.html

  * Detach hooks for PCI USB controllers have worrisome XXX comments,

        http://mail-index.netbsd.org/source-changes/2009/04/19/msg220094.html

  * pcppi(4) detachment is racy:

        http://mail-index.netbsd.org/source-changes-d/2009/04/08/msg000243.html

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933


Home | Main Index | Thread Index | Old Index