Whamcloud - gitweb
LU-11838 osd-ldiskfs: inode times switched to timespec64 47/35247/2
authorLi Dongyang <dongyangli@ddn.com>
Mon, 17 Jun 2019 19:01:36 +0000 (12:01 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 3 Jul 2019 03:25:40 +0000 (03:25 +0000)
Since kernel 4.18 inode times swtich from struct timespec
to timespec64 to make it y2038 safe.

Linux-commit: 95582b00838837fc07e042979320caf917ce3fe6

This patch is back-ported from the following one:
Lustre-commit: 3af55b3159ac2133dc35eeb2f02825848fb65548
Lustre-change: https://review.whamcloud.com/34675

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

index 9f736fb..866117b 100644 (file)
@@ -3035,6 +3035,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
@@ -3280,6 +3301,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 56d04d8..2189a75 100644 (file)
@@ -2598,8 +2598,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;
@@ -2607,7 +2612,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,
@@ -2825,11 +2834,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;