powerpc/5200: Enable CPU_FTR_NEED_COHERENT for MPC52xx
[safe/jmp/linux-2.6] / fs / mpage.c
index 235e4d3..16c3ef3 100644 (file)
@@ -6,7 +6,7 @@
  * Contains functions related to preparing and submitting BIOs which contain
  * multiple pagecache pages.
  *
- * 15May2002   akpm@zip.com.au
+ * 15May2002   Andrew Morton
  *             Initial version
  * 27Jun2002   axboe@suse.de
  *             use bio_add_page() to build bio's just the right size
@@ -82,7 +82,7 @@ static void mpage_end_io_write(struct bio *bio, int err)
        bio_put(bio);
 }
 
-static struct bio *mpage_bio_submit(int rw, struct bio *bio)
+struct bio *mpage_bio_submit(int rw, struct bio *bio)
 {
        bio->bi_end_io = mpage_end_io_read;
        if (rw == WRITE)
@@ -90,6 +90,7 @@ static struct bio *mpage_bio_submit(int rw, struct bio *bio)
        submit_bio(rw, bio);
        return NULL;
 }
+EXPORT_SYMBOL(mpage_bio_submit);
 
 static struct bio *
 mpage_alloc(struct block_device *bdev,
@@ -240,7 +241,6 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
                                first_hole = page_block;
                        page_block++;
                        block_in_file++;
-                       clear_buffer_mapped(map_bh);
                        continue;
                }
 
@@ -307,7 +307,10 @@ alloc_new:
                goto alloc_new;
        }
 
-       if (buffer_boundary(map_bh) || (first_hole != blocks_per_page))
+       relative_block = block_in_file - *first_logical_block;
+       nblocks = map_bh->b_size >> blkbits;
+       if ((buffer_boundary(map_bh) && relative_block == nblocks) ||
+           (first_hole != blocks_per_page))
                bio = mpage_bio_submit(READ, bio);
        else
                *last_block_in_bio = blocks[blocks_per_page - 1];
@@ -435,15 +438,9 @@ EXPORT_SYMBOL(mpage_readpage);
  * written, so it can intelligently allocate a suitably-sized BIO.  For now,
  * just allocate full-size (16-page) BIOs.
  */
-struct mpage_data {
-       struct bio *bio;
-       sector_t last_block_in_bio;
-       get_block_t *get_block;
-       unsigned use_writepage;
-};
 
-static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
-                            void *data)
+int __mpage_writepage(struct page *page, struct writeback_control *wbc,
+                     void *data)
 {
        struct mpage_data *mpd = data;
        struct bio *bio = mpd->bio;
@@ -651,6 +648,7 @@ out:
        mpd->bio = bio;
        return ret;
 }
+EXPORT_SYMBOL(__mpage_writepage);
 
 /**
  * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them