summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_inode_item.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-08-17 19:59:07 +0300
committerDarrick J. Wong <darrick.wong@oracle.com>2020-09-16 06:52:41 +0300
commitf93e5436f0ee5a85eaa3a86d2614d215873fb18b (patch)
treece60a83ad06e42b199e2ebb14fa62e33be7f6955 /fs/xfs/xfs_inode_item.c
parent30e05599219f3c15bd5f24190af0e33cdb4a00e5 (diff)
downloadlinux-f93e5436f0ee5a85eaa3a86d2614d215873fb18b.tar.xz
xfs: widen ondisk inode timestamps to deal with y2038+
Redesign the ondisk inode timestamps to be a simple unsigned 64-bit counter of nanoseconds since 14 Dec 1901 (i.e. the minimum time in the 32-bit unix time epoch). This enables us to handle dates up to 2486, which solves the y2038 problem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Gao Xiang <hsiangkao@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_inode_item.c')
-rw-r--r--fs/xfs/xfs_inode_item.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 94784e680543..17e20a6d8b4e 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -301,11 +301,15 @@ xfs_inode_item_format_attr_fork(
*/
static inline xfs_ictimestamp_t
xfs_inode_to_log_dinode_ts(
+ struct xfs_inode *ip,
const struct timespec64 tv)
{
struct xfs_legacy_ictimestamp *lits;
xfs_ictimestamp_t its;
+ if (xfs_inode_has_bigtime(ip))
+ return xfs_inode_encode_bigtime(tv);
+
lits = (struct xfs_legacy_ictimestamp *)&its;
lits->t_sec = tv.tv_sec;
lits->t_nsec = tv.tv_nsec;
@@ -331,9 +335,9 @@ xfs_inode_to_log_dinode(
memset(to->di_pad, 0, sizeof(to->di_pad));
memset(to->di_pad3, 0, sizeof(to->di_pad3));
- to->di_atime = xfs_inode_to_log_dinode_ts(inode->i_atime);
- to->di_mtime = xfs_inode_to_log_dinode_ts(inode->i_mtime);
- to->di_ctime = xfs_inode_to_log_dinode_ts(inode->i_ctime);
+ to->di_atime = xfs_inode_to_log_dinode_ts(ip, inode->i_atime);
+ to->di_mtime = xfs_inode_to_log_dinode_ts(ip, inode->i_mtime);
+ to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode->i_ctime);
to->di_nlink = inode->i_nlink;
to->di_gen = inode->i_generation;
to->di_mode = inode->i_mode;
@@ -355,7 +359,7 @@ xfs_inode_to_log_dinode(
if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
to->di_version = 3;
to->di_changecount = inode_peek_iversion(inode);
- to->di_crtime = xfs_inode_to_log_dinode_ts(from->di_crtime);
+ to->di_crtime = xfs_inode_to_log_dinode_ts(ip, from->di_crtime);
to->di_flags2 = from->di_flags2;
to->di_cowextsize = from->di_cowextsize;
to->di_ino = ip->i_ino;