From 741db5a3466236620612772319c3401171d3f2b6 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 4 Feb 2020 11:49:12 -0500 Subject: Prepare ks_data before calling kstat_install() It violated sequence described in kstat.h, and at least on FreeBSD kstat_install() uses provided names to create the sysctls. If the names are not available at the time, it ends up bad. Reviewed-by: Igor Kozhukhov Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Alexander Motin Sponsored-By: iXsystems, Inc. Closes #9933 --- module/zfs/dbuf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'module/zfs') diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index d460f9922..15a8641b9 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -850,10 +850,6 @@ retry: KSTAT_TYPE_NAMED, sizeof (dbuf_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL); if (dbuf_ksp != NULL) { - dbuf_ksp->ks_data = &dbuf_stats; - dbuf_ksp->ks_update = dbuf_kstat_update; - kstat_install(dbuf_ksp); - for (i = 0; i < DN_MAX_LEVELS; i++) { snprintf(dbuf_stats.cache_levels[i].name, KSTAT_STRLEN, "cache_level_%d", i); @@ -864,6 +860,9 @@ retry: dbuf_stats.cache_levels_bytes[i].data_type = KSTAT_DATA_UINT64; } + dbuf_ksp->ks_data = &dbuf_stats; + dbuf_ksp->ks_update = dbuf_kstat_update; + kstat_install(dbuf_ksp); } } -- cgit v1.2.3