Blame SOURCES/xfsprogs-5.10.0-xfs-explicitly-define-inode-timestamp-range.patch

f49185
From 18e3b8c234fac67c6c96e9ff34f0ab4598220fa1 Mon Sep 17 00:00:00 2001
f49185
From: "Darrick J. Wong" <darrick.wong@oracle.com>
f49185
Date: Tue, 10 Nov 2020 15:11:09 -0500
f49185
Subject: [PATCH] xfs: explicitly define inode timestamp range
f49185
f49185
Source kernel commit: 876fdc7c4f366a709ac272ef3336ae7dce58f2af
f49185
f49185
Formally define the inode timestamp ranges that existing filesystems
f49185
support, and switch the vfs timetamp ranges to use it.
f49185
f49185
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
f49185
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
f49185
Reviewed-by: Christoph Hellwig <hch@lst.de>
f49185
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
f49185
Reviewed-by: Gao Xiang <hsiangkao@redhat.com>
f49185
Reviewed-by: Dave Chinner <dchinner@redhat.com>
f49185
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
f49185
---
f49185
f49185
NOTE: we hvae no xfs_compat.h so S32_MAX etc went in xfs_fs.h
f49185
f49185
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
f49185
index 7f7b03a..5712aa0 100644
f49185
--- a/libxfs/xfs_format.h
f49185
+++ b/libxfs/xfs_format.h
f49185
@@ -839,11 +839,33 @@ typedef struct xfs_agfl {
f49185
 	    ASSERT(xfs_daddr_to_agno(mp, d) == \
f49185
 		   xfs_daddr_to_agno(mp, (d) + (len) - 1)))
f49185
 
f49185
+/*
f49185
+ * XFS Timestamps
f49185
+ * ==============
f49185
+ *
f49185
+ * Traditional ondisk inode timestamps consist of signed 32-bit counters for
f49185
+ * seconds and nanoseconds; time zero is the Unix epoch, Jan  1 00:00:00 UTC
f49185
+ * 1970, which means that the timestamp epoch is the same as the Unix epoch.
f49185
+ * Therefore, the ondisk min and max defined here can be used directly to
f49185
+ * constrain the incore timestamps on a Unix system.
f49185
+ */
f49185
 typedef struct xfs_timestamp {
f49185
 	__be32		t_sec;		/* timestamp seconds */
f49185
 	__be32		t_nsec;		/* timestamp nanoseconds */
f49185
 } xfs_timestamp_t;
f49185
 
f49185
+/*
f49185
+ * Smallest possible ondisk seconds value with traditional timestamps.  This
f49185
+ * corresponds exactly with the incore timestamp Dec 13 20:45:52 UTC 1901.
f49185
+ */
f49185
+#define XFS_LEGACY_TIME_MIN	((int64_t)S32_MIN)
f49185
+
f49185
+/*
f49185
+ * Largest possible ondisk seconds value with traditional timestamps.  This
f49185
+ * corresponds exactly with the incore timestamp Jan 19 03:14:07 UTC 2038.
f49185
+ */
f49185
+#define XFS_LEGACY_TIME_MAX	((int64_t)S32_MAX)
f49185
+
f49185
 /*
f49185
  * On-disk inode structure.
f49185
  *
f49185
diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
f49185
index fbc9031..4fa9852 100644
f49185
--- a/libxfs/xfs_fs.h
f49185
+++ b/libxfs/xfs_fs.h
f49185
@@ -694,6 +694,10 @@ struct timespec64 {
f49185
 	long		tv_nsec;		/* nanoseconds */
f49185
 };
f49185
 
f49185
+#define U32_MAX			((uint32_t)~0U)
f49185
+#define S32_MAX			((int32_t)(U32_MAX >> 1))
f49185
+#define S32_MIN			((int32_t)(-S32_MAX - 1))
f49185
+
f49185
 #ifndef HAVE_BBMACROS
f49185
 /*
f49185
  * Block I/O parameterization.	A basic block (BB) is the lowest size of