Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jan 2022 20:08:54 GMT
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 6d1a563281a9 - stable/12 - Free UMA zones when a pass(4) instance goes away.
Message-ID:  <202201202008.20KK8sGF094302@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by ken:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d1a563281a9367eb288c3ecc74332e09bcd2b6b

commit 6d1a563281a9367eb288c3ecc74332e09bcd2b6b
Author:     Kenneth D. Merry <ken@FreeBSD.org>
AuthorDate: 2022-01-13 15:50:40 +0000
Commit:     Kenneth D. Merry <ken@FreeBSD.org>
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 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201202008.20KK8sGF094302>