Blame SOURCES/xfsprogs-5.10.0-mkfs-format-bigtime-filesystems.patch

0bf83d
From e9601810beb7d5b36a5fbd03c593cf63f685bfff 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] mkfs: format bigtime filesystems
0bf83d
0bf83d
Allow formatting with large timestamps.
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
diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
0bf83d
index 45b150f..0a115cb 100644
0bf83d
--- a/man/man8/mkfs.xfs.8
0bf83d
+++ b/man/man8/mkfs.xfs.8
0bf83d
@@ -154,6 +154,22 @@ valid
0bf83d
 are:
0bf83d
 .RS 1.2i
0bf83d
 .TP
0bf83d
+.BI bigtime= value
0bf83d
+This option enables filesystems that can handle inode timestamps from December
0bf83d
+1901 to July 2486, and quota timer expirations from January 1970 to July 2486.
0bf83d
+The value is either 0 to disable the feature, or 1 to enable large timestamps.
0bf83d
+.IP
0bf83d
+If this feature is not enabled, the filesystem can only handle timestamps from
0bf83d
+December 1901 to January 2038, and quota timers from January 1970 to February
0bf83d
+2106.
0bf83d
+.IP
0bf83d
+By default,
0bf83d
+.B mkfs.xfs
0bf83d
+will not enable this feature.
0bf83d
+If the option
0bf83d
+.B \-m crc=0
0bf83d
+is used, the large timestamp feature is not supported and is disabled.
0bf83d
+.TP
0bf83d
 .BI crc= value
0bf83d
 This is used to create a filesystem which maintains and checks CRC information
0bf83d
 in all metadata objects on disk. The value is either 0 to disable the feature,
0bf83d
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
0bf83d
index 87f15f4..b74a00b 100644
0bf83d
--- a/mkfs/xfs_mkfs.c
0bf83d
+++ b/mkfs/xfs_mkfs.c
0bf83d
@@ -118,6 +118,7 @@ enum {
0bf83d
 	M_RMAPBT,
0bf83d
 	M_REFLINK,
0bf83d
 	M_INOBTCNT,
0bf83d
+	M_BIGTIME,
0bf83d
 	M_MAX_OPTS,
0bf83d
 };
0bf83d
 
0bf83d
@@ -653,6 +654,7 @@ static struct opt_params mopts = {
0bf83d
 		[M_RMAPBT] = "rmapbt",
0bf83d
 		[M_REFLINK] = "reflink",
0bf83d
 		[M_INOBTCNT] = "inobtcount",
0bf83d
+		[M_BIGTIME] = "bigtime",
0bf83d
 	},
0bf83d
 	.subopt_params = {
0bf83d
 		{ .index = M_CRC,
0bf83d
@@ -689,6 +691,12 @@ static struct opt_params mopts = {
0bf83d
 		  .maxval = 1,
0bf83d
 		  .defaultval = 1,
0bf83d
 		},
0bf83d
+		{ .index = M_BIGTIME,
0bf83d
+		  .conflicts = { { NULL, LAST_CONFLICT } },
0bf83d
+		  .minval = 0,
0bf83d
+		  .maxval = 1,
0bf83d
+		  .defaultval = 1,
0bf83d
+		},
0bf83d
 	},
0bf83d
 };
0bf83d
 
0bf83d
@@ -740,6 +748,7 @@ struct sb_feat_args {
0bf83d
 	bool	rmapbt;			/* XFS_SB_FEAT_RO_COMPAT_RMAPBT */
0bf83d
 	bool	reflink;		/* XFS_SB_FEAT_RO_COMPAT_REFLINK */
0bf83d
 	bool	inobtcnt;		/* XFS_SB_FEAT_RO_COMPAT_INOBTCNT */
0bf83d
+	bool	bigtime;		/* XFS_SB_FEAT_INCOMPAT_BIGTIME */
0bf83d
 	bool	nodalign;
0bf83d
 	bool	nortalign;
0bf83d
 };
0bf83d
@@ -863,7 +872,7 @@ usage( void )
0bf83d
 	fprintf(stderr, _("Usage: %s\n\
0bf83d
 /* blocksize */		[-b size=num]\n\
0bf83d
 /* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
0bf83d
-			    inobtcnt=0|1]\n\
0bf83d
+			    inobtcnt=0|1,bigtime=0|1]\n\
0bf83d
 /* data subvol */	[-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
0bf83d
 			    (sunit=value,swidth=value|su=num,sw=num|noalign),\n\
0bf83d
 			    sectsize=num\n\
0bf83d
@@ -1620,6 +1629,9 @@ meta_opts_parser(
0bf83d
 	case M_INOBTCNT:
0bf83d
 		cli->sb_feat.inobtcnt = getnum(value, opts, subopt);
0bf83d
 		break;
0bf83d
+	case M_BIGTIME:
0bf83d
+		cli->sb_feat.bigtime = getnum(value, opts, subopt);
0bf83d
+		break;
0bf83d
 	default:
0bf83d
 		return -EINVAL;
0bf83d
 	}
0bf83d
@@ -2057,6 +2069,13 @@ _("inode btree counters not supported without CRC support\n"));
0bf83d
 			usage();
0bf83d
 		}
0bf83d
 		cli->sb_feat.inobtcnt = false;
0bf83d
+
0bf83d
+		if (cli->sb_feat.bigtime && cli_opt_set(&mopts, M_BIGTIME)) {
0bf83d
+			fprintf(stderr,
0bf83d
+_("timestamps later than 2038 not supported without CRC support\n"));
0bf83d
+			usage();
0bf83d
+		}
0bf83d
+		cli->sb_feat.bigtime = false;
0bf83d
 	}
0bf83d
 
0bf83d
 	if (!cli->sb_feat.finobt) {
0bf83d
@@ -3033,6 +3052,8 @@ sb_set_features(
0bf83d
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
0bf83d
 	if (fp->inobtcnt)
0bf83d
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
0bf83d
+	if (fp->bigtime)
0bf83d
+		sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_BIGTIME;
0bf83d
 
0bf83d
 	/*
0bf83d
 	 * Sparse inode chunk support has two main inode alignment requirements.
0bf83d
@@ -3952,6 +3973,7 @@ main(
0bf83d
 			.parent_pointers = false,
0bf83d
 			.nodalign = false,
0bf83d
 			.nortalign = false,
0bf83d
+			.bigtime = false,
0bf83d
 		},
0bf83d
 	};
0bf83d