From nobody Thu Jan 20 20:06:25 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 CF8091971445; Thu, 20 Jan 2022 20:06:25 +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 4JftnF5HFPz3pF3; Thu, 20 Jan 2022 20:06:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642709185; 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=eqi+5cQ4NR6XSrNRTOgud4tQmPkxjGvU66H88p4lprw=; b=XP+CoueTGG2JjZ+pwk7GFuQQ0vR1hpFtcwiuZhk+bpQJxw33Mp8ARo8Q9T6vQT4L9SnoqA ghuNA3gDvNVV07mihPFGPSU1XhB/YQM/0Z2DlVZ1dI+pM5wg1bYbTpTuYfBSVy4ZTcJdqx bHmIFGCBZ2/mDE6clzKkZ9TfA4vPmeB+iXU+IdU7wKDgjvRdcUDWdv6rMdp4OXJzHPRbsQ /oin6QoTRC+UzqI3ivCrCeeGM5riSggsUXbVDFF9CwY0Z1GAARRrpa9LMKarXZnLuGw5zp Llt2gBZo5WTPnmylozdx3OcMbnnESISTy9ApNq42DVmeB6ei0gvzFbFO4dYX9Q== 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 8C4D768B1; Thu, 20 Jan 2022 20:06:25 +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 20KK6Pwo094036; Thu, 20 Jan 2022 20:06:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20KK6PPh094035; Thu, 20 Jan 2022 20:06:25 GMT (envelope-from git) Date: Thu, 20 Jan 2022 20:06:25 GMT Message-Id: <202201202006.20KK6PPh094035@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: 2077f85a63f2 - stable/13 - Free UMA zones when a pass(4) instance goes away. 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: ken X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2077f85a63f2855fd0e1658d3655b60302db6ebd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642709185; 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=eqi+5cQ4NR6XSrNRTOgud4tQmPkxjGvU66H88p4lprw=; b=Xi5Sa55k3KXIR7CEYTuwGj71be5BFh1SIJ7ygn04PbAsysvvo4D6FdtBcbLlem97uL3GfV cpq0V5Gm24AB5Okqgndl63P9//MVnL+2ZzV9GFZ6uWldUirmX9K/8F/+TNRRF3JSjdsB+n Lv4yHm07izN5Jk/mPy+spyUf3xgV+5b5r8eTQ2i5S/+JFbb1oy4PnpRSbwyarz5PbjqRNm rBa53lcdt519t0/vhwYtK6U8rR29XPdcEKowqW6kaI3QlFMNz44Drpb4xQ4eyLTk6ntm3C 7qlqrEvRqak0u17deME60zj9JFlNZWHFCDaPbBnFryzuuQYOcOeDalzQAVWqAw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642709185; a=rsa-sha256; cv=none; b=SY+BlZnNBraQI55aM/EahxYnEk1ZAYcIkol9dE/anH71hj5joeLpOfWGBQjj9eVTRHVNFt /UsYrDpuabLcsuEwgR+p5bunSjoT+rto66q8RkNjylm49Mep8KQRBsFNAKPP7CJgAj2Vby dKEd+yR3hI4kdWde8wbHN2bB5jUuV8S7R1N7hp0aVlWTgF2lRL/hPqQ/wIotnMMjXs2/eo U57HY+47OrJbLw4+HMO9N1E3WtR1etEXOhHWEgcPNwXeN0XpXlT2J2rCAMrbwqskP02hqN g7VP67dB6NrqmK7yPwk8MUt0md+LxKTJpiDwj+0jKaN9n4ix7EPku8wY6NQtNQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by ken: URL: https://cgit.FreeBSD.org/src/commit/?id=2077f85a63f2855fd0e1658d3655b60302db6ebd commit 2077f85a63f2855fd0e1658d3655b60302db6ebd Author: Kenneth D. Merry AuthorDate: 2022-01-13 15:50:40 +0000 Commit: Kenneth D. Merry CommitDate: 2022-01-20 19:55:04 +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 456eff641776..e9751e26d8ca 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); @@ -1074,7 +1086,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 {