Skip to contentSkip to conversation

+ mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Feb 28, 2014

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Fri, 28 Feb 2014 15:58:59 -0800

The patch titled
Subject: mm: cleanup size checks in filemap_fault() and filemap_map_pages()
has been added to the -mm tree. Its filename is
mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: "Kirill A. Shutemov" <[email protected]>
Subject: 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.

Cc Linus Torvalds <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Dave Chinner <[email protected]>
Cc Ning Qu <[email protected]>

---

 mm/filemap.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
mm/filemap.c renamed from mm/filemap.c~mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages +7 -7
diff -puN mm/filemap.c~mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages mm/filemap.c
@@ -1950,11 +1950,11 @@ int filemap_fault(struct vm_area_struct
 	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;
 
 	/*
@@ -2003,8 +2003,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;
@@ -2106,8 +2106,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;

_

Patches currently in -mm which might be from [email protected] are

origin.patch
mm-close-pagetail-race.patch
mm-page_alloc-make-first_page-visible-before-pagetail.patch mm-include-vm_mixedmap-flag-in-the-vm_special-list-to-avoid-munlocking.patch pagewalk-update-page-table-walker-core.patch
pagewalk-add-walk_page_vma.patch
smaps-redefine-callback-functions-for-page-table-walker.patch clear_refs-redefine-callback-functions-for-page-table-walker.patch pagemap-redefine-callback-functions-for-page-table-walker.patch numa_maps-redefine-callback-functions-for-page-table-walker.patch memcg-redefine-callback-functions-for-page-table-walker.patch madvise-redefine-callback-functions-for-page-table-walker.patch arch-powerpc-mm-subpage-protc-use-walk_page_vma-instead-of-walk_page_range.patch pagewalk-remove-argument-hmask-from-hugetlb_entry.patch mempolicy-apply-page-table-walker-on-queue_pages_range.patch
mm-rename-__do_fault-do_fault.patch mm-do_fault-extract-to-call-vm_ops-do_fault-to-separate-function.patch mm-introduce-do_read_fault.patch
mm-introduce-do_cow_fault.patch
mm-introduce-do_shared_fault-and-drop-do_fault.patch mm-introduce-do_shared_fault-and-drop-do_fault-fix.patch mm-introduce-do_shared_fault-and-drop-do_fault-fix-fix.patch mm-consolidate-code-to-call-vm_ops-page_mkwrite.patch mm-consolidate-code-to-call-vm_ops-page_mkwrite-fix.patch
mm-consolidate-code-to-setup-pte.patch
mm-thp-drop-do_huge_pmd_wp_zero_page_fallback.patch mm-revert-thp-make-madv_hugepage-check-for-mm-def_flags.patch mm-revert-thp-make-madv_hugepage-check-for-mm-def_flags-ignore-madv_hugepage-on-s390-to-prevent-sigsegv-in-qemu.patch mm-thp-add-vm_init_def_mask-and-prctl_thp_disable.patch exec-kill-the-unnecessary-mm-def_flags-setting-in-load_elf_binary.patch mm-disable-split-page-table-lock-for-mmu.patch
mm-introduce-vm_ops-map_pages.patch
mm-implement-map_pages-for-page-cache.patch mm-cleanup-size-checks-in-filemap_fault-and-filemap_map_pages.patch