Blame SOURCES/xfsprogs-5.10.0-xfs_repair-support-bigtime-timestamp-checking.patch

0bf83d
From 37c7dda1c20bfd2cc73679275bab2dd43e0ad9b8 Mon Sep 17 00:00:00 2001
0bf83d
From: "Darrick J. Wong" <darrick.wong@oracle.com>
0bf83d
Date: Fri, 20 Nov 2020 17:03:28 -0500
0bf83d
Subject: [PATCH] xfs_repair: support bigtime timestamp checking
0bf83d
0bf83d
Make sure that inodes don't have the bigtime flag set when the feature
0bf83d
is disabled, and don't check for overflows in the nanoseconds when
0bf83d
bigtime is enabled because that is no longer possible.  Also make sure
0bf83d
that quotas don't have bigtime set erroneously.
0bf83d
0bf83d
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
0bf83d
Reviewed-by: Christoph Hellwig <hch@lst.de>
0bf83d
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
0bf83d
---
0bf83d
0bf83d
NOTE: we do not have quota repair in this version of xfsprogs
0bf83d
0bf83d
diff --git a/repair/dinode.c b/repair/dinode.c
0bf83d
index 0c40f2a..561603b 100644
0bf83d
--- a/repair/dinode.c
0bf83d
+++ b/repair/dinode.c
0bf83d
@@ -2213,11 +2213,15 @@ static void
0bf83d
 check_nsec(
0bf83d
 	const char		*name,
0bf83d
 	xfs_ino_t		lino,
0bf83d
+	struct xfs_dinode	*dip,
0bf83d
 	xfs_timestamp_t		*ts,
0bf83d
 	int			*dirty)
0bf83d
 {
0bf83d
 	struct xfs_legacy_timestamp *t;
0bf83d
 
0bf83d
+	if (xfs_dinode_has_bigtime(dip))
0bf83d
+		return;
0bf83d
+
0bf83d
 	t = (struct xfs_legacy_timestamp *)ts;
0bf83d
 	if (be32_to_cpu(t->t_nsec) < NSEC_PER_SEC)
0bf83d
 		return;
0bf83d
@@ -2625,6 +2629,27 @@ _("bad (negative) size %" PRId64 " on inode %" PRIu64 "\n"),
0bf83d
 			flags2 &= ~XFS_DIFLAG2_COWEXTSIZE;
0bf83d
 		}
0bf83d
 
0bf83d
+		if (xfs_dinode_has_bigtime(dino) &&
0bf83d
+		    !xfs_sb_version_hasbigtime(&mp->m_sb)) {
0bf83d
+			if (!uncertain) {
0bf83d
+				do_warn(
0bf83d
+	_("inode %" PRIu64 " is marked bigtime but file system does not support large timestamps\n"),
0bf83d
+					lino);
0bf83d
+			}
0bf83d
+			flags2 &= ~XFS_DIFLAG2_BIGTIME;
0bf83d
+
0bf83d
+			if (no_modify) {
0bf83d
+				do_warn(_("would zero timestamps.\n"));
0bf83d
+			} else {
0bf83d
+				do_warn(_("zeroing timestamps.\n"));
0bf83d
+				dino->di_atime = 0;
0bf83d
+				dino->di_mtime = 0;
0bf83d
+				dino->di_ctime = 0;
0bf83d
+				dino->di_crtime = 0;
0bf83d
+				*dirty = 1;
0bf83d
+			}
0bf83d
+		}
0bf83d
+
0bf83d
 		if (!verify_mode && flags2 != be64_to_cpu(dino->di_flags2)) {
0bf83d
 			if (!no_modify) {
0bf83d
 				do_warn(_("fixing bad flags2.\n"));
0bf83d
@@ -2752,11 +2777,11 @@ _("Bad CoW extent size %u on inode %" PRIu64 ", "),
0bf83d
 	}
0bf83d
 
0bf83d
 	/* nsec fields cannot be larger than 1 billion */
0bf83d
-	check_nsec("atime", lino, &dino->di_atime, dirty);
0bf83d
-	check_nsec("mtime", lino, &dino->di_mtime, dirty);
0bf83d
-	check_nsec("ctime", lino, &dino->di_ctime, dirty);
0bf83d
+	check_nsec("atime", lino, dino, &dino->di_atime, dirty);
0bf83d
+	check_nsec("mtime", lino, dino, &dino->di_mtime, dirty);
0bf83d
+	check_nsec("ctime", lino, dino, &dino->di_ctime, dirty);
0bf83d
 	if (dino->di_version >= 3)
0bf83d
-		check_nsec("crtime", lino, &dino->di_crtime, dirty);
0bf83d
+		check_nsec("crtime", lino, dino, &dino->di_crtime, dirty);
0bf83d
 
0bf83d
 	/*
0bf83d
 	 * general size/consistency checks: