2017-10-04 19:33:43 +03:00
|
|
|
/*
|
2010-05-18 02:18:00 +04:00
|
|
|
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Copyright (C) 2007 The Regents of the University of California.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
2008-05-26 08:38:26 +04:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
2013-03-05 05:26:55 +04:00
|
|
|
* For details, see <http://zfsonlinux.org/>.
|
2010-05-18 02:18:00 +04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
2008-05-26 08:38:26 +04:00
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 08:38:26 +04:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2010-05-18 02:18:00 +04:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-04 19:33:43 +03:00
|
|
|
*/
|
2008-05-26 08:38:26 +04:00
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
#ifndef _SPLAT_INTERNAL_H
|
|
|
|
#define _SPLAT_INTERNAL_H
|
|
|
|
|
2008-02-28 03:48:31 +03:00
|
|
|
#include "splat-ctl.h"
|
2014-09-30 02:00:46 +04:00
|
|
|
#include <sys/mutex.h>
|
2014-12-08 21:04:42 +03:00
|
|
|
#include <linux/file_compat.h>
|
2015-08-20 00:48:21 +03:00
|
|
|
#include <linux/version.h>
|
2008-02-28 02:42:31 +03:00
|
|
|
|
|
|
|
typedef int (*splat_test_func_t)(struct file *, void *);
|
|
|
|
|
|
|
|
typedef struct splat_test {
|
|
|
|
struct list_head test_list;
|
|
|
|
splat_user_t desc;
|
|
|
|
splat_test_func_t test;
|
|
|
|
} splat_test_t;
|
|
|
|
|
|
|
|
typedef struct splat_subsystem {
|
|
|
|
struct list_head subsystem_list;/* List had to chain entries */
|
|
|
|
splat_user_t desc;
|
|
|
|
spinlock_t test_lock;
|
|
|
|
struct list_head test_list;
|
|
|
|
} splat_subsystem_t;
|
|
|
|
|
2016-12-15 05:24:47 +03:00
|
|
|
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);
|
|
|
|
|
2008-02-28 02:42:31 +03:00
|
|
|
#define SPLAT_INFO_BUFFER_SIZE 65536
|
|
|
|
#define SPLAT_INFO_BUFFER_REDZONE 256
|
|
|
|
|
|
|
|
typedef struct splat_info {
|
2014-09-30 02:00:46 +04:00
|
|
|
kmutex_t info_lock;
|
2008-02-28 02:42:31 +03:00
|
|
|
int info_size;
|
|
|
|
char *info_buffer;
|
|
|
|
char *info_head; /* Internal kernel use only */
|
|
|
|
} splat_info_t;
|
|
|
|
|
|
|
|
#define sym2str(sym) (char *)(#sym)
|
|
|
|
|
|
|
|
#define splat_print(file, format, args...) \
|
2008-05-07 00:38:28 +04:00
|
|
|
({ splat_info_t *_info_ = (splat_info_t *)file->private_data; \
|
2008-02-28 02:42:31 +03:00
|
|
|
int _rc_; \
|
|
|
|
\
|
|
|
|
ASSERT(_info_); \
|
|
|
|
ASSERT(_info_->info_buffer); \
|
|
|
|
\
|
2014-09-30 02:00:46 +04:00
|
|
|
mutex_enter(&_info_->info_lock); \
|
2008-02-28 02:42:31 +03:00
|
|
|
\
|
|
|
|
/* Don't allow the kernel to start a write in the red zone */ \
|
|
|
|
if ((int)(_info_->info_head - _info_->info_buffer) > \
|
|
|
|
(SPLAT_INFO_BUFFER_SIZE - SPLAT_INFO_BUFFER_REDZONE)) { \
|
|
|
|
_rc_ = -EOVERFLOW; \
|
|
|
|
} else { \
|
|
|
|
_rc_ = sprintf(_info_->info_head, format, args); \
|
|
|
|
if (_rc_ >= 0) \
|
|
|
|
_info_->info_head += _rc_; \
|
|
|
|
} \
|
|
|
|
\
|
2014-09-30 02:00:46 +04:00
|
|
|
mutex_exit(&_info_->info_lock); \
|
2008-02-28 02:42:31 +03:00
|
|
|
_rc_; \
|
|
|
|
})
|
|
|
|
|
2008-05-07 00:38:28 +04:00
|
|
|
#define splat_vprint(file, test, format, args...) \
|
2008-02-28 02:42:31 +03:00
|
|
|
splat_print(file, "%*s: " format, SPLAT_NAME_SIZE, test, args)
|
|
|
|
|
2009-09-19 03:09:47 +04:00
|
|
|
#define splat_locked_test(lock, test) \
|
|
|
|
({ \
|
|
|
|
int _rc_; \
|
|
|
|
spin_lock(lock); \
|
|
|
|
_rc_ = (test) ? 1 : 0; \
|
|
|
|
spin_unlock(lock); \
|
|
|
|
_rc_; \
|
|
|
|
})
|
|
|
|
|
2009-01-07 23:54:03 +03:00
|
|
|
splat_subsystem_t *splat_condvar_init(void);
|
|
|
|
splat_subsystem_t *splat_kmem_init(void);
|
|
|
|
splat_subsystem_t *splat_mutex_init(void);
|
|
|
|
splat_subsystem_t *splat_krng_init(void);
|
|
|
|
splat_subsystem_t *splat_rwlock_init(void);
|
|
|
|
splat_subsystem_t *splat_taskq_init(void);
|
|
|
|
splat_subsystem_t *splat_thread_init(void);
|
|
|
|
splat_subsystem_t *splat_time_init(void);
|
|
|
|
splat_subsystem_t *splat_vnode_init(void);
|
|
|
|
splat_subsystem_t *splat_kobj_init(void);
|
|
|
|
splat_subsystem_t *splat_atomic_init(void);
|
|
|
|
splat_subsystem_t *splat_list_init(void);
|
2009-01-13 20:30:59 +03:00
|
|
|
splat_subsystem_t *splat_generic_init(void);
|
2009-07-28 04:18:59 +04:00
|
|
|
splat_subsystem_t *splat_cred_init(void);
|
2011-02-26 02:48:18 +03:00
|
|
|
splat_subsystem_t *splat_zlib_init(void);
|
2011-06-21 21:57:48 +04:00
|
|
|
splat_subsystem_t *splat_linux_init(void);
|
2008-02-28 02:42:31 +03:00
|
|
|
|
|
|
|
void splat_condvar_fini(splat_subsystem_t *);
|
|
|
|
void splat_kmem_fini(splat_subsystem_t *);
|
|
|
|
void splat_mutex_fini(splat_subsystem_t *);
|
|
|
|
void splat_krng_fini(splat_subsystem_t *);
|
|
|
|
void splat_rwlock_fini(splat_subsystem_t *);
|
|
|
|
void splat_taskq_fini(splat_subsystem_t *);
|
|
|
|
void splat_thread_fini(splat_subsystem_t *);
|
|
|
|
void splat_time_fini(splat_subsystem_t *);
|
2008-03-12 23:52:46 +03:00
|
|
|
void splat_vnode_fini(splat_subsystem_t *);
|
2008-03-11 23:54:40 +03:00
|
|
|
void splat_kobj_fini(splat_subsystem_t *);
|
2008-03-28 21:21:09 +03:00
|
|
|
void splat_atomic_fini(splat_subsystem_t *);
|
2009-01-07 23:54:03 +03:00
|
|
|
void splat_list_fini(splat_subsystem_t *);
|
2009-01-13 20:30:59 +03:00
|
|
|
void splat_generic_fini(splat_subsystem_t *);
|
2009-07-28 04:18:59 +04:00
|
|
|
void splat_cred_fini(splat_subsystem_t *);
|
2011-02-26 02:48:18 +03:00
|
|
|
void splat_zlib_fini(splat_subsystem_t *);
|
2011-06-21 21:57:48 +04:00
|
|
|
void splat_linux_fini(splat_subsystem_t *);
|
2008-02-28 02:42:31 +03:00
|
|
|
|
|
|
|
int splat_condvar_id(void);
|
|
|
|
int splat_kmem_id(void);
|
|
|
|
int splat_mutex_id(void);
|
|
|
|
int splat_krng_id(void);
|
|
|
|
int splat_rwlock_id(void);
|
|
|
|
int splat_taskq_id(void);
|
|
|
|
int splat_thread_id(void);
|
|
|
|
int splat_time_id(void);
|
2008-03-12 23:52:46 +03:00
|
|
|
int splat_vnode_id(void);
|
2008-03-11 23:54:40 +03:00
|
|
|
int splat_kobj_id(void);
|
2008-03-28 21:21:09 +03:00
|
|
|
int splat_atomic_id(void);
|
2009-01-07 23:54:03 +03:00
|
|
|
int splat_list_id(void);
|
2009-01-13 20:30:59 +03:00
|
|
|
int splat_generic_id(void);
|
2009-07-28 04:18:59 +04:00
|
|
|
int splat_cred_id(void);
|
2011-02-26 02:48:18 +03:00
|
|
|
int splat_zlib_id(void);
|
2011-06-21 21:57:48 +04:00
|
|
|
int splat_linux_id(void);
|
2008-02-28 02:42:31 +03:00
|
|
|
|
|
|
|
#endif /* _SPLAT_INTERNAL_H */
|