aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNate Diller <nate.diller@gmail.com>2007-05-12 13:36:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-12 13:55:39 -0400
commite3bf460f3eb86cdbc76725a0dac1f191e796676c (patch)
tree7f11e16b4196735f62d4e3848f9084000b5e6b55 /fs
parent6d690dcac92a84f98fd774862628ff871b713660 (diff)
ntfs: use zero_user_page
Use zero_user_page() instead of open-coding it. [akpm@linux-foundation.org: kmap-type fixes] Signed-off-by: Nate Diller <nate.diller@gmail.com> Acked-by: Anton Altaparmakov <aia21@cantab.net> 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/ntfs/aops.c36
-rw-r--r--fs/ntfs/file.c59
2 files changed, 26 insertions, 69 deletions
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 629e7abdd840..6e5c2534f4bc 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -86,19 +86,15 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
86 } 86 }
87 /* Check for the current buffer head overflowing. */ 87 /* Check for the current buffer head overflowing. */
88 if (unlikely(file_ofs + bh->b_size > init_size)) { 88 if (unlikely(file_ofs + bh->b_size > init_size)) {
89 u8 *kaddr;
90 int ofs; 89 int ofs;
91 90
92 ofs = 0; 91 ofs = 0;
93 if (file_ofs < init_size) 92 if (file_ofs < init_size)
94 ofs = init_size - file_ofs; 93 ofs = init_size - file_ofs;
95 local_irq_save(flags); 94 local_irq_save(flags);
96 kaddr = kmap_atomic(page, KM_BIO_SRC_IRQ); 95 zero_user_page(page, bh_offset(bh) + ofs,
97 memset(kaddr + bh_offset(bh) + ofs, 0, 96 bh->b_size - ofs, KM_BIO_SRC_IRQ);
98 bh->b_size - ofs);
99 kunmap_atomic(kaddr, KM_BIO_SRC_IRQ);
100 local_irq_restore(flags); 97 local_irq_restore(flags);
101 flush_dcache_page(page);
102 } 98 }
103 } else { 99 } else {
104 clear_buffer_uptodate(bh); 100 clear_buffer_uptodate(bh);
@@ -245,8 +241,7 @@ static int ntfs_read_block(struct page *page)
245 rl = NULL; 241 rl = NULL;
246 nr = i = 0; 242 nr = i = 0;
247 do { 243 do {
248 u8 *kaddr; 244 int err = 0;
249 int err;
250 245
251 if (unlikely(buffer_uptodate(bh))) 246 if (unlikely(buffer_uptodate(bh)))
252 continue; 247 continue;
@@ -254,7 +249,6 @@ static int ntfs_read_block(struct page *page)
254 arr[nr++] = bh; 249 arr[nr++] = bh;
255 continue; 250 continue;
256 } 251 }
257 err = 0;
258 bh->b_bdev = vol->sb->s_bdev; 252 bh->b_bdev = vol->sb->s_bdev;
259 /* Is the block within the allowed limits? */ 253 /* Is the block within the allowed limits? */
260 if (iblock < lblock) { 254 if (iblock < lblock) {
@@ -340,10 +334,7 @@ handle_hole:
340 bh->b_blocknr = -1UL; 334 bh->b_blocknr = -1UL;
341 clear_buffer_mapped(bh); 335 clear_buffer_mapped(bh);
342handle_zblock: 336handle_zblock:
343 kaddr = kmap_atomic(page, KM_USER0); 337 zero_user_page(page, i * blocksize, blocksize, KM_USER0);
344 memset(kaddr + i * blocksize, 0, blocksize);
345 kunmap_atomic(kaddr, KM_USER0);
346 flush_dcache_page(page);
347 if (likely(!err)) 338 if (likely(!err))
348 set_buffer_uptodate(bh); 339 set_buffer_uptodate(bh);
349 } while (i++, iblock++, (bh = bh->b_this_page) != head); 340 } while (i++, iblock++, (bh = bh->b_this_page) != head);
@@ -460,10 +451,7 @@ retry_readpage:
460 * ok to ignore the compressed flag here. 451 * ok to ignore the compressed flag here.
461 */ 452 */
462 if (unlikely(page->index > 0)) { 453 if (unlikely(page->index > 0)) {
463 kaddr = kmap_atomic(page, KM_USER0); 454 zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
464 memset(kaddr, 0, PAGE_CACHE_SIZE);
465 flush_dcache_page(page);
466 kunmap_atomic(kaddr, KM_USER0);
467 goto done; 455 goto done;
468 } 456 }
469 if (!NInoAttr(ni)) 457 if (!NInoAttr(ni))
@@ -790,14 +778,10 @@ lock_retry_remap:
790 * uptodate so it can get discarded by the VM. 778 * uptodate so it can get discarded by the VM.
791 */ 779 */
792 if (err == -ENOENT || lcn == LCN_ENOENT) { 780 if (err == -ENOENT || lcn == LCN_ENOENT) {
793 u8 *kaddr;
794
795 bh->b_blocknr = -1; 781 bh->b_blocknr = -1;
796 clear_buffer_dirty(bh); 782 clear_buffer_dirty(bh);
797 kaddr = kmap_atomic(page, KM_USER0); 783 zero_user_page(page, bh_offset(bh), blocksize,
798 memset(kaddr + bh_offset(bh), 0, blocksize); 784 KM_USER0);
799 kunmap_atomic(kaddr, KM_USER0);
800 flush_dcache_page(page);
801 set_buffer_uptodate(bh); 785 set_buffer_uptodate(bh);
802 err = 0; 786 err = 0;
803 continue; 787 continue;
@@ -1422,10 +1406,8 @@ retry_writepage:
1422 if (page->index >= (i_size >> PAGE_CACHE_SHIFT)) { 1406 if (page->index >= (i_size >> PAGE_CACHE_SHIFT)) {
1423 /* The page straddles i_size. */ 1407 /* The page straddles i_size. */
1424 unsigned int ofs = i_size & ~PAGE_CACHE_MASK; 1408 unsigned int ofs = i_size & ~PAGE_CACHE_MASK;
1425 kaddr = kmap_atomic(page, KM_USER0); 1409 zero_user_page(page, ofs, PAGE_CACHE_SIZE - ofs,
1426 memset(kaddr + ofs, 0, PAGE_CACHE_SIZE - ofs); 1410 KM_USER0);
1427 kunmap_atomic(kaddr, KM_USER0);
1428 flush_dcache_page(page);
1429 } 1411 }
1430 /* Handle mst protected attributes. */ 1412 /* Handle mst protected attributes. */
1431 if (NInoMstProtected(ni)) 1413 if (NInoMstProtected(ni))
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 621de369e6f8..39a1669506bd 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -606,11 +606,8 @@ do_next_page:
606 ntfs_submit_bh_for_read(bh); 606 ntfs_submit_bh_for_read(bh);
607 *wait_bh++ = bh; 607 *wait_bh++ = bh;
608 } else { 608 } else {
609 u8 *kaddr = kmap_atomic(page, KM_USER0); 609 zero_user_page(page, bh_offset(bh),
610 memset(kaddr + bh_offset(bh), 0, 610 blocksize, KM_USER0);
611 blocksize);
612 kunmap_atomic(kaddr, KM_USER0);
613 flush_dcache_page(page);
614 set_buffer_uptodate(bh); 611 set_buffer_uptodate(bh);
615 } 612 }
616 } 613 }
@@ -685,12 +682,9 @@ map_buffer_cached:
685 ntfs_submit_bh_for_read(bh); 682 ntfs_submit_bh_for_read(bh);
686 *wait_bh++ = bh; 683 *wait_bh++ = bh;
687 } else { 684 } else {
688 u8 *kaddr = kmap_atomic(page, 685 zero_user_page(page,
689 KM_USER0); 686 bh_offset(bh),
690 memset(kaddr + bh_offset(bh), 687 blocksize, KM_USER0);
691 0, blocksize);
692 kunmap_atomic(kaddr, KM_USER0);
693 flush_dcache_page(page);
694 set_buffer_uptodate(bh); 688 set_buffer_uptodate(bh);
695 } 689 }
696 } 690 }
@@ -708,11 +702,8 @@ map_buffer_cached:
708 */ 702 */
709 if (bh_end <= pos || bh_pos >= end) { 703 if (bh_end <= pos || bh_pos >= end) {
710 if (!buffer_uptodate(bh)) { 704 if (!buffer_uptodate(bh)) {
711 u8 *kaddr = kmap_atomic(page, KM_USER0); 705 zero_user_page(page, bh_offset(bh),
712 memset(kaddr + bh_offset(bh), 0, 706 blocksize, KM_USER0);
713 blocksize);
714 kunmap_atomic(kaddr, KM_USER0);
715 flush_dcache_page(page);
716 set_buffer_uptodate(bh); 707 set_buffer_uptodate(bh);
717 } 708 }
718 mark_buffer_dirty(bh); 709 mark_buffer_dirty(bh);
@@ -751,10 +742,8 @@ map_buffer_cached:
751 if (!buffer_uptodate(bh)) 742 if (!buffer_uptodate(bh))
752 set_buffer_uptodate(bh); 743 set_buffer_uptodate(bh);
753 } else if (!buffer_uptodate(bh)) { 744 } else if (!buffer_uptodate(bh)) {
754 u8 *kaddr = kmap_atomic(page, KM_USER0); 745 zero_user_page(page, bh_offset(bh), blocksize,
755 memset(kaddr + bh_offset(bh), 0, blocksize); 746 KM_USER0);
756 kunmap_atomic(kaddr, KM_USER0);
757 flush_dcache_page(page);
758 set_buffer_uptodate(bh); 747 set_buffer_uptodate(bh);
759 } 748 }
760 continue; 749 continue;
@@ -878,11 +867,8 @@ rl_not_mapped_enoent:
878 if (!buffer_uptodate(bh)) 867 if (!buffer_uptodate(bh))
879 set_buffer_uptodate(bh); 868 set_buffer_uptodate(bh);
880 } else if (!buffer_uptodate(bh)) { 869 } else if (!buffer_uptodate(bh)) {
881 u8 *kaddr = kmap_atomic(page, KM_USER0); 870 zero_user_page(page, bh_offset(bh),
882 memset(kaddr + bh_offset(bh), 0, 871 blocksize, KM_USER0);
883 blocksize);
884 kunmap_atomic(kaddr, KM_USER0);
885 flush_dcache_page(page);
886 set_buffer_uptodate(bh); 872 set_buffer_uptodate(bh);
887 } 873 }
888 continue; 874 continue;
@@ -1137,16 +1123,12 @@ rl_not_mapped_enoent:
1137 * to zero the overflowing region. 1123 * to zero the overflowing region.
1138 */ 1124 */
1139 if (unlikely(bh_pos + blocksize > initialized_size)) { 1125 if (unlikely(bh_pos + blocksize > initialized_size)) {
1140 u8 *kaddr;
1141 int ofs = 0; 1126 int ofs = 0;
1142 1127
1143 if (likely(bh_pos < initialized_size)) 1128 if (likely(bh_pos < initialized_size))
1144 ofs = initialized_size - bh_pos; 1129 ofs = initialized_size - bh_pos;
1145 kaddr = kmap_atomic(page, KM_USER0); 1130 zero_user_page(page, bh_offset(bh) + ofs,
1146 memset(kaddr + bh_offset(bh) + ofs, 0, 1131 blocksize - ofs, KM_USER0);
1147 blocksize - ofs);
1148 kunmap_atomic(kaddr, KM_USER0);
1149 flush_dcache_page(page);
1150 } 1132 }
1151 } else /* if (unlikely(!buffer_uptodate(bh))) */ 1133 } else /* if (unlikely(!buffer_uptodate(bh))) */
1152 err = -EIO; 1134 err = -EIO;
@@ -1286,11 +1268,8 @@ rl_not_mapped_enoent:
1286 if (PageUptodate(page)) 1268 if (PageUptodate(page))
1287 set_buffer_uptodate(bh); 1269 set_buffer_uptodate(bh);
1288 else { 1270 else {
1289 u8 *kaddr = kmap_atomic(page, KM_USER0); 1271 zero_user_page(page, bh_offset(bh),
1290 memset(kaddr + bh_offset(bh), 0, 1272 blocksize, KM_USER0);
1291 blocksize);
1292 kunmap_atomic(kaddr, KM_USER0);
1293 flush_dcache_page(page);
1294 set_buffer_uptodate(bh); 1273 set_buffer_uptodate(bh);
1295 } 1274 }
1296 } 1275 }
@@ -1350,9 +1329,7 @@ err_out:
1350 len = PAGE_CACHE_SIZE; 1329 len = PAGE_CACHE_SIZE;
1351 if (len > bytes) 1330 if (len > bytes)
1352 len = bytes; 1331 len = bytes;
1353 kaddr = kmap_atomic(*pages, KM_USER0); 1332 zero_user_page(*pages, 0, len, KM_USER0);
1354 memset(kaddr, 0, len);
1355 kunmap_atomic(kaddr, KM_USER0);
1356 } 1333 }
1357 goto out; 1334 goto out;
1358} 1335}
@@ -1473,9 +1450,7 @@ err_out:
1473 len = PAGE_CACHE_SIZE; 1450 len = PAGE_CACHE_SIZE;
1474 if (len > bytes) 1451 if (len > bytes)
1475 len = bytes; 1452 len = bytes;
1476 kaddr = kmap_atomic(*pages, KM_USER0); 1453 zero_user_page(*pages, 0, len, KM_USER0);
1477 memset(kaddr, 0, len);
1478 kunmap_atomic(kaddr, KM_USER0);
1479 } 1454 }
1480 goto out; 1455 goto out;
1481} 1456}