From patchwork Mon May 24 02:39:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liubo X-Patchwork-Id: 101805 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 o4O2aWq4026989 for ; Mon, 24 May 2010 02:36:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755248Ab0EXCgb (ORCPT ); Sun, 23 May 2010 22:36:31 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:63905 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754251Ab0EXCgb (ORCPT ); Sun, 23 May 2010 22:36:31 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 4B1C717003F; Mon, 24 May 2010 10:36:26 +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 o4O2YKCK009264; Mon, 24 May 2010 10:34:20 +0800 Received: from localhost.localdomain (unknown [10.167.141.170]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 2787F10C0A8; Mon, 24 May 2010 10:40:06 +0800 (CST) Message-ID: <4BF9E6CB.4050607@cn.fujitsu.com> Date: Mon, 24 May 2010 10:39:07 +0800 From: liubo Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; 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: Linux Btrfs , Mike Fedyk Subject: [PATCH 04/10 v2] 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]); Mon, 24 May 2010 02:36:33 +0000 (UTC) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 1d54c53..9832083 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -469,6 +469,7 @@ static noinline int add_ra_bio_pages(struct inode *inode, page = radix_tree_lookup(&mapping->page_tree, page_index); rcu_read_unlock(); if (page) { +check_misses: misses++; if (misses > 4) break; @@ -480,10 +481,19 @@ 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) + goto check_misses; + + break; } end = last_offset + PAGE_CACHE_SIZE - 1;