From patchwork Wed Dec 5 10:53:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 1840941 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 3D7E5DF266 for ; Wed, 5 Dec 2012 10:53:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752185Ab2LEKxE (ORCPT ); Wed, 5 Dec 2012 05:53:04 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:54479 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751880Ab2LEKxB (ORCPT ); Wed, 5 Dec 2012 05:53:01 -0500 X-IronPort-AV: E=Sophos;i="4.83,377,1352044800"; d="scan'208";a="6338931" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 05 Dec 2012 18:51:12 +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 qB5Ar5Ni019298 for ; Wed, 5 Dec 2012 18:53:05 +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 2012120518522214-255051 ; Wed, 5 Dec 2012 18:52:22 +0800 Message-ID: <50BF27A5.8070603@cn.fujitsu.com> Date: Wed, 05 Dec 2012 18:53:25 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Linux Btrfs Subject: [PATCH 2/6] Btrfs: fix missing reserved space release in error path of delalloc reservation X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/12/05 18:52:22, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/12/05 18:52:22, Serialize complete at 2012/12/05 18:52:22 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We forget to release the reserved space in the error path of delalloc reservatiom, fix it. Signed-off-by: Miao Xie --- fs/btrfs/extent-tree.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 3d3e2c1..1cd71b2 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4572,6 +4572,9 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) ret = btrfs_qgroup_reserve(root, num_bytes + nr_extents * root->leafsize); if (ret) { + spin_lock(&BTRFS_I(inode)->lock); + calc_csum_metadata_size(inode, num_bytes, 0); + spin_unlock(&BTRFS_I(inode)->lock); mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); return ret; } @@ -4607,6 +4610,10 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) btrfs_ino(inode), to_free, 0); } + if (root->fs_info->quota_enabled) { + btrfs_qgroup_free(root, num_bytes + + nr_extents * root->leafsize); + } mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); return ret; }