From nobody Tue Oct 06 22:58:49 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hzsBL1SjZz6cdr3 for ; Tue, 06 Oct 2026 22:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hzsBL0p3fz3DZp for ; Tue, 06 Oct 2026 22:58:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791327530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Rth2XEyioa6+8oQz248cagbpUyzzulqGCb+OMBXWSMw=; b=ifwLsdg6kXgCd1E99NeJc16N4ftsNVZv41K4FtcuOrMWuKzNHc5hVFbMwW2a/rFRyE/ZHR r2prlRhpUUyhYMafPpIvj5WjjiVfQBOYMbssDlg0YCPy+hjv/795c0pfxmr3GYATv3IHaI UqYYoOo2kQpuJuYcVrwHOlurei/fhR0s5veV2EBdgDhrjaI9wCUEYGIaRDpMBcEtCBnu4/ DQfFQJ2kXYRAzhLIID9/42OPlUSPmQjhV46zWqZoJfVT6AuBO/AqyLQjh451NgyS/1X+u/ 2V3AE8U+o+r+S9+b6LbCNqcsmPeDTvp1m6X9QCsejY6pdUg1uGwSkYFATybxcw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791327530; b=oNHB9zR754ystmKdCQPMR1fUvoOsUG2ooEHOM4EBF61QKqadA4ajMtf0W/uuYbnZ/myISR iyXeqhRRy3zk/yz7d2X6hVE+PXNm6SMSTQ2LUWBdX7PsORBk/jMRzuNm/gBBJ7trpscNIU G4d/w+azouCgF/0yw/Iq9opyXbBb4OTY85B0wj9M5WXL4bPiSQm0nRr1SIahbAIwgSQNql pqosEuxtKxVfCzUoUVrp4vMaYJO3JJf+2A2PTakutbJeYE6Qz7hQ7gikHIc62sOwQS3EVC eU77G2niejSuYBU//VfkBLinqeFqWx/MucM5Y7zu8T0xwM6KMDGQlFp1bjiDLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791327530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Rth2XEyioa6+8oQz248cagbpUyzzulqGCb+OMBXWSMw=; b=sTuFY3k/e/DIeSpYrmPehkXiZruw7eW83Vs5eBwXpsFq0anPDpEL5IzOG3vVEVDCk32UCq MEnCeHG3tmo+ec5e03tZyuPB3lGRsArki6btUzkcFaBdlq3AsvmGb+1lxS5AWN+KXxQ8xB EkLUJYcN5MomlCGNV5AaXTaRoisy/M0Gm1+UNIGLEglUJowHkwEa8IvXE65Gh2J1s4jm6h pK5wx2NXDrWSNff3IKrLSrQsP+KNzPMMywEsZrWdraxSaFCkona6MWyDEdaErzLf/H9OPW J/HD9NBDg1DqocWSfOoUgNKilzZ7Ytbmluz0EmwyRwgwi3aHNeidEExIQrJLFA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hzsBK6lFSzQvj for ; Tue, 06 Oct 2026 22:58:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31e11 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 06 Oct 2026 22:58:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 4a3a5de8ace3 - main - nda: Update trim stats with the periph lock held List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a3a5de8ace3c41da35f0fbac4d2549b868d1091 Auto-Submitted: auto-generated Date: Tue, 06 Oct 2026 22:58:49 +0000 Message-Id: <6ac57d29.31e11.60ba1514@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4a3a5de8ace3c41da35f0fbac4d2549b868d1091 commit 4a3a5de8ace3c41da35f0fbac4d2549b868d1091 Author: Warner Losh AuthorDate: 2026-10-06 22:45:36 +0000 Commit: Warner Losh CommitDate: 2026-10-06 22:46:22 +0000 nda: Update trim stats with the periph lock held Separate the updating the stats for the completion from the biodone for each one. Sponsored by: Netflix Reviewed by: ali_mashtizadeh.com Differential Revision: https://reviews.freebsd.org/D60155 --- sys/cam/cam_iosched.c | 22 ++++++++++++++++++++++ sys/cam/cam_iosched.h | 2 ++ sys/cam/nvme/nvme_da.c | 22 ++++------------------ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index e807301c6302..822adffc93e5 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -1822,6 +1822,28 @@ cam_iosched_bio_update_stats(struct cam_iosched_softc *isc, struct bio *bp, return retval; } +/* + * Update completion status and statistics for each bio in a queue. + * The queue is not modified. + */ +void +cam_iosched_bio_queue_update_stats(struct cam_iosched_softc *isc, + struct bio_queue *queue, union ccb *done_ccb, int error) +{ + struct bio *bp; + + TAILQ_FOREACH(bp, queue, bio_queue) { + bp->bio_error = error; + if (error != 0) { + bp->bio_flags |= BIO_ERROR; + bp->bio_resid = bp->bio_bcount; + } else + bp->bio_resid = 0; + cam_iosched_bio_update_stats(isc, bp, done_ccb); + done_ccb = NULL; + } +} + /* * Tell the io scheduler that you've pushed a trim down into the sim. * This also tells the I/O scheduler not to push any more trims down, so diff --git a/sys/cam/cam_iosched.h b/sys/cam/cam_iosched.h index cbe6a20fb871..9fc9d4a91b22 100644 --- a/sys/cam/cam_iosched.h +++ b/sys/cam/cam_iosched.h @@ -100,6 +100,8 @@ void cam_iosched_set_work_flags(struct cam_iosched_softc *isc, uint32_t flags); void cam_iosched_clr_work_flags(struct cam_iosched_softc *isc, uint32_t flags); void cam_iosched_trim_done(struct cam_iosched_softc *isc); int cam_iosched_bio_update_stats(struct cam_iosched_softc *isc, struct bio *bp, union ccb *done_ccb); +void cam_iosched_bio_queue_update_stats(struct cam_iosched_softc *isc, + struct bio_queue *queue, union ccb *done_ccb, int error); void cam_iosched_set_latfcn(struct cam_iosched_softc *isc, cam_iosched_latfcn_t, void *); void cam_iosched_set_trim_goal(struct cam_iosched_softc *isc, int goal); void cam_iosched_set_trim_ticks(struct cam_iosched_softc *isc, int ticks); diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index fe5c87c5428a..dc06d2d0d0ab 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -1329,8 +1329,8 @@ ndadone(struct cam_periph *periph, union ccb *done_ccb) biodone(bp); } else { /* state == NDA_CCB_TRIM */ struct nda_trim_request *trim; - struct bio *bp1, *bp2; - TAILQ_HEAD(, bio) queue; + struct bio *bp2; + struct bio_queue queue; trim = nvmeio->ccb_trim; TAILQ_INIT(&queue); @@ -1342,28 +1342,14 @@ ndadone(struct cam_periph *periph, union ccb *done_ccb) * need to call this here. * cam_iosched_trim_done(softc->cam_iosched); */ - /* - * The the I/O scheduler that we're finishing the I/O - * so we can keep book. The first one we pass in the CCB - * which has the timing information. The rest we pass in NULL - * so we can keep proper counts. - */ - bp1 = TAILQ_FIRST(&queue); - cam_iosched_bio_update_stats(softc->cam_iosched, bp1, done_ccb); + cam_iosched_bio_queue_update_stats(softc->cam_iosched, + &queue, done_ccb, error); xpt_release_ccb(done_ccb); softc->outstanding_cmds--; ndaschedule(periph); cam_periph_unlock(periph); while ((bp2 = TAILQ_FIRST(&queue)) != NULL) { TAILQ_REMOVE(&queue, bp2, bio_queue); - bp2->bio_error = error; - if (error != 0) { - bp2->bio_flags |= BIO_ERROR; - bp2->bio_resid = bp1->bio_bcount; - } else - bp2->bio_resid = 0; - if (bp1 != bp2) - cam_iosched_bio_update_stats(softc->cam_iosched, bp2, NULL); biodone(bp2); } }