Page MenuHomeFreeBSD

cam: Defer callbacks in camperiphfree to a sleepable context
Needs ReviewPublic

Authored by imp on Aug 3 2022, 5:25 PM.


Group Reviewers

camperiphfree will attempt to make a deferred callback if a new device
arrives while a periph for that same device is being destroyed. This
callback can create a new periph which may create a new disk which
requires a sleepable context to allocate memory. Use the new
xpt_deferred_callback to defer the actual call to a sleepable
context. This is a rare event as most SIMs will debounce device
departure and arrives. It has shown up lately for both misbehaving USB
drives as well as flakey SATA drives connected to ahci.

PR: 263703
Sponsored by: Netflix

Diff Detail

rS FreeBSD src repository - subversion
Lint OK
No Unit Test Coverage
Build Status
Buildable 46741
Build 43630: arc lint + arc unit

Event Timeline

imp requested review of this revision.Aug 3 2022, 5:25 PM

I never liked this mechanism of deferred_callback. But now it even more decouples the async events from the periph state and obfuscates it. Even now if device reattached and then detached I guess CAM_PERIPH_NEW_DEV_FOUND will remain set, since cam_periph_invalidate() for some reason clears it only if periph is still valid, and so periph will still try to recreate itself. Am I missing something? But this additional decouple may postpone the recreation even more, so that CAM_PERIPH_NEW_DEV_FOUND clear by AC_LOST_DEVICE potentially sitting in the async queue will no longer help and the callback will be called any way.

Don't get me wrong, there is definitely the problem to be fixed.