From patchwork Thu May 20 07:18:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 101141 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 o4K7Q7VG005522 for ; Thu, 20 May 2010 07:26:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754043Ab0ETH0G (ORCPT ); Thu, 20 May 2010 03:26:06 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:53761 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750877Ab0ETH0E (ORCPT ); Thu, 20 May 2010 03:26:04 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id C9F7017012E; Thu, 20 May 2010 15:26:01 +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 o4K7NxsV016210; Thu, 20 May 2010 15:23:59 +0800 Received: from [127.0.0.1] (unknown [10.167.141.211]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 1E6B410C0A1; Thu, 20 May 2010 15:29:37 +0800 (CST) Message-ID: <4BF4E23D.6080405@cn.fujitsu.com> Date: Thu, 20 May 2010 15:18:21 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Chris Mason CC: Linux Btrfs Subject: [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru 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]); Thu, 20 May 2010 07:26:08 +0000 (UTC) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 1d54c53..1bd4d92 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -480,10 +480,23 @@ static noinline int add_ra_bio_pages(struct inode *inode, if (!page) break; - if (add_to_page_cache_lru(page, mapping, page_index, - GFP_NOFS)) { + ret = add_to_page_cache_lru(page, mapping, page_index, + GFP_NOFS); + if (ret) { page_cache_release(page); - goto next; + + /* + * -EEXIST indicates the page has been added, so + * it can move on to next page. + */ + if (ret == -EEXIST) { + misses++; + if (misses > 4) + break; + goto next; + } + + break; } end = last_offset + PAGE_CACHE_SIZE - 1;