diff options
Diffstat (limited to 'drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h')
-rw-r--r-- | drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h index bdbbe93..fedb46d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h @@ -39,8 +39,8 @@ extern int cfs_fail_err; extern wait_queue_head_t cfs_race_waitq; extern int cfs_race_state; -int __cfs_fail_check_set(__u32 id, __u32 value, int set); -int __cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set); +int __cfs_fail_check_set(u32 id, u32 value, int set); +int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set); enum { CFS_FAIL_LOC_NOSET = 0, @@ -55,11 +55,11 @@ enum { #define CFS_FAILED_BIT 30 /* CFS_FAILED is 0x40000000 */ -#define CFS_FAILED (1 << CFS_FAILED_BIT) +#define CFS_FAILED BIT(CFS_FAILED_BIT) #define CFS_FAIL_ONCE_BIT 31 /* CFS_FAIL_ONCE is 0x80000000 */ -#define CFS_FAIL_ONCE (1 << CFS_FAIL_ONCE_BIT) +#define CFS_FAIL_ONCE BIT(CFS_FAIL_ONCE_BIT) /* The following flags aren't made to be combined */ #define CFS_FAIL_SKIP 0x20000000 /* skip N times then fail */ @@ -69,14 +69,14 @@ enum { #define CFS_FAULT 0x02000000 /* match any CFS_FAULT_CHECK */ -static inline bool CFS_FAIL_PRECHECK(__u32 id) +static inline bool CFS_FAIL_PRECHECK(u32 id) { - return cfs_fail_loc != 0 && + return cfs_fail_loc && ((cfs_fail_loc & CFS_FAIL_MASK_LOC) == (id & CFS_FAIL_MASK_LOC) || - (cfs_fail_loc & id & CFS_FAULT)); + (cfs_fail_loc & id & CFS_FAULT)); } -static inline int cfs_fail_check_set(__u32 id, __u32 value, +static inline int cfs_fail_check_set(u32 id, u32 value, int set, int quiet) { int ret = 0; @@ -103,28 +103,34 @@ static inline int cfs_fail_check_set(__u32 id, __u32 value, #define CFS_FAIL_CHECK_QUIET(id) \ cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET, 1) -/* If id hit cfs_fail_loc and cfs_fail_val == (-1 or value) return 1, - * otherwise return 0 */ +/* + * If id hit cfs_fail_loc and cfs_fail_val == (-1 or value) return 1, + * otherwise return 0 + */ #define CFS_FAIL_CHECK_VALUE(id, value) \ cfs_fail_check_set(id, value, CFS_FAIL_LOC_VALUE, 0) #define CFS_FAIL_CHECK_VALUE_QUIET(id, value) \ cfs_fail_check_set(id, value, CFS_FAIL_LOC_VALUE, 1) -/* If id hit cfs_fail_loc, cfs_fail_loc |= value and return 1, - * otherwise return 0 */ +/* + * If id hit cfs_fail_loc, cfs_fail_loc |= value and return 1, + * otherwise return 0 + */ #define CFS_FAIL_CHECK_ORSET(id, value) \ cfs_fail_check_set(id, value, CFS_FAIL_LOC_ORSET, 0) #define CFS_FAIL_CHECK_ORSET_QUIET(id, value) \ cfs_fail_check_set(id, value, CFS_FAIL_LOC_ORSET, 1) -/* If id hit cfs_fail_loc, cfs_fail_loc = value and return 1, - * otherwise return 0 */ +/* + * If id hit cfs_fail_loc, cfs_fail_loc = value and return 1, + * otherwise return 0 + */ #define CFS_FAIL_CHECK_RESET(id, value) \ cfs_fail_check_set(id, value, CFS_FAIL_LOC_RESET, 0) #define CFS_FAIL_CHECK_RESET_QUIET(id, value) \ cfs_fail_check_set(id, value, CFS_FAIL_LOC_RESET, 1) -static inline int cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set) +static inline int cfs_fail_timeout_set(u32 id, u32 value, int ms, int set) { if (unlikely(CFS_FAIL_PRECHECK(id))) return __cfs_fail_timeout_set(id, value, ms, set); @@ -138,8 +144,10 @@ static inline int cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set) #define CFS_FAIL_TIMEOUT_MS(id, ms) \ cfs_fail_timeout_set(id, 0, ms, CFS_FAIL_LOC_NOSET) -/* If id hit cfs_fail_loc, cfs_fail_loc |= value and - * sleep seconds or milliseconds */ +/* + * If id hit cfs_fail_loc, cfs_fail_loc |= value and + * sleep seconds or milliseconds + */ #define CFS_FAIL_TIMEOUT_ORSET(id, value, secs) \ cfs_fail_timeout_set(id, value, secs * 1000, CFS_FAIL_LOC_ORSET) @@ -152,13 +160,14 @@ static inline int cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set) #define CFS_FAULT_CHECK(id) \ CFS_FAIL_CHECK(CFS_FAULT | (id)) -/* The idea here is to synchronise two threads to force a race. The +/* + * 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 - * the first and continues. */ -static inline void cfs_race(__u32 id) + * the first and continues. + */ +static inline void cfs_race(u32 id) { - if (CFS_FAIL_PRECHECK(id)) { if (unlikely(__cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET))) { int rc; @@ -166,7 +175,7 @@ static inline void cfs_race(__u32 id) cfs_race_state = 0; CERROR("cfs_race id %x sleeping\n", id); rc = wait_event_interruptible(cfs_race_waitq, - cfs_race_state != 0); + !!cfs_race_state); CERROR("cfs_fail_race id %x awake, rc=%d\n", id, rc); } else { CERROR("cfs_fail_race id %x waking\n", id); |