diff mbox series

[18/18] mkfs: format bigtime filesystems

Message ID 159770524797.3958786.6498012041319904192.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfsprogs: widen timestamps to deal with y2038 | expand

Commit Message

Darrick J. Wong Aug. 17, 2020, 11 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Allow formatting with large timestamps.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 man/man8/mkfs.xfs.8 |   16 ++++++++++++++++
 mkfs/xfs_mkfs.c     |   24 +++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

Comments

Amir Goldstein Aug. 18, 2020, 2:45 p.m. UTC | #1
On Tue, Aug 18, 2020 at 2:23 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Allow formatting with large timestamps.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Amir Goldstein <amir73il@gmail.com>

Other than one comment below...

> ---
>  man/man8/mkfs.xfs.8 |   16 ++++++++++++++++
>  mkfs/xfs_mkfs.c     |   24 +++++++++++++++++++++++-
>  2 files changed, 39 insertions(+), 1 deletion(-)
>
>
> diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
> index 082f3ab6c063..7434b9f2b4cd 100644
> --- a/man/man8/mkfs.xfs.8
> +++ b/man/man8/mkfs.xfs.8
> @@ -154,6 +154,22 @@ valid
>  are:
>  .RS 1.2i
>  .TP
> +.BI bigtime= value
> +This option enables filesystems that can handle inode timestamps from December
> +1901 to July 2486, and quota timer expirations from January 1970 to July 2486.
> +The value is either 0 to disable the feature, or 1 to enable large timestamps.
> +.IP
> +If this feature is not enabled, the filesystem can only handle timestamps from
> +December 1901 to January 2038, and quota timers from January 1970 to February
> +2106.
> +.IP
> +By default,
> +.B mkfs.xfs
> +will not enable this feature.
> +If the option
> +.B \-m crc=0
> +is used, the large timestamp feature is not supported and is disabled.
> +.TP
>  .BI crc= value
>  This is used to create a filesystem which maintains and checks CRC information
>  in all metadata objects on disk. The value is either 0 to disable the feature,
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 037246effd70..f9f78a020092 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -120,6 +120,7 @@ enum {
>         M_RMAPBT,
>         M_REFLINK,
>         M_INOBTCNT,
> +       M_BIGTIME,
>         M_MAX_OPTS,
>  };
>
> @@ -667,6 +668,7 @@ static struct opt_params mopts = {
>                 [M_RMAPBT] = "rmapbt",
>                 [M_REFLINK] = "reflink",
>                 [M_INOBTCNT] = "inobtcount",
> +               [M_BIGTIME] = "bigtime",
>         },
>         .subopt_params = {
>                 { .index = M_CRC,
> @@ -703,6 +705,12 @@ static struct opt_params mopts = {
>                   .maxval = 1,
>                   .defaultval = 1,
>                 },
> +               { .index = M_BIGTIME,
> +                 .conflicts = { { NULL, LAST_CONFLICT } },
> +                 .minval = 0,
> +                 .maxval = 1,
> +                 .defaultval = 1,

                 .defaultval = 0 ?

Thanks,
Amir.
Darrick J. Wong Aug. 18, 2020, 3:34 p.m. UTC | #2
On Tue, Aug 18, 2020 at 05:45:41PM +0300, Amir Goldstein wrote:
> On Tue, Aug 18, 2020 at 2:23 AM Darrick J. Wong <darrick.wong@oracle.com> wrote:
> >
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Allow formatting with large timestamps.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> 
> Other than one comment below...
> 
> > ---
> >  man/man8/mkfs.xfs.8 |   16 ++++++++++++++++
> >  mkfs/xfs_mkfs.c     |   24 +++++++++++++++++++++++-
> >  2 files changed, 39 insertions(+), 1 deletion(-)
> >
> >
> > diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
> > index 082f3ab6c063..7434b9f2b4cd 100644
> > --- a/man/man8/mkfs.xfs.8
> > +++ b/man/man8/mkfs.xfs.8
> > @@ -154,6 +154,22 @@ valid
> >  are:
> >  .RS 1.2i
> >  .TP
> > +.BI bigtime= value
> > +This option enables filesystems that can handle inode timestamps from December
> > +1901 to July 2486, and quota timer expirations from January 1970 to July 2486.
> > +The value is either 0 to disable the feature, or 1 to enable large timestamps.
> > +.IP
> > +If this feature is not enabled, the filesystem can only handle timestamps from
> > +December 1901 to January 2038, and quota timers from January 1970 to February
> > +2106.
> > +.IP
> > +By default,
> > +.B mkfs.xfs
> > +will not enable this feature.
> > +If the option
> > +.B \-m crc=0
> > +is used, the large timestamp feature is not supported and is disabled.
> > +.TP
> >  .BI crc= value
> >  This is used to create a filesystem which maintains and checks CRC information
> >  in all metadata objects on disk. The value is either 0 to disable the feature,
> > diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> > index 037246effd70..f9f78a020092 100644
> > --- a/mkfs/xfs_mkfs.c
> > +++ b/mkfs/xfs_mkfs.c
> > @@ -120,6 +120,7 @@ enum {
> >         M_RMAPBT,
> >         M_REFLINK,
> >         M_INOBTCNT,
> > +       M_BIGTIME,
> >         M_MAX_OPTS,
> >  };
> >
> > @@ -667,6 +668,7 @@ static struct opt_params mopts = {
> >                 [M_RMAPBT] = "rmapbt",
> >                 [M_REFLINK] = "reflink",
> >                 [M_INOBTCNT] = "inobtcount",
> > +               [M_BIGTIME] = "bigtime",
> >         },
> >         .subopt_params = {
> >                 { .index = M_CRC,
> > @@ -703,6 +705,12 @@ static struct opt_params mopts = {
> >                   .maxval = 1,
> >                   .defaultval = 1,
> >                 },
> > +               { .index = M_BIGTIME,
> > +                 .conflicts = { { NULL, LAST_CONFLICT } },
> > +                 .minval = 0,
> > +                 .maxval = 1,
> > +                 .defaultval = 1,
> 
>                  .defaultval = 0 ?

The (somewhat misnamed) defaultval determines the implied value if the
user doesn't specify one, e.g. "-m bigtime" instead of "-m bigtime=1".
Therefore, we want it to default to 1 like all the other feature flag
arguments.

Thanks for reviewing most of this featureset! :)

--D

> 
> Thanks,
> Amir.
diff mbox series

Patch

diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
index 082f3ab6c063..7434b9f2b4cd 100644
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8
@@ -154,6 +154,22 @@  valid
 are:
 .RS 1.2i
 .TP
+.BI bigtime= value
+This option enables filesystems that can handle inode timestamps from December
+1901 to July 2486, and quota timer expirations from January 1970 to July 2486.
+The value is either 0 to disable the feature, or 1 to enable large timestamps.
+.IP
+If this feature is not enabled, the filesystem can only handle timestamps from
+December 1901 to January 2038, and quota timers from January 1970 to February
+2106.
+.IP
+By default,
+.B mkfs.xfs
+will not enable this feature.
+If the option
+.B \-m crc=0
+is used, the large timestamp feature is not supported and is disabled.
+.TP
 .BI crc= value
 This is used to create a filesystem which maintains and checks CRC information
 in all metadata objects on disk. The value is either 0 to disable the feature,
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 037246effd70..f9f78a020092 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -120,6 +120,7 @@  enum {
 	M_RMAPBT,
 	M_REFLINK,
 	M_INOBTCNT,
+	M_BIGTIME,
 	M_MAX_OPTS,
 };
 
@@ -667,6 +668,7 @@  static struct opt_params mopts = {
 		[M_RMAPBT] = "rmapbt",
 		[M_REFLINK] = "reflink",
 		[M_INOBTCNT] = "inobtcount",
+		[M_BIGTIME] = "bigtime",
 	},
 	.subopt_params = {
 		{ .index = M_CRC,
@@ -703,6 +705,12 @@  static struct opt_params mopts = {
 		  .maxval = 1,
 		  .defaultval = 1,
 		},
+		{ .index = M_BIGTIME,
+		  .conflicts = { { NULL, LAST_CONFLICT } },
+		  .minval = 0,
+		  .maxval = 1,
+		  .defaultval = 1,
+		},
 	},
 };
 
@@ -755,6 +763,7 @@  struct sb_feat_args {
 	bool	rmapbt;			/* XFS_SB_FEAT_RO_COMPAT_RMAPBT */
 	bool	reflink;		/* XFS_SB_FEAT_RO_COMPAT_REFLINK */
 	bool	inobtcnt;		/* XFS_SB_FEAT_RO_COMPAT_INOBTCNT */
+	bool	bigtime;		/* XFS_SB_FEAT_INCOMPAT_BIGTIME */
 	bool	nodalign;
 	bool	nortalign;
 };
@@ -878,7 +887,7 @@  usage( void )
 	fprintf(stderr, _("Usage: %s\n\
 /* blocksize */		[-b size=num]\n\
 /* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
-			    inobtcnt=0|1]\n\
+			    inobtcnt=0|1,bigtime=0|1]\n\
 /* data subvol */	[-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
 			    (sunit=value,swidth=value|su=num,sw=num|noalign),\n\
 			    sectsize=num\n\
@@ -1621,6 +1630,9 @@  meta_opts_parser(
 	case M_INOBTCNT:
 		cli->sb_feat.inobtcnt = getnum(value, opts, subopt);
 		break;
+	case M_BIGTIME:
+		cli->sb_feat.bigtime = getnum(value, opts, subopt);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -2044,6 +2056,13 @@  _("reflink not supported without CRC support\n"));
 			usage();
 		}
 		cli->sb_feat.reflink = false;
+
+		if (cli->sb_feat.bigtime) {
+			fprintf(stderr,
+_("big timestamps not supported without CRC support\n"));
+			usage();
+		}
+		cli->sb_feat.bigtime = false;
 	}
 
 	if (!cli->sb_feat.finobt) {
@@ -3020,6 +3039,8 @@  sb_set_features(
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
 	if (fp->inobtcnt)
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
+	if (fp->bigtime)
+		sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_BIGTIME;
 
 	/*
 	 * Sparse inode chunk support has two main inode alignment requirements.
@@ -3692,6 +3713,7 @@  main(
 			.parent_pointers = false,
 			.nodalign = false,
 			.nortalign = false,
+			.bigtime = false,
 		},
 	};