diff mbox series

[10/10] xfs_repair: allow adding rmapbt to reflink filesystems

Message ID 173568779287.2710949.3018758018747416020.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>

New debugging knob so that I can upgrade a filesystem to have rmap
btrees even if reflink was already enabled.  We cannot easily precompute
the space requirements, so this is dangerous.

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

Patch

diff --git a/repair/globals.c b/repair/globals.c
index fe9f9ac5914bb0..f4f1d317917183 100644
--- a/repair/globals.c
+++ b/repair/globals.c
@@ -49,6 +49,7 @@  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	allow_rmapbt_upgrade_with_reflink; /* add rmapbt when reflink already on */
 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 c660971080f7e4..febbbbcc81f931 100644
--- a/repair/globals.h
+++ b/repair/globals.h
@@ -90,6 +90,7 @@  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	allow_rmapbt_upgrade_with_reflink; /* add rmapbt when reflink already on */
 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 780294d24c9900..29a406f69ca3a1 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -283,7 +283,8 @@  set_rmapbt(
 		exit(0);
 	}
 
-	if (xfs_has_reflink(mp) && !add_reflink) {
+	if (xfs_has_reflink(mp) && !add_reflink &&
+	    !allow_rmapbt_upgrade_with_reflink) {
 		printf(
 	_("Reverse mapping btrees cannot be added when reflink is enabled.\n"));
 		exit(0);
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index 55e417201b34f7..4cff11d81d6bcb 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -47,6 +47,7 @@  enum o_opt_nums {
 	BLOAD_NODE_SLACK,
 	NOQUOTA,
 	SKIP_FREESP_CHECK,
+	ALLOW_RMAPBT_UPGRADE_WITH_REFLINK,
 	O_MAX_OPTS,
 };
 
@@ -61,6 +62,7 @@  static char *o_opts[] = {
 	[BLOAD_NODE_SLACK]	= "debug_bload_node_slack",
 	[NOQUOTA]		= "noquota",
 	[SKIP_FREESP_CHECK]	= "debug_skip_freesp_check_on_upgrade",
+	[ALLOW_RMAPBT_UPGRADE_WITH_REFLINK] = "debug_allow_rmapbt_upgrade_with_reflink",
 	[O_MAX_OPTS]		= NULL,
 };
 
@@ -334,6 +336,15 @@  process_args(int argc, char **argv)
 						do_log(
 		_("WARNING: Allowing filesystem upgrades to proceed without free space check.  THIS MAY DESTROY YOUR FILESYSTEM!!!\n"));
 					break;
+				case ALLOW_RMAPBT_UPGRADE_WITH_REFLINK:
+					if (!val)
+						do_abort(
+		_("-o debug_allow_rmapbt_upgrade_with_reflink requires a parameter\n"));
+					allow_rmapbt_upgrade_with_reflink = (int)strtol(val, NULL, 0);
+					if (allow_rmapbt_upgrade_with_reflink)
+						do_log(
+		_("WARNING: Allowing filesystem upgrade to rmapbt when reflink enabled.  THIS MAY DESTROY YOUR FILESYSTEM!!!\n"));
+					break;
 				default:
 					unknown('o', val);
 					break;