aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNate Diller <nate.diller@gmail.com>2007-05-09 05:35:09 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 15:30:56 -0400
commitf2fff596955867d407cc7e8e426097bd9ad2be9b (patch)
tree68ca108b7eecef9d789fb7bf9eb2405854880575 /fs
parent0c11d7a9e9e9793219baf715048c190a84bead57 (diff)
reiserfs: use zero_user_page
Use zero_user_page() instead of open-coding it. 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 'fs')
-rw-r--r--fs/reiserfs/file.c39
-rw-r--r--fs/reiserfs/inode.c13
2 files changed, 13 insertions, 39 deletions
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index ab45db529c80..9e451a68580f 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -1059,20 +1059,12 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1059 maping blocks, since there is none, so we just zero out remaining 1059 maping blocks, since there is none, so we just zero out remaining
1060 parts of first and last pages in write area (if needed) */ 1060 parts of first and last pages in write area (if needed) */
1061 if ((pos & ~((loff_t) PAGE_CACHE_SIZE - 1)) > inode->i_size) { 1061 if ((pos & ~((loff_t) PAGE_CACHE_SIZE - 1)) > inode->i_size) {
1062 if (from != 0) { /* First page needs to be partially zeroed */ 1062 if (from != 0) /* First page needs to be partially zeroed */
1063 char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0); 1063 zero_user_page(prepared_pages[0], 0, from, KM_USER0);
1064 memset(kaddr, 0, from); 1064
1065 kunmap_atomic(kaddr, KM_USER0); 1065 if (to != PAGE_CACHE_SIZE) /* Last page needs to be partially zeroed */
1066 flush_dcache_page(prepared_pages[0]); 1066 zero_user_page(prepared_pages[num_pages-1], to,
1067 } 1067 PAGE_CACHE_SIZE - to, KM_USER0);
1068 if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */
1069 char *kaddr =
1070 kmap_atomic(prepared_pages[num_pages - 1],
1071 KM_USER0);
1072 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
1073 kunmap_atomic(kaddr, KM_USER0);
1074 flush_dcache_page(prepared_pages[num_pages - 1]);
1075 }
1076 1068
1077 /* Since all blocks are new - use already calculated value */ 1069 /* Since all blocks are new - use already calculated value */
1078 return blocks; 1070 return blocks;
@@ -1199,13 +1191,9 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1199 ll_rw_block(READ, 1, &bh); 1191 ll_rw_block(READ, 1, &bh);
1200 *wait_bh++ = bh; 1192 *wait_bh++ = bh;
1201 } else { /* Not mapped, zero it */ 1193 } else { /* Not mapped, zero it */
1202 char *kaddr = 1194 zero_user_page(prepared_pages[0],
1203 kmap_atomic(prepared_pages[0], 1195 block_start,
1204 KM_USER0); 1196 from - block_start, KM_USER0);
1205 memset(kaddr + block_start, 0,
1206 from - block_start);
1207 kunmap_atomic(kaddr, KM_USER0);
1208 flush_dcache_page(prepared_pages[0]);
1209 set_buffer_uptodate(bh); 1197 set_buffer_uptodate(bh);
1210 } 1198 }
1211 } 1199 }
@@ -1237,13 +1225,8 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1237 ll_rw_block(READ, 1, &bh); 1225 ll_rw_block(READ, 1, &bh);
1238 *wait_bh++ = bh; 1226 *wait_bh++ = bh;
1239 } else { /* Not mapped, zero it */ 1227 } else { /* Not mapped, zero it */
1240 char *kaddr = 1228 zero_user_page(prepared_pages[num_pages-1],
1241 kmap_atomic(prepared_pages 1229 to, block_end - to, KM_USER0);
1242 [num_pages - 1],
1243 KM_USER0);
1244 memset(kaddr + to, 0, block_end - to);
1245 kunmap_atomic(kaddr, KM_USER0);
1246 flush_dcache_page(prepared_pages[num_pages - 1]);
1247 set_buffer_uptodate(bh); 1230 set_buffer_uptodate(bh);
1248 } 1231 }
1249 } 1232 }
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 9fcbfe316977..1272d11399fb 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2148,13 +2148,8 @@ int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
2148 length = offset & (blocksize - 1); 2148 length = offset & (blocksize - 1);
2149 /* if we are not on a block boundary */ 2149 /* if we are not on a block boundary */
2150 if (length) { 2150 if (length) {
2151 char *kaddr;
2152
2153 length = blocksize - length; 2151 length = blocksize - length;
2154 kaddr = kmap_atomic(page, KM_USER0); 2152 zero_user_page(page, offset, length, KM_USER0);
2155 memset(kaddr + offset, 0, length);
2156 flush_dcache_page(page);
2157 kunmap_atomic(kaddr, KM_USER0);
2158 if (buffer_mapped(bh) && bh->b_blocknr != 0) { 2153 if (buffer_mapped(bh) && bh->b_blocknr != 0) {
2159 mark_buffer_dirty(bh); 2154 mark_buffer_dirty(bh);
2160 } 2155 }
@@ -2370,7 +2365,6 @@ static int reiserfs_write_full_page(struct page *page,
2370 ** last byte in the file 2365 ** last byte in the file
2371 */ 2366 */
2372 if (page->index >= end_index) { 2367 if (page->index >= end_index) {
2373 char *kaddr;
2374 unsigned last_offset; 2368 unsigned last_offset;
2375 2369
2376 last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1); 2370 last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
@@ -2379,10 +2373,7 @@ static int reiserfs_write_full_page(struct page *page,
2379 unlock_page(page); 2373 unlock_page(page);
2380 return 0; 2374 return 0;
2381 } 2375 }
2382 kaddr = kmap_atomic(page, KM_USER0); 2376 zero_user_page(page, last_offset, PAGE_CACHE_SIZE - last_offset, KM_USER0);
2383 memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE - last_offset);
2384 flush_dcache_page(page);
2385 kunmap_atomic(kaddr, KM_USER0);
2386 } 2377 }
2387 bh = head; 2378 bh = head;
2388 block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits); 2379 block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits);