Whamcloud - gitweb
LU-12477 lustre: restore time_after32() 25/37725/3
authorMr NeilBrown <neilb@suse.de>
Tue, 25 Feb 2020 20:53:38 +0000 (07:53 +1100)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 Mar 2020 22:37:17 +0000 (22:37 +0000)
time_after32 is needed when compiling with kernels earlier than v4.14,
which haven't had it backported.  E.g. SLE12-SP3-LTSS needs it.

Fixes: 8e88bbfef579 ("LU-12477 lustre: remove obsolete config checks")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ifb51b9ed0945ad28f8e8aa34dada3860107b95df
Reviewed-on: https://review.whamcloud.com/37725
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/lustre_compat.h

index 1d16ac9..0d61f4b 100644 (file)
@@ -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