All of lore.kernel.org
 help / color / mirror / Atom feed
From: Su Yue <suy.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <suy.fnst@cn.fujitsu.com>
Subject: [PATCH RFC 1/3] btrfs-progs: lowmem: delay before lowmem repair starts
Date: Mon, 2 Jul 2018 17:28:18 +0800	[thread overview]
Message-ID: <20180702092820.16285-2-suy.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <20180702092820.16285-1-suy.fnst@cn.fujitsu.com>

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

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 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




  reply	other threads:[~2018-07-02  9:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02  9:28 [PATCH RFC 0/3] btrfs-progs: lowmem: delay before lowmem repair Su Yue
2018-07-02  9:28 ` Su Yue [this message]
2018-07-02  9:28 ` [PATCH RFC 2/3] btrfs-progs: lowmem: force to start without delay with option '--force-repair-lowmem' Su Yue
2018-07-02  9:28 ` [PATCH RFC 3/3] btrfs-progs: tests: append '--force-repair-lowmem' if lowmem repair is enabled Su Yue
2018-07-02  9:43 ` [PATCH RFC 0/3] btrfs-progs: lowmem: delay before lowmem repair Nikolay Borisov
2018-07-02 11:07   ` David Disseldorp
2018-07-02 11:09     ` Nikolay Borisov
2018-07-02 13:57       ` Su Yue
2018-07-02 14:01   ` Su Yue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180702092820.16285-2-suy.fnst@cn.fujitsu.com \
    --to=suy.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.