Skip to content
Snippets Groups Projects
Commit f3d53e74 authored by Bobi Jam's avatar Bobi Jam
Browse files

Branch b1_6

b=12211
origianl patch producer=adilger
i=green, bobijam

move obd_fail_check() from being a static inline to being a function.
We already protect this function from being called needlessly by use of
unlikely() and checking obd_fail_loc != 0 before calling it.

Having such a large function inline bloats the code and likely reduces
performance by putting extra (though unlikely) code in every function.
parent 57443b82
No related branches found
No related tags found
No related merge requests found
......@@ -268,52 +268,7 @@ extern unsigned int obd_alloc_fail_rate;
#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;
}
int obd_fail_check(__u32 id);
#define OBD_FAIL_CHECK(id) \
({ \
int _ret_ = 0; \
......
......@@ -162,3 +162,50 @@ EXPORT_SYMBOL(obd_alloc_fail);
EXPORT_SYMBOL(obd_fail_loc);
EXPORT_SYMBOL(obd_alloc_fail_rate);
EXPORT_SYMBOL(obd_fail_val);
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;
}
EXPORT_SYMBOL(obd_fail_check);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment