[04/10] btrfs: Add error check for add_to_page_cache_lru
diff mbox

Message ID 4BF4E23D.6080405@cn.fujitsu.com
State New, archived
Headers show

Commit Message

Miao Xie May 20, 2010, 7:18 a.m. UTC
None

Patch
diff mbox

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;