From nobody Thu Jan 20 20:08:54 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 3B85F1973FA2; Thu, 20 Jan 2022 20:08:55 +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 4Jftr70wKnz3r2L; Thu, 20 Jan 2022 20:08:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642709335; 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=NphSNmA46eOeY78H9ZqWzVo3FSMl3ZhwUg6NUsEGXF4=; b=YizyXfh6Iyt9E8rMdXAu3+NJeCzhk5M55YpYJY5thUTlPknKmAD9+5axTVuA+61SszESLv vWb5GLe3wFAAlDz1XUBW5vb0dyr+E4t3786RorYnaxNzRT+qJYKrlMZC1EkPdd4Zub9d2Z REF21cNqyIOsSaTVjGn69arsdm+Z7EJcX0PejEtydsafZgX0H2c4Uvd4lBSLQ79zFJ0ylS fOdBceRJ/oKqR+XZJOcYnwJiY+wALfGyXKQDxCohaqH7Q9DVf68sDPAAba8JsEx2v2VvJy cou0K+k6uUxEeZl/Z59AKcf/RPw3jqzE4hZSsikV3N5DmcpMoYWQ1UT8v4ZxOg== 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 F370A68B2; Thu, 20 Jan 2022 20:08: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 20KK8sFL094303; Thu, 20 Jan 2022 20:08:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20KK8sGF094302; Thu, 20 Jan 2022 20:08:54 GMT (envelope-from git) Date: Thu, 20 Jan 2022 20:08:54 GMT Message-Id: <202201202008.20KK8sGF094302@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Kenneth D. Merry" Subject: git: 6d1a563281a9 - stable/12 - Free UMA zones when a pass(4) instance goes away. 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: ken X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 6d1a563281a9367eb288c3ecc74332e09bcd2b6b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642709335; 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=NphSNmA46eOeY78H9ZqWzVo3FSMl3ZhwUg6NUsEGXF4=; b=pcdJ4Tv4n81crXF0ARm6koWWdSPDovR7ElYzZO9Kxw70dmPLi7CYR1oMikdOaqI8GrUBVr xbry1c62x3TPu7o5btzpm4KNReEyotyHWdjfNr9vwp0J0Dp9Ak5l4virC4xifVJmeIVUDZ bNKpmpe3+GspHNhYWK26UQhMku9nBmzVKHQ5cFwaTQamFBfeAOyuRbcSHXZ+tLyd0wXa/2 Wp34hmnf8QcQApCsrxRuHamIrVtrisvSRmC0wTJc3sLdLtqUVwYsRuklWYxx8UCI6VWPx8 O8w74juOic/qEKuoDljjYLW02/Dbga/+1D0qW3dVTTn37mBYGlS4R5G7XflquQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642709335; a=rsa-sha256; cv=none; b=gcYbBNbF/c5uYS1Z1htsitP6RF3MkY8HOu9aUUllQfISzSc7uSVy4kEpkXo/sniYOmLfpf v4RuLiJ4CjXFPNZwaSRizNukOLzMA3CyDLGqXK7srT73zT8WBrUiOMLQlek2ygnp0coUjy OT0PXHbVlCSsdcpFBFMbN6xEABlv/+gWYZQj0iQKeG43Awb/XdA2NlANIlCr3mP8ba8rgO pz8FsNSKSYCqVDprzH08MlvhEe8r6v2QeHBAB5WXmqmfotKSDt0QRwoNDegie3lzQfdGYi 0jcs1Oadyyul/Ke9D2WmKr+ww6TvZLAkwzlJ84MoF7aQ2wcG4EzrnyTnQHHl6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=6d1a563281a9367eb288c3ecc74332e09bcd2b6b commit 6d1a563281a9367eb288c3ecc74332e09bcd2b6b Author: Kenneth D. Merry AuthorDate: 2022-01-13 15:50:40 +0000 Commit: Kenneth D. Merry CommitDate: 2022-01-20 20:06:59 +0000 Free UMA zones when a pass(4) instance goes away. If the UMA zones are not freed, we get warnings about re-using the sysctl variables associated with the UMA zones, and we're leaking the other memory associated with the zone structures. e.g.: sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.size)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.flags)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.bucket_size)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.bucket_size_max)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.name)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.rsize)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.ppera)! sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.ipers)! Also, correctly clear the PASS_FLAG_ZONE_INPROG flag in passcreatezone(). The way it was previously done, it would have had set the flag and cleared all other flags that were set at that point. Sponsored by: Spectra Logic (cherry picked from commit ca2a7262df5ec5fd07d4ac61738947f48c9cd7f2) --- sys/cam/scsi/scsi_pass.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index b91b0556f10b..965ac00539e1 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -398,6 +398,18 @@ passcleanup(struct cam_periph *periph) */ taskqueue_drain(taskqueue_thread, &softc->add_physpath_task); + /* + * It should be safe to destroy the zones from here, because all + * of the references to this peripheral have been freed, and all + * I/O has been terminated and freed. We check the zones for NULL + * because they may not have been allocated yet if the device went + * away before any asynchronous I/O has been issued. + */ + if (softc->pass_zone != NULL) + uma_zdestroy(softc->pass_zone); + if (softc->pass_io_zone != NULL) + uma_zdestroy(softc->pass_io_zone); + cam_periph_lock(periph); free(softc, M_DEVBUF); @@ -1076,7 +1088,7 @@ passcreatezone(struct cam_periph *periph) /* * Set the flags appropriately and notify any other waiters. */ - softc->flags &= PASS_FLAG_ZONE_INPROG; + softc->flags &= ~PASS_FLAG_ZONE_INPROG; softc->flags |= PASS_FLAG_ZONE_VALID; wakeup(&softc->pass_zone); } else {