mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-27 10:24:22 +03:00
Add basic dynamic kstat support
Add the bare minimum functionality to support dynamic kstats. A complete kstat implementation should be done as part of issue #84. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #84
This commit is contained in:
parent
4b2220f0b9
commit
9a8b7a7458
@ -72,7 +72,14 @@
|
|||||||
|
|
||||||
#define KS_MAGIC 0x9d9d9d9d
|
#define KS_MAGIC 0x9d9d9d9d
|
||||||
|
|
||||||
typedef int kid_t; /* unique kstat id */
|
/* Dynamic updates */
|
||||||
|
#define KSTAT_READ 0
|
||||||
|
#define KSTAT_WRITE 1
|
||||||
|
|
||||||
|
struct kstat_s;
|
||||||
|
|
||||||
|
typedef int kid_t; /* unique kstat id */
|
||||||
|
typedef int kstat_update_t(struct kstat_s *, int); /* dynamic update cb */
|
||||||
|
|
||||||
typedef struct kstat_s {
|
typedef struct kstat_s {
|
||||||
int ks_magic; /* magic value */
|
int ks_magic; /* magic value */
|
||||||
@ -89,6 +96,8 @@ typedef struct kstat_s {
|
|||||||
uint_t ks_ndata; /* # of type-specific data records */
|
uint_t ks_ndata; /* # of type-specific data records */
|
||||||
size_t ks_data_size; /* size of kstat data section */
|
size_t ks_data_size; /* size of kstat data section */
|
||||||
struct proc_dir_entry *ks_proc; /* proc linkage */
|
struct proc_dir_entry *ks_proc; /* proc linkage */
|
||||||
|
kstat_update_t *ks_update; /* dynamic updates */
|
||||||
|
void *ks_private; /* private data */
|
||||||
spinlock_t ks_lock; /* kstat data lock */
|
spinlock_t ks_lock; /* kstat data lock */
|
||||||
struct list_head ks_list; /* kstat linkage */
|
struct list_head ks_list; /* kstat linkage */
|
||||||
} kstat_t;
|
} kstat_t;
|
||||||
|
@ -223,6 +223,13 @@ kstat_seq_show(struct seq_file *f, void *p)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
kstat_default_update(kstat_t *ksp, int rw)
|
||||||
|
{
|
||||||
|
ASSERT(ksp != NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
kstat_seq_data_addr(kstat_t *ksp, loff_t n)
|
kstat_seq_data_addr(kstat_t *ksp, loff_t n)
|
||||||
{
|
{
|
||||||
@ -260,6 +267,9 @@ kstat_seq_start(struct seq_file *f, loff_t *pos)
|
|||||||
ASSERT(ksp->ks_magic == KS_MAGIC);
|
ASSERT(ksp->ks_magic == KS_MAGIC);
|
||||||
SENTRY;
|
SENTRY;
|
||||||
|
|
||||||
|
/* Dynamically update kstat, on error existing kstats are used */
|
||||||
|
(void) ksp->ks_update(ksp, KSTAT_READ);
|
||||||
|
|
||||||
spin_lock(&ksp->ks_lock);
|
spin_lock(&ksp->ks_lock);
|
||||||
ksp->ks_snaptime = gethrtime();
|
ksp->ks_snaptime = gethrtime();
|
||||||
|
|
||||||
@ -361,6 +371,8 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
|
|||||||
strncpy(ksp->ks_class, ks_class, KSTAT_STRLEN);
|
strncpy(ksp->ks_class, ks_class, KSTAT_STRLEN);
|
||||||
ksp->ks_type = ks_type;
|
ksp->ks_type = ks_type;
|
||||||
ksp->ks_flags = ks_flags;
|
ksp->ks_flags = ks_flags;
|
||||||
|
ksp->ks_update = kstat_default_update;
|
||||||
|
ksp->ks_private = NULL;
|
||||||
|
|
||||||
switch (ksp->ks_type) {
|
switch (ksp->ks_type) {
|
||||||
case KSTAT_TYPE_RAW:
|
case KSTAT_TYPE_RAW:
|
||||||
|
Loading…
Reference in New Issue
Block a user