svn commit: r348566 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Alexander Motin mav at FreeBSD.org
Mon Jun 3 19:00:25 UTC 2019


Author: mav
Date: Mon Jun  3 19:00:24 2019
New Revision: 348566
URL: https://svnweb.freebsd.org/changeset/base/348566

Log:
  MFC r348554: 9688 aggsum_fini leaks memory
  
  illumos/illumos-gate at 29bf2d68bef208274f5a54a14cc80c4a8cb76f53
  
  Reviewed by: Serapheim Dimitropoulos <serapheim.dimitro at delphix.com>
  Reviewed by: Matt Ahrens <matt at delphix.com>
  Reviewed by: Prashanth Sreenivasa <pks at delphix.com>
  Reviewed by: Jorgen Lundman <lundman at lundman.net>
  Reviewed by: Igor Kozhukhov <igor at dilos.org>
  Approved by: Robert Mustacchi <rm at joyent.com>
  Author:     Paul Dagnelie <pcd at delphix.com>

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c	Mon Jun  3 18:32:56 2019	(r348565)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c	Mon Jun  3 19:00:24 2019	(r348566)
@@ -13,7 +13,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright (c) 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2017, 2018 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -99,6 +99,7 @@ aggsum_fini(aggsum_t *as)
 {
 	for (int i = 0; i < as->as_numbuckets; i++)
 		mutex_destroy(&as->as_buckets[i].asc_lock);
+	kmem_free(as->as_buckets, as->as_numbuckets * sizeof (aggsum_bucket_t));
 	mutex_destroy(&as->as_lock);
 }
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Mon Jun  3 18:32:56 2019	(r348565)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c	Mon Jun  3 19:00:24 2019	(r348566)
@@ -7074,6 +7074,16 @@ arc_state_fini(void)
 	multilist_destroy(arc_mru_ghost->arcs_list[ARC_BUFC_DATA]);
 	multilist_destroy(arc_mfu->arcs_list[ARC_BUFC_DATA]);
 	multilist_destroy(arc_mfu_ghost->arcs_list[ARC_BUFC_DATA]);
+
+	aggsum_fini(&arc_meta_used);
+	aggsum_fini(&arc_size);
+	aggsum_fini(&astat_data_size);
+	aggsum_fini(&astat_metadata_size);
+	aggsum_fini(&astat_hdr_size);
+	aggsum_fini(&astat_bonus_size);
+	aggsum_fini(&astat_dnode_size);
+	aggsum_fini(&astat_dbuf_size);
+	aggsum_fini(&astat_l2_hdr_size);
 }
 
 uint64_t
@@ -7357,8 +7367,13 @@ arc_fini(void)
 	mutex_destroy(&arc_adjust_lock);
 	cv_destroy(&arc_adjust_waiters_cv);
 
-	arc_state_fini();
+	/*
+	 * buf_fini() must proceed arc_state_fini() because buf_fin() may
+	 * trigger the release of kmem magazines, which can callback to
+	 * arc_space_return() which accesses aggsums freed in act_state_fini().
+	 */
 	buf_fini();
+	arc_state_fini();
 
 	ASSERT0(arc_loaned_bytes);
 }


More information about the svn-src-all mailing list