diff options
author | Cyril Plisko <[email protected]> | 2013-08-13 15:15:36 +0300 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-10-25 13:41:30 -0700 |
commit | ffbf0e57c2ad9e72ab437c7982f443926cb26325 (patch) | |
tree | c74e4f1fa1d132259d819483481d048b0cd793e9 /include | |
parent | ce07767f79c926acdbdf7bb272f05e89820f31c3 (diff) |
Kstat to use private lock by default
While porting Illumos #3537 I found that ks_lock member of kstat_t
structure is different between Illumos and SPL. It is a pointer to
the kmutex_t in Illumos, but the mutex lock itself in SPL.
Apparently Illumos kstat API allows consumer to override the lock
if required. With SPL implementation it is not possible anymore.
Things were alright until the first attempt to actually override
the lock. Porting of Illumos #3537 introduced such code for the
first time.
In order to provide the Solaris/Illumos like functionality we:
1. convert ks_lock to "kmutex_t *ks_lock"
2. create a new field "kmutex_t ks_private_lock"
3. On kstat_create() ks_lock = &ks_private_lock
Thus if consumer doesn't care we still have our internal lock in use.
If, however, consumer does care she has a chance to set ks_lock to
anything else before calling kstat_install().
The rest of the code will use ks_lock regardless of its origin.
Signed-off-by: Ned Bass <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #286
Diffstat (limited to 'include')
-rw-r--r-- | include/sys/kstat.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/sys/kstat.h b/include/sys/kstat.h index 6e3c0cdfe..97d8596f7 100644 --- a/include/sys/kstat.h +++ b/include/sys/kstat.h @@ -114,7 +114,8 @@ struct kstat_s { struct proc_dir_entry *ks_proc; /* proc linkage */ kstat_update_t *ks_update; /* dynamic updates */ void *ks_private; /* private data */ - kmutex_t ks_lock; /* kstat data lock */ + kmutex_t ks_private_lock; /* kstat private data lock */ + kmutex_t *ks_lock; /* kstat data lock */ struct list_head ks_list; /* kstat linkage */ kstat_module_t *ks_owner; /* kstat module linkage */ kstat_raw_ops_t ks_raw_ops; /* ops table for raw type */ |