From: Shaun Tancheff Date: Thu, 13 Jun 2019 18:27:19 +0000 (-0500) Subject: LU-12355 osd-ldiskfs: timespec_trunc removed X-Git-Tag: 2.12.56~100 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1dec2632b68eab9a46d6a81d33a456345b0c0bf7 LU-12355 osd-ldiskfs: timespec_trunc removed 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 Reviewed-on: https://review.whamcloud.com/35050 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index cc4e8b6..5e82b61 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -3148,10 +3148,21 @@ i_pages, [ # # 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.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], [ +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" LB_CHECK_COMPILE([if inode timestamps are struct timespec64], inode_timespec64, [ #include @@ -3159,11 +3170,13 @@ inode_timespec64, [ 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]) ]) +EXTRA_KCFLAGS="$tmp_flags" ]) # LC_INODE_TIMESPEC64 # diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index edf9dbb..f4127a7 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -2602,27 +2602,6 @@ static int osd_write_locked(const struct lu_env *env, struct dt_object *dt) 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) { @@ -2838,11 +2817,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(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(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(inode, attr->la_mtime); if (bits & LA_SIZE) { spin_lock(&inode->i_lock); LDISKFS_I(inode)->i_disksize = attr->la_size; diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index bb3bec1..53d0cad 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -558,6 +558,22 @@ struct osd_iobuf { 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 { @@ -588,11 +604,6 @@ struct osd_thread_info { 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 diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index e63e6d6..d71004e 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -232,10 +232,6 @@ struct osd_thread_info { 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;