CURRENT_TIME macro is not y2038 safe on 32 bit systems.
The patch replaces all the uses of CURRENT_TIME by current_time() for
filesystem times, and ktime_get_* functions for others.
struct timespec is also not y2038 safe. Retain timespec for timestamp
representation here as lustre uses it internally everywhere. These
references will be changed to use struct timespec64 in a separate patch.
This is also in preparation for the patch that transitions vfs
timestamps to use 64 bit time and hence make them y2038 safe.
current_time() is also planned to be transitioned to y2038 safe behavior
along with this change.
CURRENT_TIME macro will be deleted before merging the aforementioned
change.
Linux-commit:
47f38c539e9a42344ff5a664942075bd4df93876
Change-Id: Iec67df8f48066801c227aba2bc9221d444dada65
Link: http://lkml.kernel.org/r/1491613030-11599-10-git-send-email-deepa.kernel@gmail.com
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-on: https://review.whamcloud.com/28305
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
]) # LC_VM_OPERATIONS_REMOVE_VMF_ARG
#
+# Kernel version 4.12 commit 47f38c539e9a42344ff5a664942075bd4df93876
+# CURRENT_TIME is not 64 bit time safe so it was replaced with
+# current_time()
+#
+AC_DEFUN([LC_CURRENT_TIME], [
+LB_CHECK_COMPILE([if CURRENT_TIME has been replaced with current_time],
+current_time, [
+ #include <linux/fs.h>
+],[
+ struct timespec ts = current_time(NULL);
+],[
+ AC_DEFINE(HAVE_CURRENT_TIME, 1,
+ [current_time() has replaced CURRENT_TIME])
+])
+]) # LIBCFS_CURRENT_TIME
+
+#
# LC_PROG_LINUX
#
# Lustre linux kernel checks
LC_INODEOPS_ENHANCED_GETATTR
LC_VM_OPERATIONS_REMOVE_VMF_ARG
+ # 4.12
+ LC_CURRENT_TIME
+
#
AS_IF([test "x$enable_server" != xno], [
LC_STACK_SIZE
# define ll_filemap_fault(vma, vmf) filemap_fault(vma, vmf)
#endif
+#ifndef HAVE_CURRENT_TIME
+static inline struct timespec current_time(struct inode *inode)
+{
+ return CURRENT_TIME;
+}
+#endif
+
#endif /* _LUSTRE_COMPAT_H */
/* We mark all of the fields "set" so MDS/OST does not re-set them */
if (!(attr->ia_valid & ATTR_CTIME_SET) &&
(attr->ia_valid & ATTR_CTIME)) {
- attr->ia_ctime = CURRENT_TIME;
+ attr->ia_ctime = current_time(inode);
attr->ia_valid |= ATTR_CTIME_SET;
}
if (!(attr->ia_valid & ATTR_ATIME_SET) &&
(attr->ia_valid & ATTR_ATIME)) {
- attr->ia_atime = CURRENT_TIME;
+ attr->ia_atime = current_time(inode);
attr->ia_valid |= ATTR_ATIME_SET;
}
if (!(attr->ia_valid & ATTR_MTIME_SET) &&
(attr->ia_valid & ATTR_MTIME)) {
- attr->ia_mtime = CURRENT_TIME;
+ attr->ia_mtime = current_time(inode);
attr->ia_valid |= ATTR_MTIME_SET;
}
struct cl_attr *attr = &osc_env_info(env)->oti_attr;
cl_object_attr_lock(obj);
- attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME);
+ attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
cl_object_attr_update(env, obj, attr, CAT_MTIME | CAT_CTIME);
cl_object_attr_unlock(obj);
}
kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms,
loi->loi_lvb.lvb_size);
- attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME);
+ attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
valid = CAT_MTIME | CAT_CTIME;
if (kms > loi->loi_kms) {
attr->cat_kms = kms;