summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_inode_item_recover.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_recover.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_recover.c')
-rw-r--r--fs/xfs/xfs_inode_item_recover.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c
index 4e895c9ad4d7..cb44f7653f03 100644
--- a/fs/xfs/xfs_inode_item_recover.c
+++ b/fs/xfs/xfs_inode_item_recover.c
@@ -115,15 +115,25 @@ out_free_ip:
return error;
}
+static inline bool xfs_log_dinode_has_bigtime(const struct xfs_log_dinode *ld)
+{
+ return ld->di_version >= 3 &&
+ (ld->di_flags2 & XFS_DIFLAG2_BIGTIME);
+}
+
/* Convert a log timestamp to an ondisk timestamp. */
static inline xfs_timestamp_t
xfs_log_dinode_to_disk_ts(
+ struct xfs_log_dinode *from,
const xfs_ictimestamp_t its)
{
struct xfs_legacy_timestamp *lts;
struct xfs_legacy_ictimestamp *lits;
xfs_timestamp_t ts;
+ if (xfs_log_dinode_has_bigtime(from))
+ return cpu_to_be64(its);
+
lts = (struct xfs_legacy_timestamp *)&ts;
lits = (struct xfs_legacy_ictimestamp *)&its;
lts->t_sec = cpu_to_be32(lits->t_sec);
@@ -149,9 +159,9 @@ xfs_log_dinode_to_disk(
to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
- to->di_atime = xfs_log_dinode_to_disk_ts(from->di_atime);
- to->di_mtime = xfs_log_dinode_to_disk_ts(from->di_mtime);
- to->di_ctime = xfs_log_dinode_to_disk_ts(from->di_ctime);
+ to->di_atime = xfs_log_dinode_to_disk_ts(from, from->di_atime);
+ to->di_mtime = xfs_log_dinode_to_disk_ts(from, from->di_mtime);
+ to->di_ctime = xfs_log_dinode_to_disk_ts(from, from->di_ctime);
to->di_size = cpu_to_be64(from->di_size);
to->di_nblocks = cpu_to_be64(from->di_nblocks);
@@ -167,7 +177,8 @@ xfs_log_dinode_to_disk(
if (from->di_version == 3) {
to->di_changecount = cpu_to_be64(from->di_changecount);
- to->di_crtime = xfs_log_dinode_to_disk_ts(from->di_crtime);
+ to->di_crtime = xfs_log_dinode_to_disk_ts(from,
+ from->di_crtime);
to->di_flags2 = cpu_to_be64(from->di_flags2);
to->di_cowextsize = cpu_to_be32(from->di_cowextsize);
to->di_ino = cpu_to_be64(from->di_ino);