@@ -2061,7 +2061,7 @@ int ll_readpage(struct file *file, struct page *vmpage)
* races with the page being unlocked after readpage() but before it's
* used by the caller
*/
- OBD_FAIL_TIMEOUT(OBD_FAIL_LLITE_READPAGE_PAUSE2, cfs_fail_val);
+ CFS_FAIL_TIMEOUT(OBD_FAIL_LLITE_READPAGE_PAUSE2, cfs_fail_val);
return result;
}
@@ -116,7 +116,7 @@ static void vvp_vmpage_error(struct inode *inode, struct page *vmpage,
} else {
SetPageError(vmpage);
if (ioret != -ENOSPC &&
- OBD_FAIL_CHECK(OBD_FAIL_LLITE_PANIC_ON_ESTALE))
+ CFS_FAIL_CHECK(OBD_FAIL_LLITE_PANIC_ON_ESTALE))
LBUG();
mapping_set_error(inode->i_mapping, ioret);
@@ -48,16 +48,17 @@ 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,
- CFS_FAIL_LOC_ORSET = 1,
- CFS_FAIL_LOC_RESET = 2,
- CFS_FAIL_LOC_VALUE = 3
+ CFS_FAIL_LOC_NOSET = 0,
+ CFS_FAIL_LOC_ORSET = 1,
+ CFS_FAIL_LOC_RESET = 2,
+ CFS_FAIL_LOC_VALUE = 3
};
-/* Failure ranges
- * "0x0100 - 0x3fff" for Lustre
- * "0xe000 - 0xefff" for LNet
- * "0xf000 - 0xffff" for LNDs
+/*
+ * Failure ranges:
+ * "0x0100 - 0x3fff" for Lustre
+ * "0xe000 - 0xefff" for LNet
+ * "0xf000 - 0xffff" for LNDs
*/
/* Failure injection control */
@@ -78,6 +79,7 @@ enum {
#define CFS_FAIL_RAND 0x08000000 /* fail 1/N of the times */
#define CFS_FAIL_USR1 0x04000000 /* user flag */
+/* CFS_FAULT may be combined with any one of the above flags. */
#define CFS_FAULT 0x02000000 /* match any CFS_FAULT_CHECK */
static inline bool CFS_FAIL_PRECHECK(u32 id)
@@ -87,6 +89,9 @@ static inline bool CFS_FAIL_PRECHECK(u32 id)
(cfs_fail_loc & id & CFS_FAULT));
}
+#define UNLIKELY_CHECK_SET(id, value, set, quiet) \
+ (unlikely(cfs_fail_check_set(id, value, set, quiet)))
+
static inline int cfs_fail_check_set(u32 id, u32 value, int set, int quiet)
{
unsigned long failed_once = cfs_fail_loc & CFS_FAILED; /* ok if racy */
@@ -108,38 +113,43 @@ static inline int cfs_fail_check_set(u32 id, u32 value, int set, int quiet)
return ret;
}
-/* If id hit cfs_fail_loc, return 1, otherwise return 0 */
+/*
+ * If id hit cfs_fail_loc, return 1, otherwise return 0
+ */
#define CFS_FAIL_CHECK(id) \
- cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET, 0)
+ UNLIKELY_CHECK_SET(id, 0, CFS_FAIL_LOC_NOSET, 0)
#define CFS_FAIL_CHECK_QUIET(id) \
- cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET, 1)
+ UNLIKELY_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
*/
#define CFS_FAIL_CHECK_VALUE(id, value) \
- cfs_fail_check_set(id, value, CFS_FAIL_LOC_VALUE, 0)
+ UNLIKELY_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)
+ UNLIKELY_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
*/
#define CFS_FAIL_CHECK_ORSET(id, value) \
- cfs_fail_check_set(id, value, CFS_FAIL_LOC_ORSET, 0)
+ UNLIKELY_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)
+ UNLIKELY_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
*/
#define CFS_FAIL_CHECK_RESET(id, value) \
- cfs_fail_check_set(id, value, CFS_FAIL_LOC_RESET, 0)
+ UNLIKELY_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)
+ UNLIKELY_CHECK_SET(id, value, CFS_FAIL_LOC_RESET, 1)
+
+#define UNLIKELY_TIMEOUT_SET(id, value, ms, set) \
+ (unlikely(cfs_fail_timeout_set(id, value, ms, set)))
static inline int cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)
{
@@ -150,23 +160,23 @@ static inline int cfs_fail_timeout_set(u32 id, u32 value, int ms, int set)
/* If id hit cfs_fail_loc, sleep for seconds or milliseconds */
#define CFS_FAIL_TIMEOUT(id, secs) \
- cfs_fail_timeout_set(id, 0, (secs) * 1000, CFS_FAIL_LOC_NOSET)
+ UNLIKELY_TIMEOUT_SET(id, 0, (secs) * 1000, CFS_FAIL_LOC_NOSET)
#define CFS_FAIL_TIMEOUT_MS(id, ms) \
- cfs_fail_timeout_set(id, 0, ms, CFS_FAIL_LOC_NOSET)
+ UNLIKELY_TIMEOUT_SET(id, 0, ms, CFS_FAIL_LOC_NOSET)
/*
* 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)
+ UNLIKELY_TIMEOUT_SET(id, value, (secs) * 1000, CFS_FAIL_LOC_ORSET)
#define CFS_FAIL_TIMEOUT_RESET(id, value, secs) \
- cfs_fail_timeout_set(id, value, (secs) * 1000, CFS_FAIL_LOC_RESET)
+ UNLIKELY_TIMEOUT_SET(id, value, (secs) * 1000, CFS_FAIL_LOC_RESET)
#define CFS_FAIL_TIMEOUT_MS_ORSET(id, value, ms) \
- cfs_fail_timeout_set(id, value, ms, CFS_FAIL_LOC_ORSET)
+ UNLIKELY_TIMEOUT_SET(id, value, ms, CFS_FAIL_LOC_ORSET)
#define CFS_FAULT_CHECK(id) \
CFS_FAIL_CHECK(CFS_FAULT | (id))
@@ -185,8 +195,14 @@ 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);
+ /*
+ * XXX: don't wait forever as there is no guarantee
+ * that this branch is executed first. for testing
+ * purposes this construction works good enough
+ */
+ rc = wait_event_interruptible_timeout(cfs_race_waitq,
+ !!cfs_race_state,
+ 5 * HZ);
CERROR("cfs_fail_race id %x awake: rc=%d\n", id, rc);
} else {
CERROR("cfs_fail_race id %x waking\n", id);
@@ -219,7 +235,7 @@ static inline void cfs_race_wait(u32 id)
* purposes this construction works good enough
*/
rc = wait_event_interruptible_timeout(cfs_race_waitq,
- cfs_race_state != 0,
+ !!cfs_race_state,
5 * HZ);
CERROR("cfs_fail_race id %x awake: rc=%d\n", id, rc);
}