+#define OBD_FAIL_FLD 0x1100
+#define OBD_FAIL_FLD_QUERY_NET 0x1101
+
+#define OBD_FAIL_SEC_CTX 0x1200
+#define OBD_FAIL_SEC_CTX_INIT_NET 0x1201
+#define OBD_FAIL_SEC_CTX_INIT_CONT_NET 0x1202
+#define OBD_FAIL_SEC_CTX_FINI_NET 0x1203
+#define OBD_FAIL_SEC_CTX_HDL_PAUSE 0x1204
+
+#define OBD_FAIL_LLOG 0x1300
+#define OBD_FAIL_LLOG_ORIGIN_CONNECT_NET 0x1301
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_CREATE_NET 0x1302
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_DESTROY_NET 0x1303
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_READ_HEADER_NET 0x1304
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_NEXT_BLOCK_NET 0x1305
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_PREV_BLOCK_NET 0x1306
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_WRITE_REC_NET 0x1307
+#define OBD_FAIL_LLOG_ORIGIN_HANDLE_CLOSE_NET 0x1308
+#define OBD_FAIL_LLOG_CATINFO_NET 0x1309
+
+
+/* Failure injection control */
+#define OBD_FAIL_MASK_SYS 0x0000FF00
+#define OBD_FAIL_MASK_LOC (0x000000FF | OBD_FAIL_MASK_SYS)
+
+#define OBD_FAILED_BIT 30
+/* OBD_FAILED is 0x40000000 */
+#define OBD_FAILED (1 << OBD_FAILED_BIT)
+
+#define OBD_FAIL_ONCE_BIT 31
+/* OBD_FAIL_ONCE is 0x80000000 */
+#define OBD_FAIL_ONCE (1 << OBD_FAIL_ONCE_BIT)
+
+/* The following flags aren't made to be combined */
+#define OBD_FAIL_SKIP 0x20000000 /* skip N times then fail */
+#define OBD_FAIL_SOME 0x10000000 /* only fail N times */
+#define OBD_FAIL_RAND 0x08000000 /* fail 1/N of the times */
+#define OBD_FAIL_USR1 0x04000000 /* user flag */
+
+#define OBD_FAIL_PRECHECK(id) (obd_fail_loc && \
+ (obd_fail_loc & OBD_FAIL_MASK_LOC) == \
+ ((id) & OBD_FAIL_MASK_LOC))
+
+static inline int obd_fail_check_set(__u32 id, __u32 value, int set)
+{
+ int ret = 0;
+ if (unlikely(OBD_FAIL_PRECHECK(id) &&
+ (ret = __obd_fail_check_set(id, value, set)))) {
+ CERROR("*** obd_fail_loc=%x ***\n", id);
+ }
+ return ret;
+}
+
+/* If id hit obd_fail_loc, return 1, otherwise return 0 */
+#define OBD_FAIL_CHECK(id) \
+ obd_fail_check_set(id, 0, OBD_FAIL_LOC_NOSET)
+
+/* If id hit obd_fail_loc, obd_fail_loc |= value and return 1,
+ * otherwise return 0 */
+#define OBD_FAIL_CHECK_ORSET(id, value) \
+ obd_fail_check_set(id, value, OBD_FAIL_LOC_ORSET)
+
+/* If id hit obd_fail_loc, obd_fail_loc = value and return 1,
+ * otherwise return 0 */
+#define OBD_FAIL_CHECK_RESET(id, value) \
+ obd_fail_check_set(id, value, OBD_FAIL_LOC_RESET)
+
+
+static inline int obd_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
+{
+ if (unlikely(OBD_FAIL_PRECHECK(id)))
+ return __obd_fail_timeout_set(id, value, ms, set);
+ else
+ return 0;
+}
+
+/* If id hit obd_fail_loc, sleep for seconds or milliseconds */
+#define OBD_FAIL_TIMEOUT(id, secs) \
+ obd_fail_timeout_set(id, 0, secs * 1000, OBD_FAIL_LOC_NOSET)
+
+#define OBD_FAIL_TIMEOUT_MS(id, ms) \
+ obd_fail_timeout_set(id, 0, ms, OBD_FAIL_LOC_NOSET)
+
+/* If id hit obd_fail_loc, obd_fail_loc |= value and
+ * sleep seconds or milliseconds */
+#define OBD_FAIL_TIMEOUT_ORSET(id, value, secs) \
+ obd_fail_timeout_set(id, value, secs * 1000, OBD_FAIL_LOC_ORSET)
+
+#define OBD_FAIL_TIMEOUT_MS_ORSET(id, value, ms) \
+ obd_fail_timeout_set(id, value, ms, OBD_FAIL_LOC_ORSET)