diff mbox series

[4/4] xfsprogs: Add wideextcnt mkfs option

Message ID 20200831130102.507-5-chandanrlinux@gmail.com (mailing list archive)
State New
Headers show
Series xfsprogs: Extend per-inode extent counters | expand

Commit Message

Chandan Babu R Aug. 31, 2020, 1:01 p.m. UTC
Enabling wideextcnt option on mkfs.xfs command line causes the
filesystem inodes to have 47-bit data fork extent counters and 32-bit
attr fork extent counters. This also sets the
XFS_SB_FEAT_INCOMPAT_WIDEEXTCNT incompat flag on the superblock
preventing older kernels from mounting such a filesystem.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
 man/man8/mkfs.xfs.8 |  7 +++++++
 mkfs/xfs_mkfs.c     | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)
diff mbox series

Patch

diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
index 9d762a43..80378722 100644
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8
@@ -522,6 +522,13 @@  space over time such that no free extents are large enough to
 accommodate a chunk of 64 inodes. Without this feature enabled, inode
 allocations can fail with out of space errors under severe fragmented
 free space conditions.
+.TP
+.BI wideextcnt[= value]
+Extend inode data and attr fork extent counters from signed 32-bits and signed
+16-bits to unsigned 47-bits and unsigned 32-bits respectively. If the value is
+omitted, 1 is assumed. Wide extent count feature is disabled by default. This
+feature is only available for filesystems formatted with -m crc=1.
+.TP
 .RE
 .TP
 .BI \-l " log_section_options"
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 2e6cd280..ff3e0705 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -71,6 +71,7 @@  enum {
 	I_ATTR,
 	I_PROJID32BIT,
 	I_SPINODES,
+	I_WIDEEXTCNT,
 	I_MAX_OPTS,
 };
 
@@ -383,6 +384,7 @@  static struct opt_params iopts = {
 		[I_ATTR] = "attr",
 		[I_PROJID32BIT] = "projid32bit",
 		[I_SPINODES] = "sparse",
+		[I_WIDEEXTCNT] = "wideextcnt",
 	},
 	.subopt_params = {
 		{ .index = I_ALIGN,
@@ -431,6 +433,12 @@  static struct opt_params iopts = {
 		  .maxval = 1,
 		  .defaultval = 1,
 		},
+		{ .index = I_WIDEEXTCNT,
+		  .conflicts = { { NULL, LAST_CONFLICT } },
+		  .minval = 0,
+		  .maxval = 1,
+		  .defaultval = 1,
+		}
 	},
 };
 
@@ -734,6 +742,7 @@  struct sb_feat_args {
 	bool	reflink;		/* XFS_SB_FEAT_RO_COMPAT_REFLINK */
 	bool	nodalign;
 	bool	nortalign;
+	bool	wideextcnt;
 };
 
 struct cli_params {
@@ -1469,6 +1478,9 @@  inode_opts_parser(
 	case I_SPINODES:
 		cli->sb_feat.spinodes = getnum(value, opts, subopt);
 		break;
+	case I_WIDEEXTCNT:
+		cli->sb_feat.wideextcnt = getnum(value, opts, subopt);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1972,6 +1984,14 @@  _("reflink not supported without CRC support\n"));
 			usage();
 		}
 		cli->sb_feat.reflink = false;
+
+		if (cli->sb_feat.wideextcnt &&
+			cli_opt_set(&iopts, I_WIDEEXTCNT)) {
+			fprintf(stderr,
+_("wideextcnt inodes not supported without CRC support\n"));
+			usage();
+		}
+		cli->sb_feat.wideextcnt = false;
 	}
 
 	if ((cli->fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) &&
@@ -2953,6 +2973,8 @@  sb_set_features(
 		sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_SPINODES;
 	}
 
+	if (fp->wideextcnt)
+		sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_WIDEEXTCNT;
 }
 
 /*
@@ -3608,6 +3630,7 @@  main(
 			.parent_pointers = false,
 			.nodalign = false,
 			.nortalign = false,
+			.wideextcnt = false,
 		},
 	};