From nobody Thu Jan 13 15:56:39 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 ABB86195D651; Thu, 13 Jan 2022 15:56:42 +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 4JZTZK44Tdz3msN; Thu, 13 Jan 2022 15:56:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642089402; 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=blOtC+JphGIqL37ZF8q8Sn+3Y7PfMCYilBG4ZB5CMnM=; b=pnPvtLh5QY4FJCMHU9a52HpxCrg7snLScUS+S6q3OdtaatWeN228HZgD1oiT/9XPVVbs0p /MaH47lv6uO9/nYpTeuMHMi/qpCugS22wP06bWGbWHg/MD5hu9hltbJjA7dWD24XVNaJid isDkDvYYyW7Hg5TNlMfGcfF5HiRS3Hxx2qjhyCdpNdxs2XVamWphu/2UV0Q01kf5D45Jyr C1ahbdGRrfloyMQR0/j8NBa1o8P76HGd+0mQsPVfCkKAy7Ch31T5JNxLIqHEAigHyzeu4d vNSeRVky214xjeAME5GEbm6Du+V46j3H61aTA5U36R5cl8jo7tT68D50fDbD5w== 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 86BA5231E6; Thu, 13 Jan 2022 15:56:39 +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 20DFudUM088872; Thu, 13 Jan 2022 15:56:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20DFud7f088871; Thu, 13 Jan 2022 15:56:39 GMT (envelope-from git) Date: Thu, 13 Jan 2022 15:56:39 GMT Message-Id: <202201131556.20DFud7f088871@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Kenneth D. Merry" Subject: git: ca2a7262df5e - main - 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/main X-Git-Reftype: branch X-Git-Commit: ca2a7262df5ec5fd07d4ac61738947f48c9cd7f2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642089402; 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=blOtC+JphGIqL37ZF8q8Sn+3Y7PfMCYilBG4ZB5CMnM=; b=Gu0pQBHIWC7vMj1AIHjRHlf1tM5qocBXib9COsgre2kVPtPxmQ+CvUNaaHUi53Y7LZqOaz k9FFYuGOvRy+PaeBSAK4iJXT5gHWfdZaALRa2i5/r36vChinVZg40CBxzIg0YEAVhXnzfC F+l6O1Iar+aUgOl9os0GuNQGjv3jPs3+3DpXakFwq1i7Dr26A74uCZiRpiIcg46ZvHmG/s B8teCE5JCDU6JmdnVKa2Zv8VDnc1ALy1zmMm8VGu+RXJ7JlyKbbo7Q4EyQdUGHLlru68jn iRFiB8Iave0SPnlloAMFtWtdoKJX1u9Ea9cNdCmOnyzcAIPRVLRuZIOZomIYXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642089402; a=rsa-sha256; cv=none; b=y4CyHVbyjgDYxclkH3kb7TKhV2s2NO4zE/6hSlk4zKPWraXzayLr1eH1Won+qr48dF2ro3 hU01rMFNR0j+DPFt2btTNYwvsak54E+3kn4+8Nkis0+veqPBelVYwx5XT9m+3Eh+hd2VPD k7oUBQx2InELiyaEM/3wRz/FHvVvNYI+cWI+3Mj7NinYCYSeAyLnCd1KtMh2FtrFjDm/uB 6Gvx93iV4p9ms9QnkgWWP2Mhf3kgeeNfTluqrfKqq3+t9mKyB9hXvoDWSL+LVAeLrIhwrF tBBgszGdcd+JFAD62pUIqwhh8MET+5hiAhOjjKzWAR5vddd/2yfXeIGVe7hrUw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=ca2a7262df5ec5fd07d4ac61738947f48c9cd7f2 commit ca2a7262df5ec5fd07d4ac61738947f48c9cd7f2 Author: Kenneth D. Merry AuthorDate: 2022-01-13 15:50:40 +0000 Commit: Kenneth D. Merry CommitDate: 2022-01-13 15:54:56 +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. MFC after: 1 week Sponsored by: Spectra Logic --- 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 5d6febe74539..e74e19acc409 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -397,6 +397,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); @@ -1073,7 +1085,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 {