From: Roman Zippel <zippel@linux-m68k.org>

Check for errors during reading of bnode pages and report them.  Also improve
error checks in case bnode validity checks failed.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/hfs/bnode.c     |   12 ++++++++++++
 25-akpm/fs/hfsplus/bnode.c |   12 ++++++++++++
 2 files changed, 24 insertions(+)

diff -puN fs/hfs/bnode.c~hfs-more-bnode-error-checks fs/hfs/bnode.c
--- 25/fs/hfs/bnode.c~hfs-more-bnode-error-checks	2005-03-18 23:42:57.000000000 -0800
+++ 25-akpm/fs/hfs/bnode.c	2005-03-18 23:42:57.000000000 -0800
@@ -285,6 +285,10 @@ static struct hfs_bnode *__hfs_bnode_cre
 		page = read_cache_page(mapping, block++, (filler_t *)mapping->a_ops->readpage, NULL);
 		if (IS_ERR(page))
 			goto fail;
+		if (PageError(page)) {
+			page_cache_release(page);
+			goto fail;
+		}
 #if !REF_PAGES
 		page_cache_release(page);
 #endif
@@ -326,12 +330,16 @@ struct hfs_bnode *hfs_bnode_find(struct 
 		hfs_bnode_get(node);
 		spin_unlock(&tree->hash_lock);
 		wait_event(node->lock_wq, !test_bit(HFS_BNODE_NEW, &node->flags));
+		if (test_bit(HFS_BNODE_ERROR, &node->flags))
+			goto node_error;
 		return node;
 	}
 	spin_unlock(&tree->hash_lock);
 	node = __hfs_bnode_create(tree, num);
 	if (!node)
 		return ERR_PTR(-ENOMEM);
+	if (test_bit(HFS_BNODE_ERROR, &node->flags))
+		goto node_error;
 	if (!test_bit(HFS_BNODE_NEW, &node->flags))
 		return node;
 
@@ -416,6 +424,10 @@ struct hfs_bnode *hfs_bnode_create(struc
 	node = __hfs_bnode_create(tree, num);
 	if (!node)
 		return ERR_PTR(-ENOMEM);
+	if (test_bit(HFS_BNODE_ERROR, &node->flags)) {
+		hfs_bnode_put(node);
+		return ERR_PTR(-EIO);
+	}
 
 	pagep = node->page;
 	memset(kmap(*pagep) + node->page_offset, 0,
diff -puN fs/hfsplus/bnode.c~hfs-more-bnode-error-checks fs/hfsplus/bnode.c
--- 25/fs/hfsplus/bnode.c~hfs-more-bnode-error-checks	2005-03-18 23:42:57.000000000 -0800
+++ 25-akpm/fs/hfsplus/bnode.c	2005-03-18 23:42:57.000000000 -0800
@@ -446,6 +446,10 @@ static struct hfs_bnode *__hfs_bnode_cre
 		page = read_cache_page(mapping, block, (filler_t *)mapping->a_ops->readpage, NULL);
 		if (IS_ERR(page))
 			goto fail;
+		if (PageError(page)) {
+			page_cache_release(page);
+			goto fail;
+		}
 #if !REF_PAGES
 		page_cache_release(page);
 #endif
@@ -487,12 +491,16 @@ struct hfs_bnode *hfs_bnode_find(struct 
 		hfs_bnode_get(node);
 		spin_unlock(&tree->hash_lock);
 		wait_event(node->lock_wq, !test_bit(HFS_BNODE_NEW, &node->flags));
+		if (test_bit(HFS_BNODE_ERROR, &node->flags))
+			goto node_error;
 		return node;
 	}
 	spin_unlock(&tree->hash_lock);
 	node = __hfs_bnode_create(tree, num);
 	if (!node)
 		return ERR_PTR(-ENOMEM);
+	if (test_bit(HFS_BNODE_ERROR, &node->flags))
+		goto node_error;
 	if (!test_bit(HFS_BNODE_NEW, &node->flags))
 		return node;
 
@@ -579,6 +587,10 @@ struct hfs_bnode *hfs_bnode_create(struc
 	node = __hfs_bnode_create(tree, num);
 	if (!node)
 		return ERR_PTR(-ENOMEM);
+	if (test_bit(HFS_BNODE_ERROR, &node->flags)) {
+		hfs_bnode_put(node);
+		return ERR_PTR(-EIO);
+	}
 
 	pagep = node->page;
 	memset(kmap(*pagep) + node->page_offset, 0,
_