Skip to content

Commit

Permalink
Allow longer SPA names in stats
Browse files Browse the repository at this point in the history
The pool name can be 256 chars long. Today, in /proc/spl/kstat/zfs/
the name is limited to < 32 characters. This change is to allows
bigger pool names.

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: gaurkuma <gauravk.18@gmail.com>
Closes openzfs#6481
  • Loading branch information
gaurkuma authored and FransUrbo committed Apr 28, 2019
1 parent d150055 commit 26628e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/libspl/include/sys/kstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef int kid_t; /* unique kstat id */
* kcid = ioctl(kd, KSTAT_IOC_WRITE, kstat_t *);
*/

#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */
#define KSTAT_STRLEN 255 /* 254 chars + NULL; must be 16 * n - 1 */

/*
* The generic kstat header
Expand Down
11 changes: 6 additions & 5 deletions module/icp/spi/kcf_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int
crypto_register_provider(crypto_provider_info_t *info,
crypto_kcf_provider_handle_t *handle)
{
char ks_name[KSTAT_STRLEN];
char *ks_name;

kcf_provider_desc_t *prov_desc = NULL;
int ret = CRYPTO_ARGUMENTS_BAD;
Expand Down Expand Up @@ -238,12 +238,12 @@ crypto_register_provider(crypto_provider_info_t *info,
* This kstat is deleted, when the provider unregisters.
*/
if (prov_desc->pd_prov_type == CRYPTO_SW_PROVIDER) {
(void) snprintf(ks_name, KSTAT_STRLEN, "%s_%s",
ks_name = kmem_asprintf("%s_%s",
"NONAME", "provider_stats");
} else {
(void) snprintf(ks_name, KSTAT_STRLEN, "%s_%d_%u_%s",
"NONAME", 0,
prov_desc->pd_prov_id, "provider_stats");
ks_name = kmem_asprintf("%s_%d_%u_%s",
"NONAME", 0, prov_desc->pd_prov_id,
"provider_stats");
}

prov_desc->pd_kstat = kstat_create("kcf", 0, ks_name, "crypto",
Expand All @@ -261,6 +261,7 @@ crypto_register_provider(crypto_provider_info_t *info,
prov_desc->pd_kstat->ks_update = kcf_prov_kstat_update;
kstat_install(prov_desc->pd_kstat);
}
strfree(ks_name);
}

if (prov_desc->pd_prov_type == CRYPTO_HW_PROVIDER)
Expand Down
25 changes: 15 additions & 10 deletions module/zfs/spa_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void
spa_read_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.read_history;
char name[KSTAT_STRLEN];
char *name;
kstat_t *ksp;

mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
Expand All @@ -155,7 +155,7 @@ spa_read_history_init(spa_t *spa)
ssh->size = 0;
ssh->private = NULL;

(void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
name = kmem_asprintf("zfs/%s", spa_name(spa));

ksp = kstat_create(name, 0, "reads", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
Expand All @@ -170,6 +170,7 @@ spa_read_history_init(spa_t *spa)
spa_read_history_data, spa_read_history_addr);
kstat_install(ksp);
}
strfree(name);
}

static void
Expand Down Expand Up @@ -367,7 +368,7 @@ static void
spa_txg_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.txg_history;
char name[KSTAT_STRLEN];
char *name;
kstat_t *ksp;

mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
Expand All @@ -378,7 +379,7 @@ spa_txg_history_init(spa_t *spa)
ssh->size = 0;
ssh->private = NULL;

(void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
name = kmem_asprintf("zfs/%s", spa_name(spa));

ksp = kstat_create(name, 0, "txgs", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
Expand All @@ -393,6 +394,7 @@ spa_txg_history_init(spa_t *spa)
spa_txg_history_data, spa_txg_history_addr);
kstat_install(ksp);
}
strfree(name);
}

static void
Expand Down Expand Up @@ -600,7 +602,7 @@ static void
spa_tx_assign_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.tx_assign_histogram;
char name[KSTAT_STRLEN];
char *name;
kstat_named_t *ks;
kstat_t *ksp;
int i;
Expand All @@ -611,7 +613,7 @@ spa_tx_assign_init(spa_t *spa)
ssh->size = ssh->count * sizeof (kstat_named_t);
ssh->private = kmem_alloc(ssh->size, KM_SLEEP);

(void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
name = kmem_asprintf("zfs/%s", spa_name(spa));

for (i = 0; i < ssh->count; i++) {
ks = &((kstat_named_t *)ssh->private)[i];
Expand All @@ -634,6 +636,7 @@ spa_tx_assign_init(spa_t *spa)
ksp->ks_update = spa_tx_assign_update;
kstat_install(ksp);
}
strfree(name);
}

static void
Expand Down Expand Up @@ -680,12 +683,12 @@ static void
spa_io_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.io_history;
char name[KSTAT_STRLEN];
char *name;
kstat_t *ksp;

mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);

(void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
name = kmem_asprintf("zfs/%s", spa_name(spa));

ksp = kstat_create(name, 0, "io", "disk", KSTAT_TYPE_IO, 1, 0);
ssh->kstat = ksp;
Expand All @@ -696,6 +699,7 @@ spa_io_history_init(spa_t *spa)
ksp->ks_update = spa_io_history_update;
kstat_install(ksp);
}
strfree(name);
}

static void
Expand Down Expand Up @@ -825,7 +829,7 @@ static void
spa_mmp_history_init(spa_t *spa)
{
spa_stats_history_t *ssh = &spa->spa_stats.mmp_history;
char name[KSTAT_STRLEN];
char *name;
kstat_t *ksp;

mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL);
Expand All @@ -836,7 +840,7 @@ spa_mmp_history_init(spa_t *spa)
ssh->size = 0;
ssh->private = NULL;

(void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa));
name = kmem_asprintf("zfs/%s", spa_name(spa));

ksp = kstat_create(name, 0, "multihost", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
Expand All @@ -851,6 +855,7 @@ spa_mmp_history_init(spa_t *spa)
spa_mmp_history_data, spa_mmp_history_addr);
kstat_install(ksp);
}
strfree(name);
}

static void
Expand Down

0 comments on commit 26628e4

Please sign in to comment.