Commit 99e3e53f authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Linus Torvalds

mm: cleanup size checks in filemap_fault() and filemap_map_pages()

Minor cleanups:
 - 'size' variable is now in bytes, not pages;
 - use round_up(): it should be easier to read.
Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Ning Qu <quning@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f1820361
...@@ -1953,11 +1953,11 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -1953,11 +1953,11 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
pgoff_t offset = vmf->pgoff; pgoff_t offset = vmf->pgoff;
struct page *page; struct page *page;
pgoff_t size; loff_t size;
int ret = 0; int ret = 0;
size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; size = round_up(i_size_read(inode), PAGE_CACHE_SIZE);
if (offset >= size) if (offset >= size >> PAGE_CACHE_SHIFT)
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
/* /*
...@@ -2006,8 +2006,8 @@ retry_find: ...@@ -2006,8 +2006,8 @@ retry_find:
* Found the page and have a reference on it. * Found the page and have a reference on it.
* We must recheck i_size under page lock. * We must recheck i_size under page lock.
*/ */
size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; size = round_up(i_size_read(inode), PAGE_CACHE_SIZE);
if (unlikely(offset >= size)) { if (unlikely(offset >= size >> PAGE_CACHE_SHIFT)) {
unlock_page(page); unlock_page(page);
page_cache_release(page); page_cache_release(page);
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
...@@ -2111,8 +2111,8 @@ repeat: ...@@ -2111,8 +2111,8 @@ repeat:
if (page->mapping != mapping || !PageUptodate(page)) if (page->mapping != mapping || !PageUptodate(page))
goto unlock; goto unlock;
size = i_size_read(mapping->host) + PAGE_CACHE_SIZE - 1; size = round_up(i_size_read(mapping->host), PAGE_CACHE_SIZE);
if (page->index >= size >> PAGE_CACHE_SHIFT) if (page->index >= size >> PAGE_CACHE_SHIFT)
goto unlock; goto unlock;
pte = vmf->pte + page->index - vmf->pgoff; pte = vmf->pte + page->index - vmf->pgoff;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment