-
-/* Failure injection control */
-#define OBD_FAIL_MASK_SYS 0x0000FF00
-#define OBD_FAIL_MASK_LOC (0x000000FF | OBD_FAIL_MASK_SYS)
-#define OBD_FAIL_ONCE 0x80000000
-#define OBD_FAILED 0x40000000
-
-/* The following flags aren't made to be combined */
-#define OBD_FAIL_SKIP 0x20000000 /* skip N then fail */
-#define OBD_FAIL_SOME 0x10000000 /* fail N times */
-#define OBD_FAIL_RAND 0x08000000 /* fail 1/N of the time */
-#define OBD_FAIL_USR1 0x04000000 /* user flag */
-
-static inline int obd_fail_check(__u32 id)
-{
- static int count = 0;
- if (likely((obd_fail_loc & OBD_FAIL_MASK_LOC) !=
- (id & OBD_FAIL_MASK_LOC)))
- return 0;
-
- if ((obd_fail_loc & (OBD_FAILED | OBD_FAIL_ONCE)) ==
- (OBD_FAILED | OBD_FAIL_ONCE)) {
- count = 0; /* paranoia */
- return 0;
- }
-
- if (obd_fail_loc & OBD_FAIL_RAND) {
- unsigned int ll_rand(void);
- if (obd_fail_val < 2)
- return 0;
- if (ll_rand() % obd_fail_val > 0)
- return 0;
- }
-
- if (obd_fail_loc & OBD_FAIL_SKIP) {
- count++;
- if (count < obd_fail_val)
- return 0;
- count = 0;
- }
-
- /* Overridden by FAIL_ONCE */
- if (obd_fail_loc & OBD_FAIL_SOME) {
- count++;
- if (count >= obd_fail_val) {
- count = 0;
- /* Don't fail anymore */
- obd_fail_loc |= OBD_FAIL_ONCE;
- }
- }
-
- obd_fail_loc |= OBD_FAILED;
- /* Handle old checks that OR in this */
- if (id & OBD_FAIL_ONCE)
- obd_fail_loc |= OBD_FAIL_ONCE;
-
- return 1;
-}
-
-#define OBD_FAIL_CHECK(id) \
-({ \
- int _ret_ = 0; \
- if (unlikely(obd_fail_loc && (_ret_ = obd_fail_check(id)))) { \
- CERROR("*** obd_fail_loc=%x ***\n", id); \
- } \
- _ret_; \
-})
-
-/* deprecated - just use OBD_FAIL_CHECK */
-#define OBD_FAIL_CHECK_ONCE OBD_FAIL_CHECK
-
-#define OBD_FAIL_RETURN(id, ret) \
-do { \
- if (unlikely(obd_fail_loc && obd_fail_check(id))) { \
- CERROR("*** obd_fail_return=%x rc=%d ***\n", id, ret); \
- RETURN(ret); \
- } \
-} while(0)
-
-#define OBD_FAIL_TIMEOUT(id, secs) \
-({ int _ret_ = 0; \
- if (unlikely(obd_fail_loc && (_ret_ = obd_fail_check(id)))) { \
- CERROR("obd_fail_timeout id %x sleeping for %d secs\n", \
- (id), (secs)); \
- set_current_state(TASK_UNINTERRUPTIBLE); \
- cfs_schedule_timeout(CFS_TASK_UNINT, \
- cfs_time_seconds(secs)); \
- set_current_state(TASK_RUNNING); \
- CERROR("obd_fail_timeout id %x awake\n", (id)); \
- } \
- _ret_; \
-})
-
-#define OBD_FAIL_TIMEOUT_MS(id, ms) \
-({ int _ret_ = 0; \
- if (unlikely(obd_fail_loc && (_ret_ = obd_fail_check(id)))) { \
- CERROR("obd_fail_timeout id %x sleeping for %d ms\n", \
- (id), (ms)); \
- set_current_state(TASK_UNINTERRUPTIBLE); \
- cfs_schedule_timeout(CFS_TASK_UNINT, \
- cfs_time_seconds(ms)/1000); \
- set_current_state(TASK_RUNNING); \
- CERROR("obd_fail_timeout id %x awake\n", (id)); \
- } \
- _ret_; \
-})
-
-#ifdef __KERNEL__
-/* 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. */
-#define OBD_RACE(id) \
-do { \
- if (unlikely(obd_fail_loc && obd_fail_check(id))) { \
- obd_race_state = 0; \
- CERROR("obd_race id %x sleeping\n", (id)); \
- OBD_SLEEP_ON(obd_race_waitq, obd_race_state != 0); \
- CERROR("obd_fail_race id %x awake\n", (id)); \
- } else if ((obd_fail_loc & OBD_FAIL_MASK_LOC) == \
- ((id) & OBD_FAIL_MASK_LOC)) { \
- CERROR("obd_fail_race id %x waking\n", (id)); \
- obd_race_state = 1; \
- wake_up(&obd_race_waitq); \
- } \
-} while(0)
-#else
-/* sigh. an expedient fix until OBD_RACE is fixed up */
-#define OBD_RACE(foo) do {} while(0)
-#endif
-
-#define fixme() CDEBUG(D_OTHER, "FIXME\n");
-
-extern atomic_t libcfs_kmemory;
-
-#ifdef LPROCFS
+#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
+#define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
+#define OBD_FAIL_SEQ_ALLOC 0x1311
+
+#define OBD_FAIL_LLITE 0x1400
+#define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
+#define OBD_FAIL_LOCK_STATE_WAIT_INTR 0x1402
+
+/* Assign references to moved code to reduce code changes */
+#define OBD_FAIL_PRECHECK(id) CFS_FAIL_PRECHECK(id)
+#define OBD_FAIL_CHECK(id) CFS_FAIL_CHECK(id)
+#define OBD_FAIL_CHECK_VALUE(id, value) CFS_FAIL_CHECK_VALUE(id, value)
+#define OBD_FAIL_CHECK_ORSET(id, value) CFS_FAIL_CHECK_ORSET(id, value)
+#define OBD_FAIL_CHECK_RESET(id, value) CFS_FAIL_CHECK_RESET(id, value)
+#define OBD_FAIL_RETURN(id, ret) CFS_FAIL_RETURN(id, ret)
+#define OBD_FAIL_TIMEOUT(id, secs) CFS_FAIL_TIMEOUT(id, secs)
+#define OBD_FAIL_TIMEOUT_MS(id, ms) CFS_FAIL_TIMEOUT_MS(id, ms)
+#define OBD_FAIL_TIMEOUT_ORSET(id, value, secs) CFS_FAIL_TIMEOUT_ORSET(id, value, secs)
+#define OBD_RACE(id) CFS_RACE(id)
+#define OBD_FAIL_ONCE CFS_FAIL_ONCE
+#define OBD_FAILED CFS_FAILED
+
+extern cfs_atomic_t libcfs_kmemory;
+
+#ifdef LPROCFS