New upstream version 8.1.0
This commit is contained in:
89
client_module/source/fault-inject/fault-inject.c
Normal file
89
client_module/source/fault-inject/fault-inject.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "fault-inject.h"
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if defined(BEEGFS_DEBUG) && defined(CONFIG_FAULT_INJECTION)
|
||||
|
||||
static struct dentry* debug_dir;
|
||||
static struct dentry* fault_dir;
|
||||
|
||||
#define BEEGFS_DECLARE_FAULT_ATTR(name) DECLARE_FAULT_ATTR(beegfs_fault_ ## name)
|
||||
|
||||
BEEGFS_DECLARE_FAULT_ATTR(readpage);
|
||||
BEEGFS_DECLARE_FAULT_ATTR(writepage);
|
||||
|
||||
BEEGFS_DECLARE_FAULT_ATTR(write_force_cache_bypass);
|
||||
BEEGFS_DECLARE_FAULT_ATTR(read_force_cache_bypass);
|
||||
|
||||
BEEGFS_DECLARE_FAULT_ATTR(commkit_sendheader_timeout);
|
||||
BEEGFS_DECLARE_FAULT_ATTR(commkit_polltimeout);
|
||||
BEEGFS_DECLARE_FAULT_ATTR(commkit_recvheader_timeout);
|
||||
|
||||
BEEGFS_DECLARE_FAULT_ATTR(commkit_readfile_receive_timeout);
|
||||
BEEGFS_DECLARE_FAULT_ATTR(commkit_writefile_senddata_timeout);
|
||||
|
||||
#define INIT_FAULT(name) \
|
||||
if(IS_ERR(fault_create_debugfs_attr(#name, fault_dir, &beegfs_fault_ ## name))) \
|
||||
goto err_fault_dir;
|
||||
|
||||
#ifndef KERNEL_HAS_FAULTATTR_DNAME
|
||||
#define DESTROY_FAULT(name) do { } while (0)
|
||||
#else
|
||||
#define DESTROY_FAULT(name) \
|
||||
do { \
|
||||
if((beegfs_fault_ ## name).dname) \
|
||||
dput( (beegfs_fault_ ## name).dname); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
bool beegfs_fault_inject_init()
|
||||
{
|
||||
debug_dir = debugfs_create_dir(BEEGFS_MODULE_NAME_STR, NULL);
|
||||
if(!debug_dir)
|
||||
goto err_debug_dir;
|
||||
|
||||
fault_dir = debugfs_create_dir("fault", debug_dir);
|
||||
if(!fault_dir)
|
||||
goto err_fault_dir;
|
||||
|
||||
INIT_FAULT(readpage);
|
||||
INIT_FAULT(writepage);
|
||||
|
||||
INIT_FAULT(write_force_cache_bypass);
|
||||
INIT_FAULT(read_force_cache_bypass);
|
||||
|
||||
INIT_FAULT(commkit_sendheader_timeout);
|
||||
INIT_FAULT(commkit_polltimeout);
|
||||
INIT_FAULT(commkit_recvheader_timeout);
|
||||
|
||||
INIT_FAULT(commkit_readfile_receive_timeout);
|
||||
INIT_FAULT(commkit_writefile_senddata_timeout);
|
||||
|
||||
return true;
|
||||
|
||||
err_fault_dir:
|
||||
debugfs_remove_recursive(debug_dir);
|
||||
debug_dir = NULL;
|
||||
err_debug_dir:
|
||||
return false;
|
||||
}
|
||||
|
||||
void beegfs_fault_inject_release()
|
||||
{
|
||||
DESTROY_FAULT(readpage);
|
||||
DESTROY_FAULT(writepage);
|
||||
|
||||
DESTROY_FAULT(write_force_cache_bypass);
|
||||
DESTROY_FAULT(read_force_cache_bypass);
|
||||
|
||||
DESTROY_FAULT(commkit_sendheader_timeout);
|
||||
DESTROY_FAULT(commkit_polltimeout);
|
||||
DESTROY_FAULT(commkit_recvheader_timeout);
|
||||
|
||||
DESTROY_FAULT(commkit_readfile_receive_timeout);
|
||||
DESTROY_FAULT(commkit_writefile_senddata_timeout);
|
||||
|
||||
debugfs_remove_recursive(debug_dir);
|
||||
}
|
||||
|
||||
#endif
|
||||
51
client_module/source/fault-inject/fault-inject.h
Normal file
51
client_module/source/fault-inject/fault-inject.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _fault_inject_fault_inject_h_dBK5RbRnOrGDnIW5Y7zvnv
|
||||
#define _fault_inject_fault_inject_h_dBK5RbRnOrGDnIW5Y7zvnv
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#if defined(BEEGFS_DEBUG) && defined(CONFIG_FAULT_INJECTION)
|
||||
|
||||
#include <linux/fault-inject.h>
|
||||
|
||||
#ifndef CONFIG_DEBUG_FS
|
||||
#error debugfs required for beegfs fault injection
|
||||
#endif
|
||||
#ifndef CONFIG_FAULT_INJECTION_DEBUG_FS
|
||||
#error CONFIG_FAULT_INJECTION_DEBUG_FS required for beegfs fault injection
|
||||
#endif
|
||||
|
||||
#define BEEGFS_SHOULD_FAIL(name, size) should_fail(&beegfs_fault_ ## name, size)
|
||||
#define BEEGFS_DEFINE_FAULT(name) extern struct fault_attr beegfs_fault_ ## name
|
||||
|
||||
BEEGFS_DEFINE_FAULT(readpage);
|
||||
BEEGFS_DEFINE_FAULT(writepage);
|
||||
|
||||
BEEGFS_DEFINE_FAULT(write_force_cache_bypass);
|
||||
BEEGFS_DEFINE_FAULT(read_force_cache_bypass);
|
||||
|
||||
BEEGFS_DEFINE_FAULT(commkit_sendheader_timeout);
|
||||
BEEGFS_DEFINE_FAULT(commkit_polltimeout);
|
||||
BEEGFS_DEFINE_FAULT(commkit_recvheader_timeout);
|
||||
|
||||
BEEGFS_DEFINE_FAULT(commkit_readfile_receive_timeout);
|
||||
BEEGFS_DEFINE_FAULT(commkit_writefile_senddata_timeout);
|
||||
|
||||
extern bool beegfs_fault_inject_init(void);
|
||||
extern void beegfs_fault_inject_release(void);
|
||||
|
||||
#else // BEEGFS_DEBUG
|
||||
|
||||
#define BEEGFS_SHOULD_FAIL(name, size) (false)
|
||||
|
||||
static inline bool beegfs_fault_inject_init(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void beegfs_fault_inject_release(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // BEEGFS_DEBUG
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user