aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorNate Diller <nate.diller@gmail.com>2007-05-09 05:35:07 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 15:30:55 -0400
commit01f2705daf5a36208e69d7cf95db9c330f843af6 (patch)
tree2d2c7a042c2466ed985f6e0950450c099f02725f /include/linux
parent38a23e311b6cd389b9d8af2ea6c28c8cffbe581c (diff)
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. [akpm@linux-foundation.org: fix a few things] Signed-off-by: Nate Diller <nate.diller@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/highmem.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index a515eb0afdfb..b5f2ab42d984 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -94,17 +94,27 @@ static inline void clear_highpage(struct page *page)
94 94
95/* 95/*
96 * Same but also flushes aliased cache contents to RAM. 96 * Same but also flushes aliased cache contents to RAM.
97 *
98 * This must be a macro because KM_USER0 and friends aren't defined if
99 * !CONFIG_HIGHMEM
97 */ 100 */
98static inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size) 101#define zero_user_page(page, offset, size, km_type) \
102 do { \
103 void *kaddr; \
104 \
105 BUG_ON((offset) + (size) > PAGE_SIZE); \
106 \
107 kaddr = kmap_atomic(page, km_type); \
108 memset((char *)kaddr + (offset), 0, (size)); \
109 flush_dcache_page(page); \
110 kunmap_atomic(kaddr, (km_type)); \
111 } while (0)
112
113
114static inline void memclear_highpage_flush(struct page *page,
115 unsigned int offset, unsigned int size)
99{ 116{
100 void *kaddr; 117 zero_user_page(page, offset, size, KM_USER0);
101
102 BUG_ON(offset + size > PAGE_SIZE);
103
104 kaddr = kmap_atomic(page, KM_USER0);
105 memset((char *)kaddr + offset, 0, size);
106 flush_dcache_page(page);
107 kunmap_atomic(kaddr, KM_USER0);
108} 118}
109 119
110#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE 120#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE