Skip to content

Commit

Permalink
add destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed May 10, 2022
1 parent aa77c28 commit 657d6e0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions module/zfs/spa_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,19 +819,11 @@ spa_state_init(spa_t *spa)
kmem_strfree(name);
}

static void *
spa_guid_addr(kstat_t *ksp, loff_t n)
{
if (n == 0)
return (ksp->ks_private);
return (NULL);
}

static int
spa_guid_data(char *buf, size_t size, void *data)
{
spa_t *spa = (spa_t *)data;
(void) snprintf(buf, size, "%llu\n", spa_guid(spa));
(void) snprintf(buf, size, "%lu\n", spa_guid(spa));
return (0);
}

Expand All @@ -853,7 +845,7 @@ spa_guid_init(spa_t *spa)
ksp->ks_data = NULL;
ksp->ks_private = spa;
ksp->ks_flags |= KSTAT_FLAG_NO_HEADERS;
kstat_set_raw_ops(ksp, NULL, spa_guid_data, spa_guid_addr);
kstat_set_raw_ops(ksp, NULL, spa_guid_data, spa_state_addr);
kstat_install(ksp);
}

Expand All @@ -871,6 +863,17 @@ spa_health_destroy(spa_t *spa)
mutex_destroy(&shk->lock);
}

static void
spa_guid_destroy(spa_t *spa)
{
spa_history_kstat_t *shk = &spa->spa_stats.guid;
kstat_t *ksp = shk->kstat;
if (ksp)
kstat_delete(ksp);

mutex_destroy(&shk->lock);
}

static spa_iostats_t spa_iostats_template = {
{ "trim_extents_written", KSTAT_DATA_UINT64 },
{ "trim_bytes_written", KSTAT_DATA_UINT64 },
Expand Down Expand Up @@ -1004,6 +1007,7 @@ spa_stats_destroy(spa_t *spa)
spa_txg_history_destroy(spa);
spa_read_history_destroy(spa);
spa_mmp_history_destroy(spa);
spa_guid_destroy(spa);
}

/* BEGIN CSTYLED */
Expand Down

0 comments on commit 657d6e0

Please sign in to comment.