diff options
author | Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | 2014-04-08 02:37:21 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-08 03:35:53 +0400 |
commit | 99e3e53f4e0fd807607bf381e14f6de8feedd383 (patch) | |
tree | 58f9324322ca4cd8d877507514d14f123c243e44 /mm/filemap.c | |
parent | f1820361f83d556a7f0a9f629100f3825e594328 (diff) | |
download | linux-99e3e53f4e0fd807607bf381e14f6de8feedd383.tar.xz |
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: Kirill 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 3f9b5fbb623f..b952d99c827c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1953,11 +1953,11 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) struct inode *inode = mapping->host; pgoff_t offset = vmf->pgoff; struct page *page; - pgoff_t size; + loff_t size; int ret = 0; - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (offset >= size) + size = round_up(i_size_read(inode), PAGE_CACHE_SIZE); + if (offset >= size >> PAGE_CACHE_SHIFT) return VM_FAULT_SIGBUS; /* @@ -2006,8 +2006,8 @@ retry_find: * Found the page and have a reference on it. * We must recheck i_size under page lock. */ - size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (unlikely(offset >= size)) { + size = round_up(i_size_read(inode), PAGE_CACHE_SIZE); + if (unlikely(offset >= size >> PAGE_CACHE_SHIFT)) { unlock_page(page); page_cache_release(page); return VM_FAULT_SIGBUS; @@ -2111,8 +2111,8 @@ repeat: if (page->mapping != mapping || !PageUptodate(page)) goto unlock; - size = i_size_read(mapping->host) + PAGE_CACHE_SIZE - 1; - if (page->index >= size >> PAGE_CACHE_SHIFT) + size = round_up(i_size_read(mapping->host), PAGE_CACHE_SIZE); + if (page->index >= size >> PAGE_CACHE_SHIFT) goto unlock; pte = vmf->pte + page->index - vmf->pgoff; |