[PATCH RFC 1/3] btrfs-progs: lowmem: delay before lowmem repair starts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since lowmem mode repair is so dangerous, delay 10 seconds before
start.

Signed-off-by: Su Yue <suy.fnst@xxxxxxxxxxxxxx>
---
 check/main.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/check/main.c b/check/main.c
index 3190b5d4f293..b9997460162f 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9553,12 +9553,6 @@ int cmd_check(int argc, char **argv)
 		exit(1);
 	}
 
-	/*
-	 * experimental and dangerous
-	 */
-	if (repair && check_mode == CHECK_MODE_LOWMEM)
-		warning("low-memory mode repair support is only partial");
-
 	radix_tree_init();
 	cache_tree_init(&root_cache);
 
@@ -9600,6 +9594,28 @@ int cmd_check(int argc, char **argv)
 	if (repair)
 		ctree_flags |= OPEN_CTREE_PARTIAL;
 
+	/*
+	 * experimental and dangerous
+	 */
+	if (repair && check_mode == CHECK_MODE_LOWMEM) {
+		int delay = 10;
+
+		printf("WARNING:\n\n");
+		printf("\tLow-memory mode repair support is only partial.\n");
+		printf("\tIt's experimental and very dangerous.\n");
+		printf("\tIt may run slow or crash unexpectedly.\n");
+		printf("\tPlease backup device before running low-memory mode repair.\n");
+		printf("\tThe operation will start in %d seconds.\n", delay);
+		printf("\tUse Ctrl-C to stop it.\n");
+
+		while (delay) {
+			printf("%2d", delay--);
+			fflush(stdout);
+			sleep(1);
+		}
+		printf("\nStarting to check and repair filesystem.\n");
+	}
+
 	info = open_ctree_fs_info(argv[optind], bytenr, tree_root_bytenr,
 				  chunk_root_bytenr, ctree_flags);
 	if (!info) {
-- 
2.17.1



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux