linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
@ 2010-05-20  7:18 Miao Xie
  2010-05-20  8:43 ` Mike Fedyk
  0 siblings, 1 reply; 3+ messages in thread
From: Miao Xie @ 2010-05-20  7:18 UTC (permalink / raw)
  To: Chris Mason; +Cc: Linux Btrfs

From: Liu Bo <liubo2009@cn.fujitsu.com>

If add_to_page_cache_lru() returns -EEXIST, it indicates the page
that belongs to this page_index has been added and this readahead
action can go on to next page.

If add_to_page_cache_lru() returns -ENOMEM, it should break for
no memory left.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/compression.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

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;
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-05-24  2:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-20  7:18 [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru Miao Xie
2010-05-20  8:43 ` Mike Fedyk
2010-05-24  2:34   ` liubo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).