git: 21b7a2ff550f - stable/14 - pass(4): Wake select/kqueue waiters when an immediate CCB completes

From: Kenneth D. Merry <ken_at_FreeBSD.org>
Date: Wed, 18 Nov 2026 18:02:54 UTC
The branch stable/14 has been updated by ken:

URL: https://cgit.FreeBSD.org/src/commit/?id=21b7a2ff550f96b87ad7b1ca750f6eedc66e988a

commit 21b7a2ff550f96b87ad7b1ca750f6eedc66e988a
Author:     Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2026-11-10 23:01:38 +0000
Commit:     Kenneth D. Merry <ken@FreeBSD.org>
CommitDate: 2026-11-18 17:37:29 +0000

    pass(4): Wake select/kqueue waiters when an immediate CCB completes
    
    In the CAMIOQUEUE ioctl, a queued CCB completes through passdone(),
    which moves it to the done queue and calls selwakeuppri() and
    KNOTE_LOCKED() so that a consumer blocked in select(2), poll(2) or
    kevent(2) wakes up and collects the CCB with CAMIOGET.  An immediate
    CCB (e.g. XPT_DEV_ADVINFO or XPT_DEV_MATCH) is instead executed
    synchronously in the ioctl and moved to the done queue directly,
    with no notification, so a consumer sleeping while waiting for its
    completion never wakes up until some other queued I/O completes.
    
    Send the same notification that passdone() sends.  The peripheral
    lock is held at this point and backs the knlist, so KNOTE_LOCKED()
    is the correct variant.
    
    A version of this fix has been in production use at Spectra Logic
    since 2024.
    
    Co-authored-by: Dave Baukus <daveb@spectralogic.com>
    Reviewed by:    imp
    MFC after:      1 week
    Sponsored by:   Spectra Logic
    Assisted-by:    Claude Fable 5 <noreply@anthropic.com>
    Differential Revision:  https://reviews.freebsd.org/D61416
    
    (cherry picked from commit 6442a92a7d9c20c666999cc699610f1f5bec3cfd)
---
 sys/cam/scsi/scsi_pass.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 72035e1e0d0e..3215b66454a1 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -1994,11 +1994,14 @@ passdoioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread
 		/*
 		 * If this is not a queued CCB (i.e. it is an immediate CCB),
 		 * then it is already done.  We need to put it on the done
-		 * queue for the user to fetch.
+		 * queue for the user to fetch, and notify any waiters so
+		 * they know there is a completed CCB to collect.
 		 */
 		if ((fc & XPT_FC_QUEUED) == 0) {
 			TAILQ_REMOVE(&softc->active_queue, io_req, links);
 			TAILQ_INSERT_TAIL(&softc->done_queue, io_req, links);
+			selwakeuppri(&softc->read_select, PRIBIO);
+			KNOTE_LOCKED(&softc->read_select.si_note, 0);
 		}
 		break;