diff mbox series

[09/10] xfs_repair: skip free space checks when upgrading

Message ID 173568779272.2710949.2287968490226708363.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [01/10] xfs_repair: allow sysadmins to add free inode btree indexes | expand

Commit Message

Darrick J. Wong Dec. 31, 2024, 11:55 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Add a debug knob to disable the free space checks when upgrading a
system.  This is extremely risky and will cause severe tire damage!!!

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 repair/globals.c    |    1 +
 repair/globals.h    |    1 +
 repair/phase2.c     |    2 ++
 repair/xfs_repair.c |   11 +++++++++++
 4 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/repair/globals.c b/repair/globals.c
index 603fea73da1654..fe9f9ac5914bb0 100644
--- a/repair/globals.c
+++ b/repair/globals.c
@@ -48,6 +48,7 @@  char	*rt_name;		/* Name of realtime device */
 int	rt_spec;		/* Realtime dev specified as option */
 int	convert_lazy_count;	/* Convert lazy-count mode on/off */
 int	lazy_count;		/* What to set if to if converting */
+bool	skip_freesp_check_on_upgrade; /* do not enable */
 bool	features_changed;	/* did we change superblock feature bits? */
 bool	add_inobtcount;		/* add inode btree counts to AGI */
 bool	add_bigtime;		/* add support for timestamps up to 2486 */
diff --git a/repair/globals.h b/repair/globals.h
index 9211e5e2432c9a..c660971080f7e4 100644
--- a/repair/globals.h
+++ b/repair/globals.h
@@ -89,6 +89,7 @@  extern char	*rt_name;		/* Name of realtime device */
 extern int	rt_spec;		/* Realtime dev specified as option */
 extern int	convert_lazy_count;	/* Convert lazy-count mode on/off */
 extern int	lazy_count;		/* What to set if to if converting */
+extern bool	skip_freesp_check_on_upgrade; /* do not enable */
 extern bool	features_changed;	/* did we change superblock feature bits? */
 extern bool	add_inobtcount;		/* add inode btree counts to AGI */
 extern bool	add_bigtime;		/* add support for timestamps up to 2486 */
diff --git a/repair/phase2.c b/repair/phase2.c
index 8dc936b572196e..780294d24c9900 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -688,6 +688,8 @@  need_check_fs_free_space(
 	struct xfs_mount		*mp,
 	const struct check_state	*old)
 {
+	if (skip_freesp_check_on_upgrade)
+		return false;
 	if (xfs_has_finobt(mp) && !(old->features & XFS_FEAT_FINOBT))
 		return true;
 	if (xfs_has_reflink(mp) && !(old->features & XFS_FEAT_REFLINK))
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index d4101f7d2297d7..55e417201b34f7 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -46,6 +46,7 @@  enum o_opt_nums {
 	BLOAD_LEAF_SLACK,
 	BLOAD_NODE_SLACK,
 	NOQUOTA,
+	SKIP_FREESP_CHECK,
 	O_MAX_OPTS,
 };
 
@@ -59,6 +60,7 @@  static char *o_opts[] = {
 	[BLOAD_LEAF_SLACK]	= "debug_bload_leaf_slack",
 	[BLOAD_NODE_SLACK]	= "debug_bload_node_slack",
 	[NOQUOTA]		= "noquota",
+	[SKIP_FREESP_CHECK]	= "debug_skip_freesp_check_on_upgrade",
 	[O_MAX_OPTS]		= NULL,
 };
 
@@ -323,6 +325,15 @@  process_args(int argc, char **argv)
 				case NOQUOTA:
 					quotacheck_skip();
 					break;
+				case SKIP_FREESP_CHECK:
+					if (!val)
+						do_abort(
+		_("-o debug_skip_freesp_check_on_upgrade requires a parameter\n"));
+					skip_freesp_check_on_upgrade = (int)strtol(val, NULL, 0);
+					if (skip_freesp_check_on_upgrade)
+						do_log(
+		_("WARNING: Allowing filesystem upgrades to proceed without free space check.  THIS MAY DESTROY YOUR FILESYSTEM!!!\n"));
+					break;
 				default:
 					unknown('o', val);
 					break;