Module Name:    src
Committed By:   riastradh
Date:           Tue Aug 30 01:13:10 UTC 2022

Modified Files:
        src/sys/dev/ic: nvme.c

Log Message:
nvme(4): If bp is null or bp->b_ci is not assigned, use curcpu().

curcpu() might be stale by the time we're done, but it's still safe
to pass it to cpu_index, and this is just used as a best-effort
mechanism to keep I/O on queues handled by the same CPU.

bp is not always provided, and bp->b_ci is not always assigned,
e.g. when dumping.  (If bp->b_ci is supposed to be always assigned,
then we need to audit all the paths into it to assign it in those
where it's not.)

Fixes dump on nvme.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/ic/nvme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.64 src/sys/dev/ic/nvme.c:1.65
--- src/sys/dev/ic/nvme.c:1.64	Sat Aug 20 11:31:38 2022
+++ src/sys/dev/ic/nvme.c	Tue Aug 30 01:13:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.64 2022/08/20 11:31:38 riastradh Exp $	*/
+/*	$NetBSD: nvme.c,v 1.65 2022/08/30 01:13:10 riastradh Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.64 2022/08/20 11:31:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.65 2022/08/30 01:13:10 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1867,7 +1867,7 @@ static struct nvme_ccb *
 nvme_ccb_get_bio(struct nvme_softc *sc, struct buf *bp,
     struct nvme_queue **selq)
 {
-	u_int cpuindex = cpu_index(bp->b_ci);
+	u_int cpuindex = cpu_index(bp->b_ci ? bp->b_ci : curcpu());
 
 	/*
 	 * Find a queue with available ccbs, preferring the originating

Reply via email to