From patchwork Mon Jan 19 07:27:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Chengniang X-Patchwork-Id: 5655151 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 90C4A9F333 for ; Mon, 19 Jan 2015 07:30:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC90E2014A for ; Mon, 19 Jan 2015 07:30:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC47F20353 for ; Mon, 19 Jan 2015 07:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751211AbbASH3D (ORCPT ); Mon, 19 Jan 2015 02:29:03 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:37807 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751166AbbASH3C (ORCPT ); Mon, 19 Jan 2015 02:29:02 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56255515" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Jan 2015 15:24:57 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t0J7RliP025185; Mon, 19 Jan 2015 15:27:47 +0800 Received: from fan-Lenovo.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 19 Jan 2015 15:28:27 +0800 From: Fan Chengniang To: CC: , Fan Chengniang Subject: [PATCH v2 1/2] btrfs-progs:btrfstune:force to set seeding flags Date: Mon, 19 Jan 2015 15:27:30 +0800 Message-ID: <1421652451-994-1-git-send-email-fancn.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.45] 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 Now we can use -f with -S option when setting seeding flags or clearing seeding flags Reported-by: Chen Hanxiao Signed-off-by: Fan Chengniang --- Documentation/btrfstune.txt | 2 +- btrfstune.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/btrfstune.txt b/Documentation/btrfstune.txt index d49a974..2448e27 100644 --- a/Documentation/btrfstune.txt +++ b/Documentation/btrfstune.txt @@ -25,7 +25,7 @@ Enable extended inode refs. -x:: Enable skinny metadata extent refs. -f:: -Allow dangerous changes, e.g. clear the seeding flag +Force to set or clear seeding flag. Allow dangerous changes, e.g. clear the seeding flag When mounting the new device, btrfs will check whether the seeding flag is set when try to open seeding device. If the user clears the seeding flag of the diff --git a/btrfstune.c b/btrfstune.c index 050418a..15f68c8 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -33,6 +33,7 @@ #include "version.h" static char *device; +static int force = 0; static int update_seeding_flag(struct btrfs_root *root, int set_flag) { @@ -44,8 +45,10 @@ static int update_seeding_flag(struct btrfs_root *root, int set_flag) super_flags = btrfs_super_flags(disk_super); if (set_flag) { if (super_flags & BTRFS_SUPER_FLAG_SEEDING) { - fprintf(stderr, "seeding flag is already set on %s\n", - device); + if (force) + return 0; + else + fprintf(stderr, "seeding flag is already set on %s\n", device); return 1; } super_flags |= BTRFS_SUPER_FLAG_SEEDING; @@ -104,7 +107,7 @@ static void print_usage(void) fprintf(stderr, "\t-S value\tpositive value will enable seeding, zero to disable, negative is not allowed\n"); fprintf(stderr, "\t-r \t\tenable extended inode refs\n"); fprintf(stderr, "\t-x \t\tenable skinny metadata extent refs\n"); - fprintf(stderr, "\t-f \t\tforce to clear flags, make sure that you are aware of the dangers\n"); + fprintf(stderr, "\t-f \t\tforce to set or clear flags, make sure that you are aware of the dangers\n"); } int main(int argc, char *argv[]) @@ -115,7 +118,6 @@ int main(int argc, char *argv[]) int seeding_flag = 0; u64 seeding_value = 0; int skinny_flag = 0; - int force = 0; int ret; optind = 1;