]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
nvme: Close a race in destroying qpair and timeouts
authorWarner Losh <imp@FreeBSD.org>
Tue, 10 Oct 2023 17:13:25 +0000 (11:13 -0600)
committerWarner Losh <imp@FreeBSD.org>
Tue, 10 Oct 2023 22:13:57 +0000 (16:13 -0600)
commitafc3d49b17a35db3b70c9e4f63a508a14a8237fe
tree2fb2e12bc0d7cd505270c822cd01efb552a77ca7
parent9cd7b624732c3b675178b02b7447272f67a3203d
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
sys/dev/nvme/nvme_qpair.c