linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] vfs: check inode size on no_cached_page
@ 2009-04-12  7:16 Wu Fengguang
  2009-04-15  0:11 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Wu Fengguang @ 2009-04-12  7:16 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, linux-fsdevel, Chenfeng Xu

[This patch may not necessarily be merged, but at least we should
 be aware of the problem.]

When user space requests past-EOF data, do_generic_file_read() will
issue a bonus readpage call, which may be unfavorable.

do_generic_file_read:
        -> find_page:
        -> find_get_page()             = NULL
        -> page_cache_sync_readahead()
        -> find_get_page()             = NULL
        -> no_cached_page:
        -> readpage:
                -> nfs_readpage()      = error
        -> readpage_error:

Reported-by: Xu Chenfeng <xcf@ustc.edu.cn>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 mm/filemap.c |    5 +++++
 1 file changed, 5 insertions(+)

--- mm.orig/mm/filemap.c
+++ mm/mm/filemap.c
@@ -1269,6 +1269,11 @@ readpage_error:
 		goto out;
 
 no_cached_page:
+		isize = i_size_read(inode);
+		end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
+		if (unlikely(!isize || index > end_index))
+			goto out;
+
 		/*
 		 * Ok, it wasn't cached, so we need to create a new
 		 * page..

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-15  2:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-12  7:16 [RFC][PATCH] vfs: check inode size on no_cached_page Wu Fengguang
2009-04-15  0:11 ` Andrew Morton
     [not found]   ` <20090415012027.GA4731@ThinkPad>
2009-04-15  1:22     ` Chenfeng Xu
2009-04-15  1:22     ` Chenfeng Xu
     [not found]   ` <20090414171114.04a47932.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-04-15  1:36     ` Wu Fengguang
2009-04-15  2:39       ` Wu Fengguang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).