From patchwork Thu Sep 27 09:09:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 1512531 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 BFE51E0010 for ; Thu, 27 Sep 2012 09:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754926Ab2I0JJM (ORCPT ); Thu, 27 Sep 2012 05:09:12 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:22943 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754325Ab2I0JJI (ORCPT ); Thu, 27 Sep 2012 05:09:08 -0400 X-IronPort-AV: E=Sophos;i="4.80,495,1344182400"; d="scan'208";a="5927561" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 27 Sep 2012 17:07:46 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q8R99686016665; Thu, 27 Sep 2012 17:09:06 +0800 Received: from [10.167.225.199] ([10.167.225.199]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012092717091811-114182 ; Thu, 27 Sep 2012 17:09:18 +0800 Message-ID: <506417BB.5050408@cn.fujitsu.com> Date: Thu, 27 Sep 2012 17:09:15 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Linux Btrfs CC: Josef Bacik Subject: [PATCH] Btrfs: fix wrong calculation of the available space when reserving the space X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/09/27 17:09:18, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/09/27 17:09:18, Serialize complete at 2012/09/27 17:09:18 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org According to the comment, we can overcommit the space up to 1/2 of the total disk space, or we just can overcommit up to 1/8. But the code was written reversedly. Fix it. Signed-off-by: Miao Xie --- This is based on btrfs-next tree. --- fs/btrfs/extent-tree.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a010234..8a01087 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3962,9 +3962,9 @@ again: * 1/2 of the space. */ if (flush) - avail >>= 3; - else avail >>= 1; + else + avail >>= 3; spin_unlock(&root->fs_info->free_chunk_lock); if (used + num_bytes < space_info->total_bytes + avail) {