From patchwork Thu Nov 18 02:09:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zefan X-Patchwork-Id: 334831 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAI2HoOE013935 for ; Thu, 18 Nov 2010 02:17:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754665Ab0KRCRr (ORCPT ); Wed, 17 Nov 2010 21:17:47 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:60370 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754625Ab0KRCRr (ORCPT ); Wed, 17 Nov 2010 21:17:47 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id E4685170CBE; Thu, 18 Nov 2010 10:17:45 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oAI2DJlU017898; Thu, 18 Nov 2010 10:13:19 +0800 Received: from lizf.localdomain ([10.167.225.51]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010111810082239-41907 ; Thu, 18 Nov 2010 10:08:22 +0800 Message-ID: <4CE48ADC.6070001@cn.fujitsu.com> Date: Thu, 18 Nov 2010 10:09:32 +0800 From: Li Zefan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: Chris Mason CC: Mitch Harder , linux-btrfs@vger.kernel.org Subject: [PATCH v2 1/6] btrfs: Fix bugs in zlib workspace References: <4CE48ABB.5070302@cn.fujitsu.com> In-Reply-To: <4CE48ABB.5070302@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-18 10:08:22, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-18 10:18:08, Serialize complete at 2010-11-18 10:18:08 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 (demeter1.kernel.org [140.211.167.41]); Thu, 18 Nov 2010 02:17:51 +0000 (UTC) diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index b9cd544..e5b8b22 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -75,16 +75,19 @@ again: return workspace; } - spin_unlock(&workspace_lock); if (atomic_read(&alloc_workspace) > cpus) { DEFINE_WAIT(wait); + + spin_unlock(&workspace_lock); prepare_to_wait(&workspace_wait, &wait, TASK_UNINTERRUPTIBLE); - if (atomic_read(&alloc_workspace) > cpus) + if (atomic_read(&alloc_workspace) > cpus && !num_workspace) schedule(); finish_wait(&workspace_wait, &wait); goto again; } atomic_inc(&alloc_workspace); + spin_unlock(&workspace_lock); + workspace = kzalloc(sizeof(*workspace), GFP_NOFS); if (!workspace) { ret = -ENOMEM;