mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
fs: convert core functions to zero_user_page
It's very common for file systems to need to zero part or all of a page, the simplist way is just to use kmap_atomic() and memset(). There's actually a library function in include/linux/highmem.h that does exactly that, but it's confusingly named memclear_highpage_flush(), which is descriptive of *how* it does the work rather than what the *purpose* is. So this patchset renames the function to zero_user_page(), and calls it from the various places that currently open code it. This first patch introduces the new function call, and converts all the core kernel callsites, both the open-coded ones and the old memclear_highpage_flush() ones. Following this patch is a series of conversions for each file system individually, per AKPM, and finally a patch deprecating the old call. The diffstat below shows the entire patchset. [[email protected]: fix a few things] Signed-off-by: Nate Diller <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
38a23e311b
commit
01f2705daf
7 changed files with 42 additions and 81 deletions
15
fs/mpage.c
15
fs/mpage.c
|
|
@ -284,11 +284,9 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
|
|||
}
|
||||
|
||||
if (first_hole != blocks_per_page) {
|
||||
char *kaddr = kmap_atomic(page, KM_USER0);
|
||||
memset(kaddr + (first_hole << blkbits), 0,
|
||||
PAGE_CACHE_SIZE - (first_hole << blkbits));
|
||||
flush_dcache_page(page);
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
zero_user_page(page, first_hole << blkbits,
|
||||
PAGE_CACHE_SIZE - (first_hole << blkbits),
|
||||
KM_USER0);
|
||||
if (first_hole == 0) {
|
||||
SetPageUptodate(page);
|
||||
unlock_page(page);
|
||||
|
|
@ -576,14 +574,11 @@ page_is_mapped:
|
|||
* written out to the file."
|
||||
*/
|
||||
unsigned offset = i_size & (PAGE_CACHE_SIZE - 1);
|
||||
char *kaddr;
|
||||
|
||||
if (page->index > end_index || !offset)
|
||||
goto confused;
|
||||
kaddr = kmap_atomic(page, KM_USER0);
|
||||
memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset);
|
||||
flush_dcache_page(page);
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
zero_user_page(page, offset, PAGE_CACHE_SIZE - offset,
|
||||
KM_USER0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue