Skip to contentSkip to conversation

btrfs: Add error check for add_to_page_cache_lru

PATCH New liubo 1 participant 1 message May 24, 2010 Btrfs file system

lore
Share & tools
lore

liubo

author
#0 lore raw

PATCH v2 4/10 btrfs: Add error check for add_to_page_cache_lru

From: Liu Bo <[email protected]>

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.

---
 fs/btrfs/compression.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
fs/btrfs/compression.c +13 -3
index 1d54c53..9832083 100644
@@ -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;
Signature · 6 lines
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html