fault-inject: add ratelimit option
[deliverable/linux.git] / include / linux / fault-inject.h
index 3ff060ac7810586d93685942195dc386fdcc0f69..798fad9e420d656985d423ec5732605ad835f6d2 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/types.h>
 #include <linux/debugfs.h>
+#include <linux/ratelimit.h>
 #include <linux/atomic.h>
 
 /*
@@ -25,18 +26,18 @@ struct fault_attr {
        unsigned long reject_end;
 
        unsigned long count;
-
-#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
-       struct dentry *dir;
-#endif
+       struct ratelimit_state ratelimit_state;
+       struct dentry *dname;
 };
 
-#define FAULT_ATTR_INITIALIZER {                               \
-               .interval = 1,                                  \
-               .times = ATOMIC_INIT(1),                        \
-               .require_end = ULONG_MAX,                       \
-               .stacktrace_depth = 32,                         \
-               .verbose = 2,                                   \
+#define FAULT_ATTR_INITIALIZER {                                       \
+               .interval = 1,                                          \
+               .times = ATOMIC_INIT(1),                                \
+               .require_end = ULONG_MAX,                               \
+               .stacktrace_depth = 32,                                 \
+               .ratelimit_state = RATELIMIT_STATE_INIT_DISABLED,       \
+               .verbose = 2,                                           \
+               .dname = NULL,                                          \
        }
 
 #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
@@ -45,19 +46,15 @@ bool should_fail(struct fault_attr *attr, ssize_t size);
 
 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
 
-int init_fault_attr_dentries(struct fault_attr *attr, const char *name);
-void cleanup_fault_attr_dentries(struct fault_attr *attr);
+struct dentry *fault_create_debugfs_attr(const char *name,
+                       struct dentry *parent, struct fault_attr *attr);
 
 #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
 
-static inline int init_fault_attr_dentries(struct fault_attr *attr,
-                                         const char *name)
-{
-       return -ENODEV;
-}
-
-static inline void cleanup_fault_attr_dentries(struct fault_attr *attr)
+static inline struct dentry *fault_create_debugfs_attr(const char *name,
+                       struct dentry *parent, struct fault_attr *attr)
 {
+       return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
This page took 0.031814 seconds and 5 git commands to generate.