From patchwork Tue Mar 7 05:42:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 9608121 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 5F0B86046A for ; Tue, 7 Mar 2017 06:23:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4701A28429 for ; Tue, 7 Mar 2017 06:23:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B7F428458; Tue, 7 Mar 2017 06:23:13 +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=-6.9 required=2.0 tests=BAYES_00,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 8450B28429 for ; Tue, 7 Mar 2017 06:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753429AbdCGGXL (ORCPT ); Tue, 7 Mar 2017 01:23:11 -0500 Received: from tartarus.angband.pl ([89.206.35.136]:40894 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754694AbdCGGXJ (ORCPT ); Tue, 7 Mar 2017 01:23:09 -0500 Received: from umbar.angband.pl ([2001:6a0:118::6]) by tartarus.angband.pl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.88) (envelope-from ) id 1cl7tk-0006sw-4Y; Tue, 07 Mar 2017 06:43:02 +0100 Received: from kilobyte by umbar.angband.pl with local (Exim 4.89_RC7) (envelope-from ) id 1cl7tj-00019K-IV; Tue, 07 Mar 2017 06:42:59 +0100 From: Adam Borowski To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Cc: Adam Borowski Date: Tue, 7 Mar 2017 06:42:51 +0100 Message-Id: <20170307054251.4361-1-kilobyte@angband.pl> X-Mailer: git-send-email 2.11.0 X-SA-Exim-Connect-IP: 2001:6a0:118::6 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH] btrfs: fix a bogus warning when converting only data or metadata X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) 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 If your filesystem has, eg, data:raid0 metadata:raid1, and you run "btrfs balance -dconvert=raid1", the meta.target field will be uninitialized. That's otherwise ok, as it's unused except for this warning. Thus, let's use the existing set of raid levels for the comparison. As a side effect, non-convert balances will now nag about data>metadata. Signed-off-by: Adam Borowski --- To reproduce: dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb mkfs.btrfs ra rb # defaults to -draid0 -mraid1 losetup -f ra losetup -f rb mount /dev/loop0 /mnt/vol1 btrfs balance start -dconvert=raid1 /mnt/vol1 fs/btrfs/volumes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3645af2749f8..c016db81ba43 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3846,6 +3846,11 @@ int btrfs_balance(struct btrfs_balance_control *bctl, } } while (read_seqretry(&fs_info->profiles_lock, seq)); + /* if we're not converting, the target field is uninitialized */ + if (!(bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT)) + bctl->meta.target = fs_info->avail_metadata_alloc_bits; + if (!(bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT)) + bctl->data.target = fs_info->avail_data_alloc_bits; if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) < btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) { btrfs_warn(fs_info,