[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130805102917.315976e5@notabene.brown>
Date: Mon, 5 Aug 2013 10:29:17 +1000
From: NeilBrown <neilb@...e.de>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Hugh Dickins <hughd@...gle.com>,
Wu Fengguang <fengguang.wu@...el.com>, Jan Kara <jack@...e.cz>,
Mel Gorman <mgorman@...e.de>, linux-mm@...ck.org,
Andi Kleen <ak@...ux.intel.com>,
Matthew Wilcox <willy@...ux.intel.com>,
"Kirill A. Shutemov" <kirill@...temov.name>,
Hillf Danton <dhillf@...il.com>, Dave Hansen <dave@...1.net>,
Ning Qu <quning@...gle.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 15/23] mm, fs: avoid page allocation beyond i_size on
read
On Sun, 4 Aug 2013 05:17:17 +0300 "Kirill A. Shutemov"
<kirill.shutemov@...ux.intel.com> wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
>
> I've noticed that we allocated unneeded page for cache on read beyond
> i_size. Simple test case (I checked it on ramfs):
>
> $ touch testfile
> $ cat testfile
>
> It triggers 'no_cached_page' code path in do_generic_file_read().
>
> Looks like it's regression since commit a32ea1e. Let's fix it.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Cc: NeilBrown <neilb@...e.de>
> ---
> mm/filemap.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 066bbff..c31d296 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1163,6 +1163,10 @@ static void do_generic_file_read(struct file *filp, loff_t *ppos,
> loff_t isize;
> unsigned long nr, ret;
>
> + isize = i_size_read(inode);
> + if (!isize || index > (isize - 1) >> PAGE_CACHE_SHIFT)
> + goto out;
> +
> cond_resched();
> find_page:
> page = find_get_page(mapping, index);
Looks good to me.
Acked-by: NeilBrown <neilb@...e.de>
Thanks,
NeilBrown
Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)
Powered by blists - more mailing lists