imported kvme080 board support patch from
[powerpc.git] / fs / mpage.c
index 1e45982..0fb914f 100644 (file)
@@ -284,11 +284,9 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
        }
 
        if (first_hole != blocks_per_page) {
-               char *kaddr = kmap_atomic(page, KM_USER0);
-               memset(kaddr + (first_hole << blkbits), 0,
-                               PAGE_CACHE_SIZE - (first_hole << blkbits));
-               flush_dcache_page(page);
-               kunmap_atomic(kaddr, KM_USER0);
+               zero_user_page(page, first_hole << blkbits,
+                               PAGE_CACHE_SIZE - (first_hole << blkbits),
+                               KM_USER0);
                if (first_hole == 0) {
                        SetPageUptodate(page);
                        unlock_page(page);
@@ -576,14 +574,11 @@ page_is_mapped:
                 * written out to the file."
                 */
                unsigned offset = i_size & (PAGE_CACHE_SIZE - 1);
-               char *kaddr;
 
                if (page->index > end_index || !offset)
                        goto confused;
-               kaddr = kmap_atomic(page, KM_USER0);
-               memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset);
-               flush_dcache_page(page);
-               kunmap_atomic(kaddr, KM_USER0);
+               zero_user_page(page, offset, PAGE_CACHE_SIZE - offset,
+                               KM_USER0);
        }
 
        /*
@@ -663,12 +658,7 @@ confused:
        /*
         * The caller has a ref on the inode, so *mapping is stable
         */
-       if (*ret) {
-               if (*ret == -ENOSPC)
-                       set_bit(AS_ENOSPC, &mapping->flags);
-               else
-                       set_bit(AS_EIO, &mapping->flags);
-       }
+       mapping_set_error(mapping, *ret);
 out:
        return bio;
 }
@@ -693,6 +683,8 @@ out:
  * the call was made get new I/O started against them.  If wbc->sync_mode is
  * WB_SYNC_ALL then we were called for data integrity and we must wait for
  * existing IO to complete.
+ *
+ * If you fix this you should check generic_writepages() also!
  */
 int
 mpage_writepages(struct address_space *mapping,
@@ -774,14 +766,7 @@ retry:
 
                        if (writepage) {
                                ret = (*writepage)(page, wbc);
-                               if (ret) {
-                                       if (ret == -ENOSPC)
-                                               set_bit(AS_ENOSPC,
-                                                       &mapping->flags);
-                                       else
-                                               set_bit(AS_EIO,
-                                                       &mapping->flags);
-                               }
+                               mapping_set_error(mapping, ret);
                        } else {
                                bio = __mpage_writepage(bio, page, get_block,
                                                &last_block_in_bio, &ret, wbc,