]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
staging: lustre: libcfs: add CFS_FAULT_CHECK()
authorJames Simmons <jsimmons@infradead.org>
Mon, 28 Mar 2016 00:26:28 +0000 (20:26 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Mar 2016 19:10:20 +0000 (12:10 -0700)
Add the macro CFS_FAULT_CHECK() which behaves like CFS_FAIL_CHECK()
except that any site may be matched by setting CFS_FAULT (0x02000000)
in cfs_fail_loc. Add cfs_fail_err for use as a return value with
CFS_FAULT_CHECK().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5409
Reviewed-on: http://review.whamcloud.com/11263
Reviewed-by: Robert Read <robert.read@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
drivers/staging/lustre/lnet/libcfs/fail.c
drivers/staging/lustre/lnet/libcfs/module.c

index aa69c6a33d19dc0a6635213c55d177b64aa29f8c..2e008bffc89a92eabad55dc96f4e2b030f25416e 100644 (file)
@@ -38,6 +38,7 @@
 
 extern unsigned long cfs_fail_loc;
 extern unsigned int cfs_fail_val;
+extern int cfs_fail_err;
 
 extern wait_queue_head_t cfs_race_waitq;
 extern int cfs_race_state;
@@ -70,9 +71,14 @@ enum {
 #define CFS_FAIL_RAND  0x08000000 /* fail 1/N of the times */
 #define CFS_FAIL_USR1  0x04000000 /* user flag */
 
-#define CFS_FAIL_PRECHECK(id) (cfs_fail_loc &&                         \
-                             (cfs_fail_loc & CFS_FAIL_MASK_LOC) ==        \
-                             ((id) & CFS_FAIL_MASK_LOC))
+#define CFS_FAULT      0x02000000 /* match any CFS_FAULT_CHECK */
+
+static inline bool CFS_FAIL_PRECHECK(__u32 id)
+{
+       return cfs_fail_loc != 0 &&
+              ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) ||
+               (cfs_fail_loc & id & CFS_FAULT));
+}
 
 static inline int cfs_fail_check_set(__u32 id, __u32 value,
                                     int set, int quiet)
@@ -144,6 +150,9 @@ static inline int cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
 #define CFS_FAIL_TIMEOUT_MS_ORSET(id, value, ms) \
        cfs_fail_timeout_set(id, value, ms, CFS_FAIL_LOC_ORSET)
 
+#define CFS_FAULT_CHECK(id)                    \
+       CFS_FAIL_CHECK(CFS_FAULT | (id))
+
 /* The idea here is to synchronise two threads to force a race. The
  * first thread that calls this with a matching fail_loc is put to
  * sleep. The next thread that calls with the same fail_loc wakes up
index dadaf7685cbdf221bd1ade81410ce31418817f8f..086e690bd6f2b45b8c35964556170ea6b356ba10 100644 (file)
@@ -41,6 +41,9 @@ EXPORT_SYMBOL(cfs_fail_loc);
 unsigned int cfs_fail_val;
 EXPORT_SYMBOL(cfs_fail_val);
 
+int cfs_fail_err;
+EXPORT_SYMBOL(cfs_fail_err);
+
 DECLARE_WAIT_QUEUE_HEAD(cfs_race_waitq);
 EXPORT_SYMBOL(cfs_race_waitq);
 
index 49c2d03dc9defc88c835b75b45fb96bfc35b37ea..f2d041118cf7dfc3bd447247185473744287b5b7 100644 (file)
@@ -424,6 +424,13 @@ static struct ctl_table lnet_table[] = {
                .mode     = 0644,
                .proc_handler = &proc_dointvec
        },
+       {
+               .procname       = "fail_err",
+               .data           = &cfs_fail_err,
+               .maxlen         = sizeof(cfs_fail_err),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec,
+       },
        {
        }
 };