HomeFreeBSD

nvme: Close a race in destroying qpair and timeouts

Description

nvme: Close a race in destroying qpair and timeouts

While we should have cleared all the pending I/O prior to calling
nvme_qpair_destroy, which should ensure that if the callout_drain causes
a call to nvme_qpair_timeout(), it won't schedule any new
timeout. However, it doesn't hurt to set timeout_pending to false in
nvme_qpair_destroy() and have nvme_qpair_timeout() exit early if it sees
it w/o scheduling a timeout. Since we don't otherwise stop the timeout
until we're about to destroy the qpair, this ensures we fail safe. The
lock/unlock also ensures the callout_drain will either remove the callout,
or wait for it to run with the early bailout.

We can likely further improve this by using callout_stop() inside the
pending lock. I'll investigate that for future refinement.

Sponsored by: Netflix
Suggestions by: jhb
Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D42065

Details

Provenance
impAuthored on Oct 10 2023, 5:13 PM
Reviewer
gallatin
Differential Revision
D42065: nvme: Close a race in destroying qpair and timeouts
Parents
rG9cd7b624732c: nvme: Eliminate RECOVERY_FAILED state
Branches
Unknown
Tags
Unknown