#include <linux/seq_file.h>
#include <sys/kstat.h>
-#include <spl-debug.h>
+#include <sys/vmem.h>
+#include <sys/cmn_err.h>
-#ifdef SS_DEBUG_SUBSYS
-#undef SS_DEBUG_SUBSYS
-#endif
-
-#define SS_DEBUG_SUBSYS SS_KSTAT
#ifndef HAVE_PDE_DATA
#define PDE_DATA(x) (PDE(x)->data)
#endif
kstat_seq_data_addr(kstat_t *ksp, loff_t n)
{
void *rc = NULL;
- SENTRY;
switch (ksp->ks_type) {
case KSTAT_TYPE_RAW:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}
- SRETURN(rc);
+ return (rc);
}
static void *
loff_t n = *pos;
kstat_t *ksp = (kstat_t *)f->private;
ASSERT(ksp->ks_magic == KS_MAGIC);
- SENTRY;
mutex_enter(ksp->ks_lock);
ksp->ks_snaptime = gethrtime();
if (!n && kstat_seq_show_headers(f))
- SRETURN(NULL);
+ return (NULL);
if (n >= ksp->ks_ndata)
- SRETURN(NULL);
+ return (NULL);
- SRETURN(kstat_seq_data_addr(ksp, n));
+ return (kstat_seq_data_addr(ksp, n));
}
static void *
{
kstat_t *ksp = (kstat_t *)f->private;
ASSERT(ksp->ks_magic == KS_MAGIC);
- SENTRY;
++*pos;
if (*pos >= ksp->ks_ndata)
- SRETURN(NULL);
+ return (NULL);
- SRETURN(kstat_seq_data_addr(ksp, *pos));
+ return (kstat_seq_data_addr(ksp, *pos));
}
static void
}
EXPORT_SYMBOL(__kstat_create);
+static int
+kstat_detect_collision(kstat_t *ksp)
+{
+ kstat_module_t *module;
+ kstat_t *tmp;
+ char parent[KSTAT_STRLEN+1];
+ char *cp;
+
+ (void) strlcpy(parent, ksp->ks_module, sizeof(parent));
+
+ if ((cp = strrchr(parent, '/')) == NULL)
+ 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)
+ return (EEXIST);
+ }
+
+ return (0);
+}
+
void
__kstat_install(kstat_t *ksp)
{
module = kstat_find_module(ksp->ks_module);
if (module == NULL) {
+ if (kstat_detect_collision(ksp) != 0) {
+ cmn_err(CE_WARN, "kstat_create('%s', '%s'): namespace" \
+ " collision", ksp->ks_module, ksp->ks_name);
+ goto out;
+ }
module = kstat_create_module(ksp->ks_module);
if (module == NULL)
goto out;
int
spl_kstat_init(void)
{
- SENTRY;
mutex_init(&kstat_module_lock, NULL, MUTEX_DEFAULT, NULL);
INIT_LIST_HEAD(&kstat_module_list);
kstat_id = 0;
- SRETURN(0);
+ return (0);
}
void
spl_kstat_fini(void)
{
- SENTRY;
ASSERT(list_empty(&kstat_module_list));
mutex_destroy(&kstat_module_lock);
- SEXIT;
}