X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Flibcfs_fail.h;h=79eda2d83e788432f08a32b93517876331767104;hb=b19b318b5e74e76b3fc5b15c796666d04df62466;hp=8529566347f6dc647cab1769577f11b4f520be0f;hpb=56782fa6e0cdd208d07480ad4b284ada1f09c60c;p=fs%2Flustre-release.git diff --git a/libcfs/include/libcfs/libcfs_fail.h b/libcfs/include/libcfs/libcfs_fail.h index 8529566..79eda2d 100644 --- a/libcfs/include/libcfs/libcfs_fail.h +++ b/libcfs/include/libcfs/libcfs_fail.h @@ -16,10 +16,6 @@ * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see http://www.gnu.org/licenses * - * Please contact Oracle Corporation, Inc., 500 Oracle Parkway, Redwood Shores, - * CA 94065 USA or visit www.oracle.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* @@ -53,6 +49,10 @@ enum { CFS_FAIL_LOC_VALUE = 3 }; +/* Failure ranges + "0x0100 - 0x3fff" for Lustre + "0xe000 - 0xefff" for LNet + "0xf000 - 0xffff" for LNDs */ /* Failure injection control */ #define CFS_FAIL_MASK_SYS 0x0000FF00 #define CFS_FAIL_MASK_LOC (0x000000FF | CFS_FAIL_MASK_SYS) @@ -169,7 +169,7 @@ static inline void cfs_race(__u32 id) CERROR("cfs_race id %x sleeping\n", id); rc = wait_event_interruptible(cfs_race_waitq, cfs_race_state != 0); - CERROR("cfs_fail_race id %x awake, rc=%d\n", id, rc); + CERROR("cfs_fail_race id %x awake: rc=%d\n", id, rc); } else { CERROR("cfs_fail_race id %x waking\n", id); cfs_race_state = 1; @@ -179,4 +179,42 @@ static inline void cfs_race(__u32 id) } #define CFS_RACE(id) cfs_race(id) +/** + * Wait on race. + * + * The first thread that calls this with a matching fail_loc is put to sleep, + * but subseqent callers of this won't sleep. Until another thread that calls + * cfs_race_wakeup(), the first thread will be woken up and continue. + */ +static inline void cfs_race_wait(__u32 id) +{ + if (CFS_FAIL_PRECHECK(id)) { + if (unlikely(__cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET))) { + int rc; + + cfs_race_state = 0; + CERROR("cfs_race id %x sleeping\n", id); + rc = wait_event_interruptible(cfs_race_waitq, + cfs_race_state != 0); + CERROR("cfs_fail_race id %x awake: rc=%d\n", id, rc); + } + } +} +#define CFS_RACE_WAIT(id) cfs_race_wait(id) + +/** + * Wake up the thread that is waiting on the matching fail_loc. + */ +static inline void cfs_race_wakeup(__u32 id) +{ + if (CFS_FAIL_PRECHECK(id)) { + if (likely(!__cfs_fail_check_set(id, 0, CFS_FAIL_LOC_NOSET))) { + CERROR("cfs_fail_race id %x waking\n", id); + cfs_race_state = 1; + wake_up(&cfs_race_waitq); + } + } +} +#define CFS_RACE_WAKEUP(id) cfs_race_wakeup(id) + #endif /* _LIBCFS_FAIL_H */