From patchwork Mon Jul 2 09:28:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 10500779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0684F60325 for ; Mon, 2 Jul 2018 09:22:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBA2128628 for ; Mon, 2 Jul 2018 09:22:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9E752863D; Mon, 2 Jul 2018 09:22:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87D1E28682 for ; Mon, 2 Jul 2018 09:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753874AbeGBJWI (ORCPT ); Mon, 2 Jul 2018 05:22:08 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:25975 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753849AbeGBJWG (ORCPT ); Mon, 2 Jul 2018 05:22:06 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="41736426" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Jul 2018 17:22:02 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id C47E24B43D5E for ; Mon, 2 Jul 2018 17:22:00 +0800 (CST) Received: from archlinux.g08.fujitsu.local (10.167.226.31) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Mon, 2 Jul 2018 17:22:06 +0800 From: Su Yue To: CC: Subject: [PATCH RFC 1/3] btrfs-progs: lowmem: delay before lowmem repair starts Date: Mon, 2 Jul 2018 17:28:18 +0800 Message-ID: <20180702092820.16285-2-suy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180702092820.16285-1-suy.fnst@cn.fujitsu.com> References: <20180702092820.16285-1-suy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.31] X-yoursite-MailScanner-ID: C47E24B43D5E.A91B0 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: suy.fnst@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since lowmem mode repair is so dangerous, delay 10 seconds before start. Signed-off-by: Su Yue --- 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) {