git: 5a178b831a9f - main - nvme: Add locking asserts

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 13 May 2024 22:38:28 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=5a178b831a9fe8c51e406355f0164d01627cf1f4

commit 5a178b831a9fe8c51e406355f0164d01627cf1f4
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-05-13 20:53:48 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-13 22:14:03 +0000

    nvme: Add locking asserts
    
    nvme_qpair_complete_tracker and nvme_qpair_manual_complete_tracker have
    to be called without the qpair lock, so assert its unowned.
    
    Sponsored by:           Netflix
---
 sys/dev/nvme/nvme_qpair.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 62d27e439180..b11bdc44dc40 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -414,10 +414,12 @@ static void
 nvme_qpair_complete_tracker(struct nvme_tracker *tr,
     struct nvme_completion *cpl, error_print_t print_on_error)
 {
-	struct nvme_qpair * qpair = tr->qpair;
+	struct nvme_qpair	*qpair = tr->qpair;
 	struct nvme_request	*req;
 	bool			retry, error, retriable;
 
+	mtx_assert(&qpair->lock, MA_NOTOWNED);
+
 	req = tr->req;
 	error = nvme_completion_is_error(cpl);
 	retriable = nvme_completion_is_retry(cpl);
@@ -486,10 +488,11 @@ nvme_qpair_manual_complete_tracker(
     error_print_t print_on_error)
 {
 	struct nvme_completion	cpl;
+	struct nvme_qpair * qpair = tr->qpair;
 
-	memset(&cpl, 0, sizeof(cpl));
+	mtx_assert(&qpair->lock, MA_NOTOWNED);
 
-	struct nvme_qpair * qpair = tr->qpair;
+	memset(&cpl, 0, sizeof(cpl));
 
 	cpl.sqid = qpair->id;
 	cpl.cid = tr->cid;