From patchwork Mon Oct 25 07:11:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zefan X-Patchwork-Id: 266232 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 o9P7Arph018595 for ; Mon, 25 Oct 2010 07:10:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753178Ab0JYHKu (ORCPT ); Mon, 25 Oct 2010 03:10:50 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:59894 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753083Ab0JYHKu (ORCPT ); Mon, 25 Oct 2010 03:10:50 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id BEF14170EE9 for ; Mon, 25 Oct 2010 15:10:47 +0800 (CST) Received: from 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 o9P76dCg016453 for ; Mon, 25 Oct 2010 15:06:40 +0800 Received: from lizf.localdomain (unknown [10.167.225.51]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 9185314C07D for ; Mon, 25 Oct 2010 15:12:26 +0800 (CST) Message-ID: <4CC52DAF.2030203@cn.fujitsu.com> Date: Mon, 25 Oct 2010 15:11:43 +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: linux-btrfs@vger.kernel.org Subject: [PATCH 1/5] btrfs: Fix bugs in zlib workspace References: <4CC52D9A.3030709@cn.fujitsu.com> In-Reply-To: <4CC52D9A.3030709@cn.fujitsu.com> 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]); Mon, 25 Oct 2010 07:10:53 +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;