From ae3d8491427343904c66d69ba94731553727eb26 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Wed, 23 May 2018 10:32:31 -0700 Subject: [PATCH] OpenZFS 9688 - aggsum_fini leaks memory Porting Notes: - Most of these fixes were applied in the original 37fb3e43 commit when this change was ported for Linux. Authored by: Paul Dagnelie Reviewed by: Serapheim Dimitropoulos Reviewed by: Matt Ahrens Reviewed by: Prashanth Sreenivasa Reviewed by: Jorgen Lundman Reviewed by: Igor Kozhukhov Reviewed by: George Melikov Approved by: Robert Mustacchi Ported-by: Brian Behlendorf OpenZFS-issue: https://www.illumos.org/issues/9688 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/29bf2d68be Closes #8042 --- module/zfs/aggsum.c | 2 +- module/zfs/arc.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/module/zfs/aggsum.c b/module/zfs/aggsum.c index 8d310e004..ace3a83a5 100644 --- a/module/zfs/aggsum.c +++ b/module/zfs/aggsum.c @@ -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 diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 07612468d..96557054c 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -7845,8 +7845,13 @@ arc_fini(void) cv_destroy(&arc_reclaim_thread_cv); cv_destroy(&arc_reclaim_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); }