HomeFreeBSD

nvme: use config_intrhook_drain to avoid removable card races

Description

nvme: use config_intrhook_drain to avoid removable card races

nvme drives are configured early in boot. However, a number of the configuration
steps takes which take a while, so we defer those to a config intrhook that runs
before the root filesystem is mounted. At the same time, the PCI hot plug wakes
up and tests the status of the card. It may decide that the card has gone away
and deletes the child. As part of that process nvme_detach is called. If this
call happens after the config_intrhook starts to run, but before it is finished,
there's a race where we can tear down the device's soft state while the
config_intrhook is still using it. Use the new config_intrhook_drain to
disestablish the hook. Either it will be removed w/o running, or the routine
will wait for it to finish. This closes the race and allows safe hotplug at any
time, even very early in boot.

Sponsored by: Netflix, Inc
Reviewed by: jhb, mav
Differential Revision: https://reviews.freebsd.org/D29006

Details

Provenance
impAuthored on Mar 11 2021, 3:42 PM
Reviewer
jhb
Differential Revision
D29006: nvme: use config_intrhook_drain to avoid removable card races
Parents
rGe52368365db3: config_intrhook: provide config_intrhook_drain
Branches
Unknown
Tags
Unknown