diff mbox series

[1/2] xfs_db: add inobtcnt upgrade path

Message ID 161238142844.1278478.2875360961680710314.stgit@magnolia (mailing list archive)
State New
Headers show
Series xfs_admin: support upgrading v5 filesystems | expand

Commit Message

Darrick J. Wong Feb. 3, 2021, 7:43 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Enable users to upgrade their filesystems to support inode btree block
counters.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 db/sb.c              |   21 +++++++++++++++++++++
 man/man8/xfs_admin.8 |    7 +++++++
 man/man8/xfs_db.8    |    3 +++
 3 files changed, 31 insertions(+)
diff mbox series

Patch

diff --git a/db/sb.c b/db/sb.c
index 223b84fe..c303c321 100644
--- a/db/sb.c
+++ b/db/sb.c
@@ -596,6 +596,7 @@  version_help(void)
 " 'version attr2'    - enable v2 inline extended attributes\n"
 " 'version log2'     - enable v2 log format\n"
 " 'version needsrepair' - flag filesystem as requiring repair\n"
+" 'version inobtcount' - enable inode btree counters\n"
 "\n"
 "The version function prints currently enabled features for a filesystem\n"
 "according to the version field of its primary superblock.\n"
@@ -856,6 +857,26 @@  version_f(
 			}
 
 			v5features.incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
+		} else if (!strcasecmp(argv[1], "inobtcount")) {
+			if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) {
+				dbprintf(
+		_("inode btree counter feature is already enabled\n"));
+				return 1;
+			}
+			if (!xfs_sb_version_hasfinobt(&mp->m_sb)) {
+				dbprintf(
+		_("inode btree counter feature cannot be enabled on filesystems lacking free inode btrees\n"));
+				exitcode = 2;
+				return 1;
+			}
+			if (!xfs_sb_version_hascrc(&mp->m_sb)) {
+				dbprintf(
+		_("inode btree counter feature cannot be enabled on pre-V5 filesystems\n"));
+				exitcode = 2;
+				return 1;
+			}
+
+			v5features.ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
 		} else if (!strcasecmp(argv[1], "extflg")) {
 			switch (XFS_SB_VERSION_NUM(&mp->m_sb)) {
 			case XFS_SB_VERSION_1:
diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8
index d8a0125c..8421e28f 100644
--- a/man/man8/xfs_admin.8
+++ b/man/man8/xfs_admin.8
@@ -131,6 +131,13 @@  Flag the filesystem as needing repairs.
 Until
 .BR xfs_repair (8)
 is run, the filesystem will not be mountable.
+.TP
+.B inobtcount
+Keep a count the number of blocks in each inode btree in the AGI.
+This reduces mount time by speeding up metadata space reservation calculations.
+The filesystem cannot be downgraded after this feature is enabled.
+Once enabled, the filesystem will not be writable by older kernels.
+This feature was added to Linux 5.10.
 .RE
 .TP
 .BI \-U " uuid"
diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8
index 792d98c8..0335317e 100644
--- a/man/man8/xfs_db.8
+++ b/man/man8/xfs_db.8
@@ -976,6 +976,9 @@  The filesystem can be flagged as requiring a run through
 if the
 .B needsrepair
 option is specified and the filesystem is formatted with the V5 format.
+Support for the inode btree counters feature can be enabled by using the
+.B inobtcount
+option if the filesystem is formatted with the V5 format.
 .IP
 If no argument is given, the current version and feature bits are printed.
 With one argument, this command will write the updated version number