From patchwork Wed Feb 13 20:59:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Philipp X-Patchwork-Id: 2139471 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F0B22E0143 for ; Wed, 13 Feb 2013 20:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964830Ab3BMU7s (ORCPT ); Wed, 13 Feb 2013 15:59:48 -0500 Received: from mail-ea0-f178.google.com ([209.85.215.178]:40874 "EHLO mail-ea0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934131Ab3BMU7q (ORCPT ); Wed, 13 Feb 2013 15:59:46 -0500 Received: by mail-ea0-f178.google.com with SMTP id a14so655266eaa.9 for ; Wed, 13 Feb 2013 12:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=TdD67UhmWESTjgyH31ioibujFdtEM/hPjAQrrTfYjxs=; b=ygFDtD1H9pWTO+vonCuJI6/ny+Ca8adrghxwEief87bl5HzKr7zs8naZ1rGg5lbCY8 8M/I5BATPGFb1wvLDBEM5QWIV1kuyH+TAEsJ2wWYDH2FC56+THXX+PflRf30rEGB+1H4 ts7jeKQUCNNuiA8ZwK67boYiTNJvdbBBdIoLzafDY8GUC4orxo0OEecCIRco2h9EXkKO iWavGbtI1ee0RxkRVOwoNmPszpu0Afg4JUiQOKviy7ULp9Nb8kJkM8508irc/7f09nzu Nh2piLhq4U4Jzv9FtbmQxy7xYJkMycdX+PXsTAkaoa+pL+WRX7RpJzIFpxdkPxwp5DL1 UjbA== X-Received: by 10.14.214.66 with SMTP id b42mr8587406eep.34.1360789185181; Wed, 13 Feb 2013 12:59:45 -0800 (PST) Received: from thor.albion (77.116.38.90.wireless.dyn.drei.com. [77.116.38.90]) by mx.google.com with ESMTPS id q42sm65967235eem.14.2013.02.13.12.59.43 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Feb 2013 12:59:44 -0800 (PST) From: Andreas Philipp To: linux-btrfs@vger.kernel.org Cc: Andreas Philipp , Chris Mason Subject: [PATCH 2/2] Correct allowed raid levels on balance. Date: Wed, 13 Feb 2013 21:59:24 +0100 Message-Id: X-Mailer: git-send-email 1.7.12.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Raid5 with 3 devices is well defined while the old logic allowed raid5 only with a minimum of 4 devices when converting the block group profile via btrfs balance. Creating a raid5 with just three devices using mkfs.btrfs worked always as expected. This is now fixed and the whole logic is rewritten. Signed-off-by: Andreas Philipp --- fs/btrfs/volumes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8818dc3..6885165 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3046,13 +3046,12 @@ int btrfs_balance(struct btrfs_balance_control *bctl, allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE; if (num_devices == 1) allowed |= BTRFS_BLOCK_GROUP_DUP; - else if (num_devices < 4) + if (num_devices > 1) allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1); - else - allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | - BTRFS_BLOCK_GROUP_RAID10 | - BTRFS_BLOCK_GROUP_RAID5 | - BTRFS_BLOCK_GROUP_RAID6); + if (num_devices > 2) + allowed |= BTRFS_BLOCK_GROUP_RAID5; + if (num_devices > 3) + allowed |= (BTRFS_BLOCK_GROUP_RAID10 | BTRFS_BLOCK_GROUP_RAID6); if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) && (!alloc_profile_is_valid(bctl->data.target, 1) ||