Whamcloud - gitweb
LU-12355 osd-ldiskfs: timespec_trunc removed 50/35050/7
authorShaun Tancheff <stancheff@cray.com>
Thu, 13 Jun 2019 18:27:19 +0000 (13:27 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Jun 2019 03:50:32 +0000 (03:50 +0000)
As part of the y2038 changes:

timespec64_trunc was added in kernel 4.17
inode i_Xtime values are timespec64 in kernel 4.18
timespec_trunc was removed in kernel 4.19

Harden the existing LC_INODE_TIMESPEC64 check and stop
using the deprecated timespec_trunc().

oti_time is set but never used, remove oti_time.

Linux-commit: 8efd6894ff089adeeac7cb9f32125b85d963d1bc
Linux-commit: 95582b00838837fc07e042979320caf917ce3fe6
Linux-commit: 976516404ff3fab2a8caa8bd6f5efc1437fed0b8

Test-Parameters: trivial
Change-Id: Idadbf6ddd9aedbd251d7bbbb5b1486d4aa757ac5
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-on: https://review.whamcloud.com/35050
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
lustre/autoconf/lustre-core.m4
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-zfs/osd_internal.h

index cc4e8b6..5e82b61 100644 (file)
@@ -3148,10 +3148,21 @@ i_pages, [
 #
 # LC_INODE_TIMESPEC64
 #
 #
 # LC_INODE_TIMESPEC64
 #
+# kernel 4.17-rc7 commit 8efd6894ff089adeeac7cb9f32125b85d963d1bc
+# fs: add timespec64_truncate()
 # kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
 # inode timestamps switched to timespec64
 # kernel 4.18 commit 95582b00838837fc07e042979320caf917ce3fe6
 # inode timestamps switched to timespec64
+# kernel 4.19-rc2 commit 976516404ff3fab2a8caa8bd6f5efc1437fed0b8
+# y2038: remove unused time interfaces
+# ...
+#  timespec_trunc
+# ...
+# When inode times are timespec64 stop using the deprecated
+# time interfaces.
 #
 AC_DEFUN([LC_INODE_TIMESPEC64], [
 #
 AC_DEFUN([LC_INODE_TIMESPEC64], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
 LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
 inode_timespec64, [
        #include <linux/fs.h>
 LB_CHECK_COMPILE([if inode timestamps are struct timespec64],
 inode_timespec64, [
        #include <linux/fs.h>
@@ -3159,11 +3170,13 @@ inode_timespec64, [
        struct inode inode = {};
        struct timespec64 ts = {};
 
        struct inode inode = {};
        struct timespec64 ts = {};
 
-       inode.i_atime = ts;
+       inode.i_atime = timespec64_trunc(ts, 1);
+       (void)inode;
 ],[
        AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
                [inode times are using timespec64])
 ])
 ],[
        AC_DEFINE(HAVE_INODE_TIMESPEC64, 1,
                [inode times are using timespec64])
 ])
+EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_INODE_TIMESPEC64
 
 #
 ]) # LC_INODE_TIMESPEC64
 
 #
index edf9dbb..f4127a7 100644 (file)
@@ -2602,27 +2602,6 @@ static int osd_write_locked(const struct lu_env *env, struct dt_object *dt)
        return obj->oo_owner == env;
 }
 
        return obj->oo_owner == 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;
-
-       t->tv_sec = seconds;
-       t->tv_nsec = 0;
-       *t = timespec_trunc(*t, inode->i_sb->s_time_gran);
-#ifdef HAVE_INODE_TIMESPEC64
-       return timespec_to_timespec64(*t);
-#else
-       return *t;
-#endif
-}
-
 static void osd_inode_getattr(const struct lu_env *env,
                              struct inode *inode, struct lu_attr *attr)
 {
 static void osd_inode_getattr(const struct lu_env *env,
                              struct inode *inode, struct lu_attr *attr)
 {
@@ -2838,11 +2817,11 @@ static int osd_inode_setattr(const struct lu_env *env,
                return 0;
 
        if (bits & LA_ATIME)
                return 0;
 
        if (bits & LA_ATIME)
-               inode->i_atime  = osd_inode_time(env, inode, attr->la_atime);
+               inode->i_atime = osd_inode_time(inode, attr->la_atime);
        if (bits & LA_CTIME)
        if (bits & LA_CTIME)
-               inode->i_ctime  = osd_inode_time(env, inode, attr->la_ctime);
+               inode->i_ctime = osd_inode_time(inode, attr->la_ctime);
        if (bits & LA_MTIME)
        if (bits & LA_MTIME)
-               inode->i_mtime  = osd_inode_time(env, inode, attr->la_mtime);
+               inode->i_mtime = osd_inode_time(inode, attr->la_mtime);
        if (bits & LA_SIZE) {
                spin_lock(&inode->i_lock);
                LDISKFS_I(inode)->i_disksize = attr->la_size;
        if (bits & LA_SIZE) {
                spin_lock(&inode->i_lock);
                LDISKFS_I(inode)->i_disksize = attr->la_size;
index bb3bec1..53d0cad 100644 (file)
@@ -558,6 +558,22 @@ struct osd_iobuf {
        unsigned int       dr_init_at;  /* the line iobuf was initialized */
 };
 
        unsigned int       dr_init_at;  /* the line iobuf was initialized */
 };
 
+#ifdef HAVE_INODE_TIMESPEC64
+# define osd_timespec                  timespec64
+# define osd_timespec_trunc(ts, gran)  timespec64_trunc((ts), (gran))
+#else
+# define osd_timespec                  timespec
+# define osd_timespec_trunc(ts, gran)  timespec_trunc((ts), (gran))
+#endif
+
+static inline struct osd_timespec osd_inode_time(struct inode *inode,
+                                                s64 seconds)
+{
+       struct osd_timespec ts = { .tv_sec = seconds };
+
+       return osd_timespec_trunc(ts, inode->i_sb->s_time_gran);
+}
+
 #define OSD_INS_CACHE_SIZE     8
 
 struct osd_thread_info {
 #define OSD_INS_CACHE_SIZE     8
 
 struct osd_thread_info {
@@ -588,11 +604,6 @@ struct osd_thread_info {
        struct osd_inode_id    oti_id3;
         struct ost_id          oti_ostid;
 
        struct osd_inode_id    oti_id3;
         struct ost_id          oti_ostid;
 
-        /*
-         * XXX temporary: for ->i_op calls.
-         */
-        struct timespec        oti_time;
-
         /**
          * following ipd and it structures are used for osd_index_iam_lookup()
          * these are defined separately as we might do index operation
         /**
          * following ipd and it structures are used for osd_index_iam_lookup()
          * these are defined separately as we might do index operation
index e63e6d6..d71004e 100644 (file)
@@ -232,10 +232,6 @@ struct osd_thread_info {
        const struct lu_env     *oti_env;
 
        struct lu_fid            oti_fid;
        const struct lu_env     *oti_env;
 
        struct lu_fid            oti_fid;
-       /*
-        * XXX temporary: for ->i_op calls.
-        */
-       struct timespec          oti_time;
 
        struct ost_id            oti_ostid;
 
 
        struct ost_id            oti_ostid;