* UCRL-CODE-235197
*
* This file is part of the SPL, Solaris Porting Layer.
- * For details, see <http://github.com/behlendorf/spl/>.
+ * For details, see <http://zfsonlinux.org/>.
*
* The SPL is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
#ifndef _SPLAT_INTERNAL_H
#define _SPLAT_INTERNAL_H
-#include "spl-device.h"
-#include "spl-debug.h"
#include "splat-ctl.h"
-
-#define SPLAT_SUBSYSTEM_INIT(type) \
-({ splat_subsystem_t *_sub_; \
- \
- _sub_ = (splat_subsystem_t *)splat_##type##_init(); \
- if (_sub_ == NULL) { \
- printk(KERN_ERR "splat: Error initializing: " #type "\n"); \
- } else { \
- spin_lock(&splat_module_lock); \
- list_add_tail(&(_sub_->subsystem_list), \
- &splat_module_list); \
- spin_unlock(&splat_module_lock); \
- } \
-})
-
-#define SPLAT_SUBSYSTEM_FINI(type) \
-({ splat_subsystem_t *_sub_, *_tmp_; \
- int _id_, _flag_ = 0; \
- \
- _id_ = splat_##type##_id(); \
- spin_lock(&splat_module_lock); \
- list_for_each_entry_safe(_sub_, _tmp_, &splat_module_list, \
- subsystem_list) { \
- if (_sub_->desc.id == _id_) { \
- list_del_init(&(_sub_->subsystem_list)); \
- spin_unlock(&splat_module_lock); \
- splat_##type##_fini(_sub_); \
- spin_lock(&splat_module_lock); \
- _flag_ = 1; \
- } \
- } \
- spin_unlock(&splat_module_lock); \
- \
- if (!_flag_) \
- printk(KERN_ERR "splat: Error finalizing: " #type "\n"); \
-})
-
-#define SPLAT_TEST_INIT(sub, n, d, tid, func) \
-({ splat_test_t *_test_; \
- \
- _test_ = (splat_test_t *)kmalloc(sizeof(*_test_), GFP_KERNEL); \
- if (_test_ == NULL) { \
- printk(KERN_ERR "splat: Error initializing: " n "/" #tid" \n");\
- } else { \
- memset(_test_, 0, sizeof(*_test_)); \
- strncpy(_test_->desc.name, n, SPLAT_NAME_SIZE-1); \
- strncpy(_test_->desc.desc, d, SPLAT_DESC_SIZE-1); \
- _test_->desc.id = tid; \
- _test_->test = func; \
- INIT_LIST_HEAD(&(_test_->test_list)); \
- spin_lock(&((sub)->test_lock)); \
- list_add_tail(&(_test_->test_list),&((sub)->test_list));\
- spin_unlock(&((sub)->test_lock)); \
- } \
-})
-
-#define SPLAT_TEST_FINI(sub, tid) \
-({ splat_test_t *_test_, *_tmp_; \
- int _flag_ = 0; \
- \
- spin_lock(&((sub)->test_lock)); \
- list_for_each_entry_safe(_test_, _tmp_, \
- &((sub)->test_list), test_list) { \
- if (_test_->desc.id == tid) { \
- list_del_init(&(_test_->test_list)); \
- _flag_ = 1; \
- } \
- } \
- spin_unlock(&((sub)->test_lock)); \
- \
- if (!_flag_) \
- printk(KERN_ERR "splat: Error finalizing: " #tid "\n"); \
-})
+#include <sys/mutex.h>
+#include <linux/file_compat.h>
+#include <linux/version.h>
typedef int (*splat_test_func_t)(struct file *, void *);
struct list_head test_list;
} splat_subsystem_t;
+void splat_test_init(splat_subsystem_t *sub, const char *name,
+ const char *desc, unsigned int tid, splat_test_func_t func);
+void splat_test_fini(splat_subsystem_t *sub, unsigned int tid);
+
#define SPLAT_INFO_BUFFER_SIZE 65536
#define SPLAT_INFO_BUFFER_REDZONE 256
typedef struct splat_info {
- spinlock_t info_lock;
+ kmutex_t info_lock;
int info_size;
char *info_buffer;
char *info_head; /* Internal kernel use only */
ASSERT(_info_); \
ASSERT(_info_->info_buffer); \
\
- spin_lock(&_info_->info_lock); \
+ mutex_enter(&_info_->info_lock); \
\
/* Don't allow the kernel to start a write in the red zone */ \
if ((int)(_info_->info_head - _info_->info_buffer) > \
_info_->info_head += _rc_; \
} \
\
- spin_unlock(&_info_->info_lock); \
+ mutex_exit(&_info_->info_lock); \
_rc_; \
})