From patchwork Sat May 11 11:13:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Philipp X-Patchwork-Id: 2553471 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C87793FC5A for ; Sat, 11 May 2013 11:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751118Ab3EKLNL (ORCPT ); Sat, 11 May 2013 07:13:11 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:59517 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751053Ab3EKLNK (ORCPT ); Sat, 11 May 2013 07:13:10 -0400 Received: by mail-ee0-f45.google.com with SMTP id l10so917527eei.4 for ; Sat, 11 May 2013 04:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:in-reply-to:x-enigmail-version :content-type:content-transfer-encoding; bh=hv0SYz7q6ph4DqHziCsR6NzjlDIpbGg37fzitzxy6BE=; b=uZkEA8EMLVSBHtzfOag+eJ3ONjNdo4ya2AIwMRLM9Q488VGcCkRr39iMn/oKu0YKp3 od1cbxD7T0jO72s+2Ewb51Ka84vq0NdFFGi/pURqKS9N54qnQIn96WMch+d2TpDiZQob N4YoM4lGIYjilmASSPWNlMUspBrdFaKysChseFH2e6jMeeHRhcdjtHMcX5nLZj+hdo33 GcP3kRRYWwUUF46OLNhI7wLW/IerEZ/k7Z73Ku9vlZmcKiYSvaekG2eNHis/PNIqKy6R eLTX/QWWWivTQN+KeXJscTb9xIVezvbxAGQA9fqJpm9Pq2SKHKhcPfTaie8QXAqXW/vt Z4cg== X-Received: by 10.14.109.131 with SMTP id s3mr52469272eeg.26.1368270788489; Sat, 11 May 2013 04:13:08 -0700 (PDT) Received: from [192.168.1.100] (178.112.43.91.wireless.dyn.drei.com. [178.112.43.91]) by mx.google.com with ESMTPSA id bn53sm9380294eeb.7.2013.05.11.04.13.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 11 May 2013 04:13:07 -0700 (PDT) Message-ID: <518E27BF.8000507@gmail.com> Date: Sat, 11 May 2013 13:13:03 +0200 From: Andreas Philipp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130410 Thunderbird/17.0.5 MIME-Version: 1.0 To: linux-btrfs@vger.kernel.org, Hugo Mills , =?ISO-8859-1?Q?Marcus_L=F6vgren?= , Remco Hosman - Yerf IT CC: Andreas Philipp , Chris Mason Subject: [PATCH RESEND 2/2] Correct allowed raid levels on balance. References: , In-Reply-To: In-Reply-To: 518E278D.6070508@gmail.com X-Enigmail-Version: 1.5.1 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) ||