From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, Chenfeng Xu <xcf@ustc.edu.cn>
Subject: [RFC][PATCH] vfs: check inode size on no_cached_page
Date: Sun, 12 Apr 2009 15:16:05 +0800 [thread overview]
Message-ID: <20090412071605.GA14058@localhost> (raw)
[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..
next reply other threads:[~2009-04-12 7:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-12 7:16 Wu Fengguang [this message]
2009-04-15 0:11 ` [RFC][PATCH] vfs: check inode size on no_cached_page 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090412071605.GA14058@localhost \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xcf@ustc.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).