Page MenuHomeFreeBSD

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

Authored by imp on Aug 3 2022, 5:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 5, 5:05 PM
Unknown Object (File)
Mar 7 2024, 4:21 AM
Unknown Object (File)
Jan 9 2024, 9:57 PM
Unknown Object (File)
Dec 15 2023, 4:34 AM
Unknown Object (File)
Nov 17 2023, 7:52 AM
Unknown Object (File)
Nov 5 2023, 5:42 PM
Unknown Object (File)
Nov 3 2023, 3:23 PM
Unknown Object (File)
Oct 11 2023, 6:50 AM
Subscribers
None

Details

Reviewers
mav
ken
Group Reviewers
cam
Summary

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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No 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.