]> granicus.if.org Git - zfs/commitdiff
Allow longer SPA names in stats
authorgaurkuma <gaurkuma@users.noreply.github.com>
Fri, 11 Aug 2017 15:53:35 +0000 (08:53 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 11 Aug 2017 15:53:35 +0000 (08:53 -0700)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: gaurkuma <gauravk.18@gmail.com>
Closes #641

include/sys/kstat.h
module/spl/spl-kstat.c

index faf6b81dabfe95ed3418793a972fdc929ef51e27..7862ab0a3d0328326bd87aff5fbd5113b7a3e2e8 100644 (file)
@@ -32,7 +32,7 @@
 #include <sys/kmem.h>
 #include <sys/mutex.h>
 
-#define KSTAT_STRLEN            31
+#define KSTAT_STRLEN            255
 #define KSTAT_RAW_MAX          (128*1024)
 
 /* For reference valid classes are:
index 1b6a7df9b34858cf4bc3d256da7770588c75685f..3765f63cb8cd1000327e0491cf71524383a4b761 100644 (file)
@@ -614,21 +614,26 @@ kstat_detect_collision(kstat_t *ksp)
 {
        kstat_module_t *module;
        kstat_t *tmp;
-       char parent[KSTAT_STRLEN+1];
+       char *parent;
        char *cp;
 
-       (void) strlcpy(parent, ksp->ks_module, sizeof(parent));
+       parent = kmem_asprintf("%s", ksp->ks_module);
 
-       if ((cp = strrchr(parent, '/')) == NULL)
+       if ((cp = strrchr(parent, '/')) == NULL) {
+               strfree(parent);
                return (0);
+       }
 
        cp[0] = '\0';
        if ((module = kstat_find_module(parent)) != NULL) {
                list_for_each_entry(tmp, &module->ksm_kstat_list, ks_list)
-                       if (strncmp(tmp->ks_name, cp+1, KSTAT_STRLEN) == 0)
+                       if (strncmp(tmp->ks_name, cp+1, KSTAT_STRLEN) == 0) {
+                               strfree(parent);
                                return (EEXIST);
+                       }
        }
 
+       strfree(parent);
        return (0);
 }