diff options
author | Nate Diller <nate.diller@gmail.com> | 2007-05-12 13:36:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-12 13:55:39 -0400 |
commit | e3bf460f3eb86cdbc76725a0dac1f191e796676c (patch) | |
tree | 7f11e16b4196735f62d4e3848f9084000b5e6b55 /fs/ntfs/file.c | |
parent | 6d690dcac92a84f98fd774862628ff871b713660 (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/ntfs/file.c')
-rw-r--r-- | fs/ntfs/file.c | 59 |
1 files changed, 17 insertions, 42 deletions
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 | } |