From patchwork Tue Jan 27 15:05:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Mills X-Patchwork-Id: 5718351 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E5F6EC058D for ; Tue, 27 Jan 2015 15:06:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A7F620221 for ; Tue, 27 Jan 2015 15:06:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE32F20218 for ; Tue, 27 Jan 2015 15:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758521AbbA0PGE (ORCPT ); Tue, 27 Jan 2015 10:06:04 -0500 Received: from frost.carfax.org.uk ([85.119.82.111]:37927 "EHLO frost.carfax.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581AbbA0PGD (ORCPT ); Tue, 27 Jan 2015 10:06:03 -0500 Received: from hrm by frost.carfax.org.uk with local (Exim 4.80) (envelope-from ) id 1YG7iM-0004Wd-0O; Tue, 27 Jan 2015 15:06:02 +0000 From: Hugo Mills To: linux-btrfs@vger.kernel.org, dsterba@suse.cz Cc: Hugo Mills Subject: [PATCH 2/2] btrfs-progs: Add --readonly flag Date: Tue, 27 Jan 2015 15:05:53 +0000 Message-Id: <1422371153-17355-2-git-send-email-hugo@carfax.org.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1422371153-17355-1-git-send-email-hugo@carfax.org.uk> References: <1422371153-17355-1-git-send-email-hugo@carfax.org.uk> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Particularly during support conversations, people get confused about which options to use with btrfs check. Adding a flag, --readonly, which implies the default read-only behaviour and which conflicts with the read-write operations, should help make the behaviour of the tool clear. Signed-off-by: Hugo Mills --- cmds-check.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index a1226c6..d4d2e73 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -8403,11 +8403,13 @@ out: return bad_roots; } -enum { OPT_REPAIR = 257, OPT_INIT_CSUM, OPT_INIT_EXTENT, OPT_CHECK_CSUM }; +enum { OPT_REPAIR = 257, OPT_READONLY, OPT_INIT_CSUM, OPT_INIT_EXTENT, + OPT_CHECK_CSUM }; static struct option long_options[] = { { "super", 1, NULL, 's' }, { "repair", 0, NULL, OPT_REPAIR }, + { "readonly", 0, NULL, OPT_READONLY }, { "init-csum-tree", 0, NULL, OPT_INIT_CSUM }, { "init-extent-tree", 0, NULL, OPT_INIT_EXTENT }, { "check-data-csum", 0, NULL, OPT_CHECK_CSUM }, @@ -8447,6 +8449,7 @@ int cmd_check(int argc, char **argv) u64 num; int option_index = 0; int init_csum_tree = 0; + int readonly = 0; int qgroup_report = 0; enum btrfs_open_ctree_flags ctree_flags = OPEN_CTREE_EXCLUSIVE; @@ -8490,6 +8493,9 @@ int cmd_check(int argc, char **argv) repair = 1; ctree_flags |= OPEN_CTREE_WRITES; break; + case OPT_READONLY: + readonly = 1; + break; case OPT_INIT_CSUM: printf("Creating a new CRC tree\n"); init_csum_tree = 1; @@ -8512,6 +8518,12 @@ int cmd_check(int argc, char **argv) if (check_argc_exact(argc, 1)) usage(cmd_check_usage); + /* This check is the only reason for --readonly to exist */ + if (readonly && repair) { + fprintf(stderr, "Repair options are not compatible with --readonly\n"); + exit(1); + } + radix_tree_init(); cache_tree_init(&root_cache);