[patch 69/76] zisofs: fix readpage() outside i_size

From: Chris Wright
Date: Fri Mar 21 2008 - 19:07:07 EST


-stable review patch. If anyone has any objections, please let us know.
---------------------

From: Dave Young <hidave.darkstar@xxxxxxxxx>

A read request outside i_size will be handled in do_generic_file_read(). So
we just return 0 to avoid getting -EIO as normal reading, let
do_generic_file_read do the rest.

At the same time we need unlock the page to avoid system stuck.

Fixes http://bugzilla.kernel.org/show_bug.cgi?id=10227

Signed-off-by: Dave Young <hidave.darkstar@xxxxxxxxx>
Acked-by: Jan Kara <jack@xxxxxxx>
Report-by: Christian Perle <chris@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
fs/isofs/compress.c | 11 +++++++++++
1 file changed, 11 insertions(+)

--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -72,6 +72,17 @@ static int zisofs_readpage(struct file *
offset = index & ~zisofs_block_page_mask;
blockindex = offset >> zisofs_block_page_shift;
maxpage = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+
+ /*
+ * If this page is wholly outside i_size we just return zero;
+ * do_generic_file_read() will handle this for us
+ */
+ if (page->index >= maxpage) {
+ SetPageUptodate(page);
+ unlock_page(page);
+ return 0;
+ }
+
maxpage = min(zisofs_block_pages, maxpage-offset);

for ( i = 0 ; i < maxpage ; i++, offset++ ) {

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/