mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -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
|
|
@ -434,7 +434,6 @@ xip_truncate_page(struct address_space *mapping, loff_t from)
|
|||
unsigned blocksize;
|
||||
unsigned length;
|
||||
struct page *page;
|
||||
void *kaddr;
|
||||
|
||||
BUG_ON(!mapping->a_ops->get_xip_page);
|
||||
|
||||
|
|
@ -458,11 +457,7 @@ xip_truncate_page(struct address_space *mapping, loff_t from)
|
|||
else
|
||||
return PTR_ERR(page);
|
||||
}
|
||||
kaddr = kmap_atomic(page, KM_USER0);
|
||||
memset(kaddr + offset, 0, length);
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
|
||||
flush_dcache_page(page);
|
||||
zero_user_page(page, offset, length, KM_USER0);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xip_truncate_page);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <linux/swap.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/pagevec.h>
|
||||
#include <linux/task_io_accounting_ops.h>
|
||||
#include <linux/buffer_head.h> /* grr. try_to_release_page,
|
||||
|
|
@ -46,7 +47,7 @@ void do_invalidatepage(struct page *page, unsigned long offset)
|
|||
|
||||
static inline void truncate_partial_page(struct page *page, unsigned partial)
|
||||
{
|
||||
memclear_highpage_flush(page, partial, PAGE_CACHE_SIZE-partial);
|
||||
zero_user_page(page, partial, PAGE_CACHE_SIZE - partial, KM_USER0);
|
||||
if (PagePrivate(page))
|
||||
do_invalidatepage(page, partial);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue