shithub: riscv

Download patch

ref: 8a6a354e22521e7d2d14b8b4c2d1b7a65a0c8d5e
parent: 9a69a14279be575bb2b7891a9d6f5da28ac2927c
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 22 21:59:25 EDT 2022

sdnvme: fix missing unlock() in submit queue full case

when we have more processors than submit queues,
the submit queues are shared between some processors
and hence we have to acquire its lock.

in the case of the submit queue being full, we have
to unlock it again before retrying otherwise we have
a deadlock.

sorry :(

--- a/sys/src/9/port/sdnvme.c
+++ b/sys/src/9/port/sdnvme.c
@@ -113,11 +113,14 @@
 	ws->queue = sq;
 	ws->link = &sq->wait[sq->tail & sq->mask];
 	while(*ws->link != nil){
-		sched();
+		/* should be very rare */
 		if(!adm){
-			/* should be very rare */
+			if(conf.nmach > ctlr->nsq)
+				unlock(sq);
+			sched();
 			goto Retry;
 		}
+		sched();
 	}
 	*ws->link = ws;