From nobody Wed Mar 13 17:02:36 2024 X-Original-To: bugs@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 4Tvxdn0T6hz5DGjt for ; Wed, 13 Mar 2024 17:02:37 +0000 (UTC) (envelope-from bugzilla-noreply@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tvxdm3nwwz4J8Z for ; Wed, 13 Mar 2024 17:02:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710349356; a=rsa-sha256; cv=none; b=avZ85JNJ4b8DVrcWCp5NeTC4RtsaMqFJaBJhk5wCaqv4AC0AOGYTUd1WaMal/E8MvqXwpa J/oqV2mhApE7Og7c83d+f41OX1AxKbhSM944UQClam5RF6RmfKXpHEIaIzUKiOjwK2Bh0o uwKwoBZPNlPlUDSXiV7M8ptuS445NlBQyrzRaw2lmQUCJxd5jyGWq38HoyEKV8IGoPbF1M uOW6UOWfKngdsCovAjgUmf+jnhrUjZtFyEWHeAmZAziuELvLcaMGNLiaoY6bAwHNTtyL4R G6hFF8SWoHZCQjgAwXGDQ8TwEYy0KDt0Z7MGiSAsmyNo1bKSBtqquPKmup9u1g== 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=1710349356; 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=Q3FsC3YEdR52UeDWgfx/t6ZzvwDFiYhRXbA04rzWsqw=; b=RoTc1rPJDV3M399MDsL63D1Dwln9rlwDE0ExOoI8SVAYKcrxCnKpurcFZ0AMbDCWGtR74J i3vSn7lud+RlY8w1z4AY+E2yNkvqR65u8et0ewlmnhipIpwv39vK4kImloi6paB/ZV/mfo G8mWCn25qQd53P3AH1T/54fJ+dE27uuNxsE846NM+jnsolb56IvWefAgQj3FKUI+075dNT PKCyvAMxxohASiIFXVrY2ndpxzRi/w/les2K9jTVPngXTA0nqkG/GMFcS7GrEjn1v6xanc 9o5JY2oRmmvQOuP31M2xF+a4rHmCH7JnJzy7L836G4SzeDBEH+E9zZRDhawUJg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Tvxdm3PdgzrVb for ; Wed, 13 Mar 2024 17:02:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 42DH2aoi045264 for ; Wed, 13 Mar 2024 17:02:36 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 42DH2aRZ045263 for bugs@FreeBSD.org; Wed, 13 Mar 2024 17:02:36 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 277673] TRIM visibility bugs Date: Wed, 13 Mar 2024 17:02:36 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: mgrooms@shrew.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277673 Bug ID: 277673 Summary: TRIM visibility bugs Product: Base System Version: 14.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: mgrooms@shrew.net Hey All, While toying with different storage options to use with bhyve, I've run acr= oss a few frustrations related to visibility into TRIM operations. Specifically, it's not always easy to tell if trim operations are being processed by a hardware device due to the counters not being updated by the SCSI da device. The counters exported as sysctl values are updated by the SCCI UNMAP method, but not by the TRIM or WD methods. You can see the BIO_DELETE opterations b= eing processed in real time by running the gstatus -d command, but the counters never change from 0. This gives the false illusion that nothing is happenin= g. With the following patch, I'm now able to see the counters reflect trim operations that are processed by da devices ... mgrooms@mgrooms:~/trim $ cat scsi_da.diff --- scsi_da.c.orig 2024-03-13 11:32:32.098922000 -0500 +++ scsi_da.c 2024-03-13 11:31:37.255187000 -0500 @@ -4197,6 +4197,9 @@ da_default_timeout * 1000); ccb->ccb_h.ccb_state =3D DA_CCB_DELETE; ccb->ccb_h.flags |=3D CAM_UNLOCKED; + softc->trim_count++; + softc->trim_ranges +=3D ranges; + softc->trim_lbas +=3D block_count; cam_iosched_submit_trim(softc->cam_iosched); } @@ -4257,6 +4260,8 @@ da_default_timeout * 1000); ccb->ccb_h.ccb_state =3D DA_CCB_DELETE; ccb->ccb_h.flags |=3D CAM_UNLOCKED; + softc->trim_count++; + softc->trim_lbas +=3D count; cam_iosched_submit_trim(softc->cam_iosched); } Additionally, while attempting to test geom mirror+stripe to provide softwa= re RAID10, the diskinfo utility reports that a mirror supports UNMAP/TRIM when= at least one underlying devices supports it, but a stripe does not. I added a small patch that attempts to use the same logic as mirror so that it will report that UNMAP/TRIM is supported when one of the underlying devices does= ... --- g_stripe.c.orig 2024-03-12 18:23:52.960025000 -0500 +++ g_stripe.c 2024-03-12 18:25:01.009378000 -0500 @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#include #include #include #include @@ -568,7 +569,7 @@ off_t offset, start, length, nstripe, stripesize; struct g_stripe_softc *sc; u_int no; - int error, fast =3D 0; + int error, fast =3D 0, val =3D 0; sc =3D bp->bio_to->geom->softc; /* @@ -591,6 +592,12 @@ g_stripe_pushdown(sc, bp); return; case BIO_GETATTR: + if (!strcmp(bp->bio_attribute, "GEOM::candelete")) { + if (sc->sc_flags & G_STRIPE_FLAG_CANDELETE) + val =3D 1; + g_handleattr(bp, "GEOM::candelete", &val, sizeof(val)); + return; + } /* To which provider it should be delivered? */ default: g_io_deliver(bp, EOPNOTSUPP); @@ -745,7 +752,7 @@ { struct g_consumer *cp, *fcp; struct g_geom *gp; - int error; + int error, i; g_topology_assert(); /* Metadata corrupted? */ @@ -792,8 +799,19 @@ goto fail; } } - sc->sc_disks[no] =3D cp; + + /* cascade candelete */ + error =3D g_access(cp, 1, 0, 0); + if (error =3D=3D 0) + { + error =3D g_getattr("GEOM::candelete", cp, &i); + if (error =3D=3D 0 && i !=3D 0) + sc->sc_flags |=3D G_STRIPE_FLAG_CANDELETE; + G_STRIPE_DEBUG(1, "Provider %s candelete %i.", pp->name, i); + g_access(cp, -1, 0, 0); + } + G_STRIPE_DEBUG(0, "Disk %s attached to %s.", pp->name, sc->sc_name); g_stripe_check_and_run(sc); --- g_stripe.h.orig 2024-03-12 18:24:00.960741000 -0500 +++ g_stripe.h 2024-03-12 12:25:22.842925000 -0500 @@ -47,6 +47,8 @@ #define G_STRIPE_TYPE_MANUAL 0 #define G_STRIPE_TYPE_AUTOMATIC 1 +#define G_STRIPE_FLAG_CANDELETE 0x00000001UL + #define G_STRIPE_DEBUG(lvl, ...) \ _GEOM_DEBUG("GEOM_STRIPE", g_stripe_debug, (lvl), NULL, __VA_ARGS__) #define G_STRIPE_LOGREQ(bp, ...) \ @@ -61,6 +63,7 @@ uint16_t sc_ndisks; off_t sc_stripesize; uint32_t sc_stripebits; + uint32_t sc_flags; struct mtx sc_lock; }; #define sc_name sc_geom->name --=20 You are receiving this mail because: You are the assignee for the bug.=