From nobody Sun Apr 24 20:02:26 2022 X-Original-To: dev-commits-src-all@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 446151A97BA8; Sun, 24 Apr 2022 20:02:28 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KmfFH5j6Wz4pVW; Sun, 24 Apr 2022 20:02:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650830547; 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=SAC4647Uuby2UieyN4NpHpNcBaZ4OJ8uks4gvm1V2Xc=; b=SwMOMU7US7okr2g+oDxPHAED6rJj8MsirrNfWCeYmgdHZy01AmqhZHXfw09qbNOZAW2bVg Vzhu5a5Jrs3v0F5N3jaG1Np5VbRTCXNz2v5jZIhpz4gwO8rVp7Lr8cLr84m+BYRMXNqK7B T8Jp8CiY9sY2M3YiM3q77Yb4a6n8tzIliUrw5JBx/1EKdmsyRfcXCgszYuOT729t2aHc92 AZPkcBKWM2IWoK6X57hFkstA9h/RCBSmU5TWkvcsB77KBCYpmlPodKdeO100Vi+8HqHuwj vCscweN9fQkPuhhXgDuV5yKeuhOZNsv2JHEoX194TTITA/DC7c1yXkKKIn7JWw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 2D25446D1; Sun, 24 Apr 2022 20:02:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23OK2Q47049609; Sun, 24 Apr 2022 20:02:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23OK2QKW049608; Sun, 24 Apr 2022 20:02:26 GMT (envelope-from git) Date: Sun, 24 Apr 2022 20:02:26 GMT Message-Id: <202204242002.23OK2QKW049608@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e8827f4094cb - main - g_vfs_done: Report when we switch on ENXIO conversion List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: e8827f4094cb9ec7c5a4dcf9ee144442c989cd0c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650830547; 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=SAC4647Uuby2UieyN4NpHpNcBaZ4OJ8uks4gvm1V2Xc=; b=CmWAXNOEphSFJKtunj9PitlJEO8KeglrGn9SZbeh8DWELpcdqAjEQvfaMW+bMtnZXJzuuX X0b7T2UFJ2Vw3axbufyBDnNl4c8D66UVhzfLwOZu+VYD+fWpBScGaPHLutXZJ05N3nS2Xa zmz0tFMFNADljwM8sxy/CP3PYp8UP1BE1tNxdPxhI/6q1A3JFjwZ7TORo0L9v549OHgUYm D+IgB88awtkUWvS1k/lL7De1VL7QOxYstCE2RDJr1GdnHY840Ww0/eDPvAhq7wPgux0VUJ 6yxDmotXRpbezrQ3urEWb8DVjyM4wI8FsIWwSSS0Rh2Q4+NMSy4xTWgbJ6nKCA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650830547; a=rsa-sha256; cv=none; b=H54YpR4w55EateXirZDRBsYvwDWedt+6Epfn1b9g/lB4CMBoWpPfze3Wd/Jln8meUafq2a ZcGwO5KU6oJx8sE0N5OSSsv6VOxqFFPwUTBhpuRjFoUdYRtvLy5UoKeooYYIus3Pekhsov Rheb1/1r8hrz8eoKGjFSoJ/xVjVXH6fJfseWWBNgK1RILyn5b1v52scptkj+cEEcAlQDby PySdRpTrKkA7s1I/23Zm8dGdQGVdFT8xXy/0opkqXJGg5ZN0og7UOOhG0FndDTKcDV5Oca HzMNDyvzrOcVjj72axeXTMXH7Hd3RoTKJDk5rFmmkeVgGX+On78IM16Ul28MYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e8827f4094cb9ec7c5a4dcf9ee144442c989cd0c commit e8827f4094cb9ec7c5a4dcf9ee144442c989cd0c Author: Warner Losh AuthorDate: 2022-04-24 19:54:20 +0000 Commit: Warner Losh CommitDate: 2022-04-24 20:01:08 +0000 g_vfs_done: Report when we switch on ENXIO conversion On the 0 -> 1 transition of sc_enxio_active, report that we're doing this. This is a rare, but interesting, event. Convert to using atomics to set this field to prevent a rare race: In CAM, when we invalidate a device, one thread (T1) will start the process in error processing called from *dadone (cam_periph_error). This routine will queue work to xpt_async_td (T2) and indicate to *dadone to call biodone(ENXIO) for the bio. T2 wakes up and basically waits to acquire the periph lock. T2 will do so when T1 drops the periph lock just before T1's call to biodone. T2 acquires the lock and calls biodone(ENXIO) on all pending bios. These two threads will race and we could lose the printf or get two in rare cases. Since we only touch sc_enxio_active in an error path that's infrequent, the extra atomic traffic will be rare but will ensure robustness. Sponsored by: Netflix Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D35037 --- sys/geom/geom_vfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c index beb5632f43d6..b6f5916c386a 100644 --- a/sys/geom/geom_vfs.c +++ b/sys/geom/geom_vfs.c @@ -143,8 +143,11 @@ g_vfs_done(struct bio *bip) cp = bip->bio_from; sc = cp->geom->softc; if (bip->bio_error != 0 && bip->bio_error != EOPNOTSUPP) { - if ((bp->b_xflags & BX_CVTENXIO) != 0) - sc->sc_enxio_active = 1; + if ((bp->b_xflags & BX_CVTENXIO) != 0) { + if (atomic_cmpset_int(&sc->sc_enxio_active, 0, 1)) + printf("g_vfs_done(): %s converting all errors to ENXIO\n", + bip->bio_to->name); + } if (sc->sc_enxio_active) bip->bio_error = ENXIO; g_print_bio("g_vfs_done():", bip, "error = %d",