mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
mm: add unmap_mapping_pages()
Several users of unmap_mapping_range() would prefer to express their range in pages rather than bytes. Unfortuately, on a 32-bit kernel, you have to remember to cast your page number to a 64-bit type before shifting it, and four places in the current tree didn't remember to do that. That's a sign of a bad interface. Conveniently, unmap_mapping_range() actually converts from bytes into pages, so hoist the guts of unmap_mapping_range() into a new function unmap_mapping_pages() and convert the callers which want to use pages. Link: http://lkml.kernel.org/r/20171206142627.GD32044@bombadil.infradead.org Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Reported-by: "zhangyi (F)" <yi.zhang@huawei.com> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
a365ac09d3
commit
977fbdcd59
@@ -179,12 +179,8 @@ static void
|
||||
truncate_cleanup_page(struct address_space *mapping, struct page *page)
|
||||
{
|
||||
if (page_mapped(page)) {
|
||||
loff_t holelen;
|
||||
|
||||
holelen = PageTransHuge(page) ? HPAGE_PMD_SIZE : PAGE_SIZE;
|
||||
unmap_mapping_range(mapping,
|
||||
(loff_t)page->index << PAGE_SHIFT,
|
||||
holelen, 0);
|
||||
pgoff_t nr = PageTransHuge(page) ? HPAGE_PMD_NR : 1;
|
||||
unmap_mapping_pages(mapping, page->index, nr, false);
|
||||
}
|
||||
|
||||
if (page_has_private(page))
|
||||
@@ -715,19 +711,15 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
|
||||
/*
|
||||
* Zap the rest of the file in one hit.
|
||||
*/
|
||||
unmap_mapping_range(mapping,
|
||||
(loff_t)index << PAGE_SHIFT,
|
||||
(loff_t)(1 + end - index)
|
||||
<< PAGE_SHIFT,
|
||||
0);
|
||||
unmap_mapping_pages(mapping, index,
|
||||
(1 + end - index), false);
|
||||
did_range_unmap = 1;
|
||||
} else {
|
||||
/*
|
||||
* Just zap this page
|
||||
*/
|
||||
unmap_mapping_range(mapping,
|
||||
(loff_t)index << PAGE_SHIFT,
|
||||
PAGE_SIZE, 0);
|
||||
unmap_mapping_pages(mapping, index,
|
||||
1, false);
|
||||
}
|
||||
}
|
||||
BUG_ON(page_mapped(page));
|
||||
@@ -753,8 +745,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
|
||||
* get remapped later.
|
||||
*/
|
||||
if (dax_mapping(mapping)) {
|
||||
unmap_mapping_range(mapping, (loff_t)start << PAGE_SHIFT,
|
||||
(loff_t)(end - start + 1) << PAGE_SHIFT, 0);
|
||||
unmap_mapping_pages(mapping, start, end - start + 1, false);
|
||||
}
|
||||
out:
|
||||
cleancache_invalidate_inode(mapping);
|
||||
|
Reference in New Issue
Block a user