From f3d53e744740e918381b5a9e6ead760973ed55b9 Mon Sep 17 00:00:00 2001 From: bobijam <bobijam> Date: Thu, 13 Dec 2007 05:51:37 +0000 Subject: [PATCH] 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. --- lustre/include/obd_support.h | 47 +----------------------------------- lustre/lvfs/lvfs_lib.c | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 963e0fdf95..09c2359af5 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 ea0664dfa7..208801a042 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); -- GitLab