Blame SOURCES/xfsprogs-5.10.0-mkfs-enable-the-inode-btree-counter-feature.patch

f49185
From 9eb0d6eb9066daa621e710139c8c8d50fedbabcf Mon Sep 17 00:00:00 2001
f49185
From: "Darrick J. Wong" <darrick.wong@oracle.com>
f49185
Date: Fri, 20 Nov 2020 17:03:27 -0500
f49185
Subject: [PATCH] mkfs: enable the inode btree counter feature
f49185
f49185
Teach mkfs how to enable the inode btree counter feature.
f49185
f49185
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
f49185
Reviewed-by: Brian Foster <bfoster@redhat.com>
f49185
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
f49185
---
f49185
f49185
diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
f49185
index 9d6f315..45b150f 100644
f49185
--- a/man/man8/mkfs.xfs.8
f49185
+++ b/man/man8/mkfs.xfs.8
f49185
@@ -188,6 +188,21 @@ option set. When the option
f49185
 .B \-m crc=0
f49185
 is used, the free inode btree feature is not supported and is disabled.
f49185
 .TP
f49185
+.BI inobtcount= value
f49185
+This option causes the filesystem to record the number of blocks used by
f49185
+the inode btree and the free inode btree.
f49185
+This can be used to reduce mount times when the free inode btree is enabled.
f49185
+.IP
f49185
+By default,
f49185
+.B mkfs.xfs
f49185
+will not enable this option.
f49185
+This feature is only available for filesystems created with the (default)
f49185
+.B \-m finobt=1
f49185
+option set.
f49185
+When the option
f49185
+.B \-m finobt=0
f49185
+is used, the inode btree counter feature is not supported and is disabled.
f49185
+.TP
f49185
 .BI uuid= value
f49185
 Use the given value as the filesystem UUID for the newly created filesystem.
f49185
 The default is to generate a random UUID.
f49185
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
f49185
index 16819d8..87f15f4 100644
f49185
--- a/mkfs/xfs_mkfs.c
f49185
+++ b/mkfs/xfs_mkfs.c
f49185
@@ -117,6 +117,7 @@ enum {
f49185
 	M_UUID,
f49185
 	M_RMAPBT,
f49185
 	M_REFLINK,
f49185
+	M_INOBTCNT,
f49185
 	M_MAX_OPTS,
f49185
 };
f49185
 
f49185
@@ -651,6 +652,7 @@ static struct opt_params mopts = {
f49185
 		[M_UUID] = "uuid",
f49185
 		[M_RMAPBT] = "rmapbt",
f49185
 		[M_REFLINK] = "reflink",
f49185
+		[M_INOBTCNT] = "inobtcount",
f49185
 	},
f49185
 	.subopt_params = {
f49185
 		{ .index = M_CRC,
f49185
@@ -681,6 +683,12 @@ static struct opt_params mopts = {
f49185
 		  .maxval = 1,
f49185
 		  .defaultval = 1,
f49185
 		},
f49185
+		{ .index = M_INOBTCNT,
f49185
+		  .conflicts = { { NULL, LAST_CONFLICT } },
f49185
+		  .minval = 0,
f49185
+		  .maxval = 1,
f49185
+		  .defaultval = 1,
f49185
+		},
f49185
 	},
f49185
 };
f49185
 
f49185
@@ -731,6 +739,7 @@ struct sb_feat_args {
f49185
 	bool	spinodes;		/* XFS_SB_FEAT_INCOMPAT_SPINODES */
f49185
 	bool	rmapbt;			/* XFS_SB_FEAT_RO_COMPAT_RMAPBT */
f49185
 	bool	reflink;		/* XFS_SB_FEAT_RO_COMPAT_REFLINK */
f49185
+	bool	inobtcnt;		/* XFS_SB_FEAT_RO_COMPAT_INOBTCNT */
f49185
 	bool	nodalign;
f49185
 	bool	nortalign;
f49185
 };
f49185
@@ -853,7 +862,8 @@ usage( void )
f49185
 {
f49185
 	fprintf(stderr, _("Usage: %s\n\
f49185
 /* blocksize */		[-b size=num]\n\
f49185
-/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1]\n\
f49185
+/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
f49185
+			    inobtcnt=0|1]\n\
f49185
 /* data subvol */	[-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
f49185
 			    (sunit=value,swidth=value|su=num,sw=num|noalign),\n\
f49185
 			    sectsize=num\n\
f49185
@@ -1607,6 +1617,9 @@ meta_opts_parser(
f49185
 	case M_REFLINK:
f49185
 		cli->sb_feat.reflink = getnum(value, opts, subopt);
f49185
 		break;
f49185
+	case M_INOBTCNT:
f49185
+		cli->sb_feat.inobtcnt = getnum(value, opts, subopt);
f49185
+		break;
f49185
 	default:
f49185
 		return -EINVAL;
f49185
 	}
f49185
@@ -2037,6 +2050,22 @@ _("reflink not supported without CRC support\n"));
f49185
 			usage();
f49185
 		}
f49185
 		cli->sb_feat.reflink = false;
f49185
+
f49185
+		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
f49185
+			fprintf(stderr,
f49185
+_("inode btree counters not supported without CRC support\n"));
f49185
+			usage();
f49185
+		}
f49185
+		cli->sb_feat.inobtcnt = false;
f49185
+	}
f49185
+
f49185
+	if (!cli->sb_feat.finobt) {
f49185
+		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
f49185
+			fprintf(stderr,
f49185
+_("inode btree counters not supported without finobt support\n"));
f49185
+			usage();
f49185
+		}
f49185
+		cli->sb_feat.inobtcnt = false;
f49185
 	}
f49185
 
f49185
 	if ((cli->fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) &&
f49185
@@ -3002,6 +3031,8 @@ sb_set_features(
f49185
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RMAPBT;
f49185
 	if (fp->reflink)
f49185
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
f49185
+	if (fp->inobtcnt)
f49185
+		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
f49185
 
f49185
 	/*
f49185
 	 * Sparse inode chunk support has two main inode alignment requirements.
f49185
@@ -3917,6 +3948,7 @@ main(
f49185
 			.spinodes = true,
f49185
 			.rmapbt = false,
f49185
 			.reflink = true,
f49185
+			.inobtcnt = false,
f49185
 			.parent_pointers = false,
f49185
 			.nodalign = false,
f49185
 			.nortalign = false,