From patchwork Tue Apr 6 14:15:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mason X-Patchwork-Id: 90793 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o36ENx6x017753 for ; Tue, 6 Apr 2010 14:23:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753635Ab0DFOX6 (ORCPT ); Tue, 6 Apr 2010 10:23:58 -0400 Received: from rcsinet11.oracle.com ([148.87.113.123]:24998 "EHLO rcsinet11.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269Ab0DFOX5 (ORCPT ); Tue, 6 Apr 2010 10:23:57 -0400 Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet11.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o36EKxqp031785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Apr 2010 14:23:37 GMT Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o35FVhNf029065; Tue, 6 Apr 2010 14:15:57 GMT Received: from abhmt004.oracle.com by acsmt354.oracle.com with ESMTP id 150380021270563342; Tue, 06 Apr 2010 07:15:42 -0700 Received: from localhost (/66.66.148.185) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 06 Apr 2010 07:15:42 -0700 Date: Tue, 6 Apr 2010 10:15:41 -0400 From: Chris Mason To: "Yan, Zheng " , Josef Bacik , linux-btrfs@vger.kernel.org Subject: Re: [PATCH] Btrfs: fix chunk allocate size calculation Message-ID: <20100406141541.GC5413@think> Mail-Followup-To: Chris Mason , "Yan, Zheng " , Josef Bacik , linux-btrfs@vger.kernel.org References: <20100317204556.GA4409@localhost.localdomain> <20100406111358.GA5218@think> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100406111358.GA5218@think> User-Agent: Mutt/1.5.20 (2009-06-14) X-Source-IP: acsmt354.oracle.com [141.146.40.154] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090203.4BBB421E.002B:SCFMA4539814,ss=1,fgs=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 06 Apr 2010 14:24:06 +0000 (UTC) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 9bf1f58..b584e9a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2249,6 +2249,12 @@ again: if (!looped) calc_size = max_t(u64, min_stripe_size, calc_size); + /* + * we're about to do_div by the stripe_len so lets make sure + * we end up with something bigger than a stripe + */ + calc_size = max_t(u64, calc_size, stripe_len * 4); + do_div(calc_size, stripe_len); calc_size *= stripe_len;