From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B998C10F14 for ; Thu, 3 Oct 2019 16:52:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E2E72133F for ; Thu, 3 Oct 2019 16:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570121542; bh=aF9CpfdxUg0KgzY0DPJtD5O3gsmdeYqLg5p8jigGk1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=thF7Pf7X27BzO/ygVapunoeESqDXhPtXnU70ygAovjHlGG2UK9gWfWhUhQAaVf1JH PtjGfnfubF5hOEjhxklYnCRY7I6YJilvmm08hJ2vntZv7Md2mR7oqUWQj1fHqlweZk uJRZvgguLcEMj6IwGzf95FXHFA3ZsLHlBGG2lMAk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405693AbfJCQwS (ORCPT ); Thu, 3 Oct 2019 12:52:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:39856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405685AbfJCQwR (ORCPT ); Thu, 3 Oct 2019 12:52:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64DD220867; Thu, 3 Oct 2019 16:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570121536; bh=aF9CpfdxUg0KgzY0DPJtD5O3gsmdeYqLg5p8jigGk1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uNO8mt5xlPahzAQkr+ykEP148sznszzOcvLpyrobc8mTThZVHzSc9pa2Nn3NlH1OA 0dwDLYqwFadjXqXKFa9A7fwpkFPHRo42GDaBTV7dCCge+LYQ+N5PaS0N/0bSMAYuxo SUYM4Mnv6xRYAVd7JoPklJaLS7DVSLwRdr+ClfwU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Murphy , Anand Jain , Qu Wenruo , David Sterba Subject: [PATCH 5.3 316/344] btrfs: Fix a regression which we cant convert to SINGLE profile Date: Thu, 3 Oct 2019 17:54:41 +0200 Message-Id: <20191003154610.279347902@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154540.062170222@linuxfoundation.org> References: <20191003154540.062170222@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qu Wenruo commit fab273595507a9ec7035df6d5512a955d80a80ba upstream. [BUG] With v5.3 kernel, we can't convert to SINGLE profile: # btrfs balance start -f -dconvert=single $mnt ERROR: error during balancing '/mnt/btrfs': Invalid argument # dmesg -t | tail validate_convert_profile: data profile=0x1000000000000 allowed=0x20 is_valid=1 final=0x1000000000000 ret=1 BTRFS error (device dm-3): balance: invalid convert data profile single [CAUSE] With the extra debug output added, it shows that the @allowed bit is lacking the special in-memory only SINGLE profile bit. Thus we fail at that (profile & ~allowed) check. This regression is caused by commit 081db89b13cb ("btrfs: use raid_attr to get allowed profiles for balance conversion") and the fact that we don't use any bit to indicate SINGLE profile on-disk, but uses special in-memory only bit to help distinguish different profiles. [FIX] Add that BTRFS_AVAIL_ALLOC_BIT_SINGLE to @allowed, so the code should be the same as it was and fix the regression. Reported-by: Chris Murphy Fixes: 081db89b13cb ("btrfs: use raid_attr to get allowed profiles for balance conversion") CC: stable@vger.kernel.org # 5.3+ Reviewed-by: Anand Jain Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/volumes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4072,7 +4072,13 @@ int btrfs_balance(struct btrfs_fs_info * } num_devices = btrfs_num_devices(fs_info); - allowed = 0; + + /* + * SINGLE profile on-disk has no profile bit, but in-memory we have a + * special bit for it, to make it easier to distinguish. Thus we need + * to set it manually, or balance would refuse the profile. + */ + allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE; for (i = 0; i < ARRAY_SIZE(btrfs_raid_array); i++) if (num_devices >= btrfs_raid_array[i].devs_min) allowed |= btrfs_raid_array[i].bg_flag;