From nobody Tue Mar 3 18:01:14 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 4fQNs64Kbfz6TQrK for ; Tue, 03 Mar 2026 18:01:14 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fQNs62qL8z3JXF for ; Tue, 03 Mar 2026 18:01:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772560874; 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=WoOrJeDX+CHUPSjnktALO+HQoNeUWJUAkAO2jv6APKk=; b=UQOFe340jWzQE4/uaV/92nZloPNhmxFzUSCRfGOgu2qhV/XF+jCVtu4Pkq64ph/bGNohtY IN5LRkqpQPLTgLB9lLegVC8BqSmsnaN9feXQRIVPk9f0bCSfsh1e7FnBHftT9nRh4RJ1lV N3CULPbNIo2u9hb5CKzICnJQ514C+0k32d/pOWI0uxiHQQvy7DCgPilexiIGBCvUSwCwWn +MpN3SRxU0akFXS05aLtcLM7DBYD/bQKaK6QIypO0Hnu9mMN0h0T+Hi+abrYdnI2seARly XtGcsBkOvbn+zOpFtrs2lZPQcVun2kasZDcawQ5tEtivFIqftjV6Fl2C+JZWzg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772560874; a=rsa-sha256; cv=none; b=Cz3L4IWLH5Te3K0anAtuQ0K0f/AFK/zqdvDNL8XkvxLGxtoF7fjOV4f7UdOUdKIMCN4uHi jKjjbNA3BOJmHpSJd2flYIHwqVydzpG73nf00wDqUhReVlg6854jbsli8Liiy5GfdnQi35 MY1wq/+4sgfHCCuCLTLjaNEnew6yWCS6mZcFNSDF5FnvFQdxcKSPAXrfyLllE0yyCoDmY6 /be5IzFR9nYqYf4H86xZMPxDH6rsbx54qQXd+Gy9+FgS+5LAMGMEyrH1HtMR5bJx6ihVmS nuSg5lqKAO2qHyoY8irlskgMnXNj32Kvsx9H8vcAGr743C4348DpxwYoUlaMiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772560874; 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=WoOrJeDX+CHUPSjnktALO+HQoNeUWJUAkAO2jv6APKk=; b=Q6FEZqeweu4W+XQbe/FOMyUhlxz/UqQ3lhQjhL2uPmWrMKra3b3+RmYl5aUnD5C+uu5tF3 tQ+tTiMvGGTJV92xUEOhaRAh+DF1rrCORSzDgXD+B/SLBqtjhZZ/60Psffkz1Od7rYZA83 UsVUauHvD8pkWlXrd8pgTZGo6cN0Ykwi4cE39WjCUQ6m/pEoo4twxw58GnXQ8CvQt5w55m 2lj5NtfQgXZAi1abwsmYg0QvzenZ+juKxJmzO0BvoJ4RqCMC2QBrgVhwytODuusVXUdqZV ddYFUDjkkocoNrFzuQ1ceLmAW7qic0iu3BTh4qVp6wFXtN549MSrgYRoZHRVUg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fQNs6274tzfv for ; Tue, 03 Mar 2026 18:01:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 43196 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 03 Mar 2026 18:01:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5c2186b99254 - main - nda: Rescan the drive on open 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 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: 5c2186b992546bce212dfad3e49012f4c69c2d0c Auto-Submitted: auto-generated Date: Tue, 03 Mar 2026 18:01:14 +0000 Message-Id: <69a721ea.43196.3698350a@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5c2186b992546bce212dfad3e49012f4c69c2d0c commit 5c2186b992546bce212dfad3e49012f4c69c2d0c Author: Warner Losh AuthorDate: 2026-03-03 17:59:31 +0000 Commit: Warner Losh CommitDate: 2026-03-03 17:59:31 +0000 nda: Rescan the drive on open SCSI and ATA drives rescan the drive on opens to catch changes to the disk. We do it here to so we catch if a drive has been FORMATed or SANITIZEd with different parameters. We don't use xpt_rescan() since we don't want to interfere with boot or keep all busses locked (this rescan won't change the bus, so we don't need the CAM topo lock). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D55520 --- sys/cam/nvme/nvme_da.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index 9646b792e9a9..2e8e376f985d 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -73,12 +73,14 @@ typedef enum { NDA_FLAG_OPEN = 0x0001, NDA_FLAG_DIRTY = 0x0002, NDA_FLAG_SCTX_INIT = 0x0004, + NDA_FLAG_RESCAN = 0x0008, } nda_flags; #define NDA_FLAG_STRING \ "\020" \ "\001OPEN" \ "\002DIRTY" \ - "\003SCTX_INIT" + "\003SCTX_INIT" \ + "\004RESCAN" typedef enum { NDA_Q_4K = 0x01, @@ -318,11 +320,27 @@ ndasetgeom(struct nda_softc *softc, struct cam_periph *periph) disk->d_flags |= flags; } +static void +ndaopen_rescan_done(struct cam_periph *periph, union ccb *ccb) +{ + struct nda_softc *softc; + + softc = (struct nda_softc *)periph->softc; + + cam_periph_assert(periph, MA_OWNED); + + softc->flags &= ~NDA_FLAG_RESCAN; + xpt_release_ccb(ccb); + wakeup(&softc->disk->d_mediasize); +} + + static int ndaopen(struct disk *dp) { struct cam_periph *periph; struct nda_softc *softc; + union ccb *ccb; int error; periph = (struct cam_periph *)dp->d_drv1; @@ -337,10 +355,37 @@ ndaopen(struct disk *dp) return (error); } + softc = (struct nda_softc *)periph->softc; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, ("ndaopen\n")); - softc = (struct nda_softc *)periph->softc; + /* + * Rescan the lun in case the mediasize or sectorsize has changed since + * we probed the device. Format and secure erase operations can do this, + * but the nvme standard doesn't require a async notification of that + * happening. da/ada do this by restarting their probe, but since + * nvme_xpt gets the identify information we need, we just rescan here + * since it's the easiest way to notice size changes. + * + * Not acquiring / releasing for the geom probe -- it's inline + */ + ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL); + ccb->ccb_h.func_code = XPT_SCAN_LUN; + ccb->ccb_h.cbfcnp = ndaopen_rescan_done; + ccb->ccb_h.ppriv_ptr0 = periph; + ccb->crcn.flags = 0; + xpt_action(ccb); + + softc->flags |= NDA_FLAG_RESCAN; + error = 0; + while ((softc->flags & NDA_FLAG_RESCAN) != 0 && error == 0) + error = cam_periph_sleep(periph, &softc->disk->d_mediasize, PRIBIO, + "ndareprobe", 0); + if (error != 0) + xpt_print(periph->path, "Unable to retrieve capacity data\n"); + else + ndasetgeom(softc, periph); + softc->flags |= NDA_FLAG_OPEN; cam_periph_unhold(periph);