From nobody Fri Apr 29 20:54:54 2022 X-Original-To: dev-commits-src-branches@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 938FC1993A75; Fri, 29 Apr 2022 20:54:54 +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 4Kql9V3Dfpz3F26; Fri, 29 Apr 2022 20:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651265694; 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=e5trThHi1a6cLU4YKJNEAEHzFYX+7GMh0xJBIofyWfo=; b=dGHgDR7uNTP2y/jdo8zU7nN4/rqjV3000AIa+DmPqZ1iav/WYYwSGc5piEodlom4luSbpS bc+bFH7NPiO9kPoa9fDlFYyZFyziuT5KxCMv1b3o/YJe2gIc2Z7xjYANo58J4LSzD5ueQ6 y9kmFn7xf7Lj88T68QQ6g4DtjstMj03PXDoP4V+RX0MSJmOQUPzvjvi3UGZZDOQEgPTXvV aC7w2ozoX+YB2Ycb7rVArfBSIzvfQJ/Wk39/uaysakDTiw3ZsghrhVsI3GkAK5+dmXW3iE dwwggB9LORBn8iP31hjU6LKoJLUo74QH5Zq/R3WFNHZP2DpO/Rs9u6DnFhizfw== 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 4E91213F2F; Fri, 29 Apr 2022 20:54:54 +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 23TKssgu054916; Fri, 29 Apr 2022 20:54:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23TKssEF054915; Fri, 29 Apr 2022 20:54:54 GMT (envelope-from git) Date: Fri, 29 Apr 2022 20:54:54 GMT Message-Id: <202204292054.23TKssEF054915@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 506fac3fb303 - stable/13 - geom_vfs: Pre-allocate event for g_vfs_destroy. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 506fac3fb303eef89df8ec7845228a33a010a3fe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651265694; 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=e5trThHi1a6cLU4YKJNEAEHzFYX+7GMh0xJBIofyWfo=; b=CQMXALbVrgtn5kz7aB8Iuu4Xn1Am+a/xRqJjArCv8X+Y7goPOctdwYnYFEQDxdkR/daB1R Is4+pM4ZeV3OqpmJ1muu9vZA+eQZU0RToDJkwzSpgxRCi9r/jqh7c7NOIhXxfPdVX45xPC 69gL+6W457xw2/VoYy29Xp2bTLujrf4Ji9JngL2sWxExLUVPxV7c3W3vERloV3BWsEuLK2 5MblBgZ3vY+Q3nk+5lwh2CQB/O9HZxVrosrl6pLn+Oc4gCMZpEqWae0yuhEFkQzeNCPzHo 4YOFhXPL4jfGtnI5kVXOgds6CaSIen0co48ZHXGldvHCj/RAkvP5YFYO4rSwOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651265694; a=rsa-sha256; cv=none; b=bjCQHYDlAP7wdCeZGvkE9Q0lD47F41sEfZfLZ1KHHlG3zQWEJe1tYmfGQmlRr3AZdl4Tfw eT2T0LbujtdrwNRrBpI+IYZBJY1QQd3jHRsTO8AMuXrrpHuyk9bWZ+vz8liWQMlK+N+5FH OfEh+bkiOjRSJuIZ444gGAffMu+5CzvgigpRNvtQmQU8azPjVNP8CwY5NfCI0BgtZa93iq PjN0B98DC7ADpMEgKJsML9bRB5kEd3BCvPZMccTPu3FyQww00PnzliYIllhOh8UHh4izxh IrIMhZxNJdT0/19rZPbRgB/U7d8KVV6yc+uOO/7fK/V5IZwNFxFtGF0kgbsr1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=506fac3fb303eef89df8ec7845228a33a010a3fe commit 506fac3fb303eef89df8ec7845228a33a010a3fe Author: John Baldwin AuthorDate: 2021-07-30 00:09:23 +0000 Commit: John Baldwin CommitDate: 2022-04-29 20:50:03 +0000 geom_vfs: Pre-allocate event for g_vfs_destroy. When an active g_vfs is orphaned due to an underlying disk going away the destroy is deferred until the filesystem is unmounted in g_vfs_done(). However, g_vfs_done() is invoked from a non-sleepable context and cannot use M_WAITOK to allocate the event. Instead, allocate the event in g_vfs_orphan() and save it in the softc to be retrieved by the last call to g_vfs_done(). Reported by: Jithesh Arakkan @ Chelsio Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D31354 (cherry picked from commit 419d406e4ee068644218fb881bc80f79f8191970) --- sys/geom/geom_vfs.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c index f01765b8ee30..592062b8b12a 100644 --- a/sys/geom/geom_vfs.c +++ b/sys/geom/geom_vfs.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); struct g_vfs_softc { struct mtx sc_mtx; struct bufobj *sc_bo; + struct g_event *sc_event; int sc_active; int sc_orphaned; int sc_enxio_active; @@ -96,6 +97,7 @@ static void g_vfs_done(struct bio *bip) { struct g_consumer *cp; + struct g_event *event; struct g_vfs_softc *sc; struct buf *bp; int destroy; @@ -157,9 +159,14 @@ g_vfs_done(struct bio *bip) mtx_lock(&sc->sc_mtx); destroy = ((--sc->sc_active) == 0 && sc->sc_orphaned); + if (destroy) { + event = sc->sc_event; + sc->sc_event = NULL; + } else + event = NULL; mtx_unlock(&sc->sc_mtx); if (destroy) - g_post_event(g_vfs_destroy, cp, M_WAITOK, NULL); + g_post_event_ep(g_vfs_destroy, cp, event, NULL); bufdone(bp); } @@ -212,6 +219,7 @@ static void g_vfs_orphan(struct g_consumer *cp) { struct g_geom *gp; + struct g_event *event; struct g_vfs_softc *sc; int destroy; @@ -222,12 +230,20 @@ g_vfs_orphan(struct g_consumer *cp) sc = gp->softc; if (sc == NULL) return; + event = g_alloc_event(M_WAITOK); mtx_lock(&sc->sc_mtx); + KASSERT(sc->sc_event == NULL, ("g_vfs %p already has an event", sc)); sc->sc_orphaned = 1; destroy = (sc->sc_active == 0); + if (!destroy) { + sc->sc_event = event; + event = NULL; + } mtx_unlock(&sc->sc_mtx); - if (destroy) + if (destroy) { + g_free(event); g_vfs_destroy(cp, 0); + } /* * Do not destroy the geom. Filesystem will do that during unmount. @@ -297,5 +313,6 @@ g_vfs_close(struct g_consumer *cp) mtx_destroy(&sc->sc_mtx); if (!sc->sc_orphaned || cp->provider == NULL) g_wither_geom_close(gp, ENXIO); + KASSERT(sc->sc_event == NULL, ("g_vfs %p event is non-NULL", sc)); g_free(sc); }