diff mbox

[04/10,v2] btrfs: Add error check for add_to_page_cache_lru

Message ID 4BF9E6CB.4050607@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

liubo May 24, 2010, 2:39 a.m. UTC
None
diff mbox

Patch

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;