Whamcloud - gitweb
LU-11838 osd-ldiskfs: inode times switched to timespec64 75/34675/4
authorLi Dongyang <dongyangli@ddn.com>
Tue, 16 Apr 2019 01:14:13 +0000 (11:14 +1000)
committerOleg Drokin <green@whamcloud.com>
Thu, 13 Jun 2019 04:17:46 +0000 (04:17 +0000)
Since kernel 4.18 inode times swtich from struct timespec
to timespec64 to make it y2038 safe.

Linux-commit: 95582b00838837fc07e042979320caf917ce3fe6

Test-Parameters:trivial
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Change-Id: Iaddb2f2be27ec348fb97e13371aa3d7e6f6e5c9f
Reviewed-on: https://review.whamcloud.com/34675
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/osd-ldiskfs/osd_handler.c

index 45271d6..cf9a753 100644 (file)
@@ -3078,6 +3078,27 @@ i_pages, [
 ]) # LC_I_PAGES
 
 #
+# LC_INODE_TIMESPEC64
+#
+# kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
+# inode timestamps switched to timespec64
+#
+AC_DEFUN([LC_INODE_TIMESPEC64], [
+LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
+inode_timespec64, [
+       #include <linux/fs.h>
+],[
+       struct inode inode = {};
+       struct timespec64 ts = {};
+
+       inode.i_atime = ts;
+],[
+       AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
+               [inode times are using timespec64])
+])
+]) # LC_INODE_TIMESPEC64
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -3325,6 +3346,9 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 4.17
        LC_I_PAGES
 
+       # 4.18
+       LC_INODE_TIMESPEC64
+
        # kernel patch to extend integrity interface
        LC_BIO_INTEGRITY_PREP_FN
 
index cf8b64d..edf9dbb 100644 (file)
@@ -2602,8 +2602,13 @@ static int osd_write_locked(const struct lu_env *env, struct dt_object *dt)
        return obj->oo_owner == env;
 }
 
-static struct timespec *osd_inode_time(const struct lu_env *env,
+#ifdef HAVE_INODE_TIMESPEC64
+static struct timespec64 osd_inode_time(const struct lu_env *env,
                                       struct inode *inode, __u64 seconds)
+#else
+static struct timespec osd_inode_time(const struct lu_env *env,
+                                      struct inode *inode, __u64 seconds)
+#endif
 {
        struct osd_thread_info *oti = osd_oti_get(env);
        struct timespec *t = &oti->oti_time;
@@ -2611,7 +2616,11 @@ static struct timespec *osd_inode_time(const struct lu_env *env,
        t->tv_sec = seconds;
        t->tv_nsec = 0;
        *t = timespec_trunc(*t, inode->i_sb->s_time_gran);
-       return t;
+#ifdef HAVE_INODE_TIMESPEC64
+       return timespec_to_timespec64(*t);
+#else
+       return *t;
+#endif
 }
 
 static void osd_inode_getattr(const struct lu_env *env,
@@ -2829,11 +2838,11 @@ static int osd_inode_setattr(const struct lu_env *env,
                return 0;
 
        if (bits & LA_ATIME)
-               inode->i_atime  = *osd_inode_time(env, inode, attr->la_atime);
+               inode->i_atime  = osd_inode_time(env, inode, attr->la_atime);
        if (bits & LA_CTIME)
-               inode->i_ctime  = *osd_inode_time(env, inode, attr->la_ctime);
+               inode->i_ctime  = osd_inode_time(env, inode, attr->la_ctime);
        if (bits & LA_MTIME)
-               inode->i_mtime  = *osd_inode_time(env, inode, attr->la_mtime);
+               inode->i_mtime  = osd_inode_time(env, inode, attr->la_mtime);
        if (bits & LA_SIZE) {
                spin_lock(&inode->i_lock);
                LDISKFS_I(inode)->i_disksize = attr->la_size;