diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 963e0fdf955b93a1322138925f333972f30f7479..09c2359af58341e898ef0e2cdf306c8239408c95 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -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; \ diff --git a/lustre/lvfs/lvfs_lib.c b/lustre/lvfs/lvfs_lib.c index ea0664dfa72afccd74fe73fce184d5ffa007e3f0..208801a0429180ae0e79c577269ad7b4cf984604 100644 --- a/lustre/lvfs/lvfs_lib.c +++ b/lustre/lvfs/lvfs_lib.c @@ -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);