X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Finclude%2Flustre_compat.h;h=0d61f4b693da8fbd41511c0dbfdea55c052b60c1;hb=refs%2Fchanges%2F25%2F37725%2F3;hp=1d16ac95ee4755b53713c3c8cbbaaba06db44bef;hpb=35d01a0fc7b2933d589f5a6bc4878382cbc15b52;p=fs%2Flustre-release.git diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 1d16ac9..0d61f4b 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -403,6 +403,27 @@ static inline struct timespec current_time(struct inode *inode) } #endif +#ifndef time_after32 +/** + * time_after32 - compare two 32-bit relative times + * @a: the time which may be after @b + * @b: the time which may be before @a + * + * Needed for kernels earlier than v4.14-rc1~134^2 + * + * time_after32(a, b) returns true if the time @a is after time @b. + * time_before32(b, a) returns true if the time @b is before time @a. + * + * Similar to time_after(), compare two 32-bit timestamps for relative + * times. This is useful for comparing 32-bit seconds values that can't + * be converted to 64-bit values (e.g. due to disk format or wire protocol + * issues) when it is known that the times are less than 68 years apart. + */ +#define time_after32(a, b) ((s32)((u32)(b) - (u32)(a)) < 0) +#define time_before32(b, a) time_after32(a, b) + +#endif + #ifndef smp_store_mb #define smp_store_mb(var, value) set_mb(var, value) #endif