block: remove the per-bio/request write hint
[linux-2.6-microblaze.git] / fs / mpage.c
index 87f5cfe..c6379a8 100644 (file)
@@ -57,38 +57,14 @@ static void mpage_end_io(struct bio *bio)
        bio_put(bio);
 }
 
-static struct bio *mpage_bio_submit(int op, int op_flags, struct bio *bio)
+static struct bio *mpage_bio_submit(struct bio *bio)
 {
        bio->bi_end_io = mpage_end_io;
-       bio_set_op_attrs(bio, op, op_flags);
        guard_bio_eod(bio);
        submit_bio(bio);
        return NULL;
 }
 
-static struct bio *
-mpage_alloc(struct block_device *bdev,
-               sector_t first_sector, int nr_vecs,
-               gfp_t gfp_flags)
-{
-       struct bio *bio;
-
-       /* Restrict the given (page cache) mask for slab allocations */
-       gfp_flags &= GFP_KERNEL;
-       bio = bio_alloc(gfp_flags, nr_vecs);
-
-       if (bio == NULL && (current->flags & PF_MEMALLOC)) {
-               while (!bio && (nr_vecs /= 2))
-                       bio = bio_alloc(gfp_flags, nr_vecs);
-       }
-
-       if (bio) {
-               bio_set_dev(bio, bdev);
-               bio->bi_iter.bi_sector = first_sector;
-       }
-       return bio;
-}
-
 /*
  * support function for mpage_readahead.  The fs supplied get_block might
  * return an up to date buffer.  This is used to map that buffer into
@@ -169,16 +145,15 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
        struct block_device *bdev = NULL;
        int length;
        int fully_mapped = 1;
-       int op_flags;
+       int op = REQ_OP_READ;
        unsigned nblocks;
        unsigned relative_block;
        gfp_t gfp;
 
        if (args->is_readahead) {
-               op_flags = REQ_RAHEAD;
+               op |= REQ_RAHEAD;
                gfp = readahead_gfp_mask(page->mapping);
        } else {
-               op_flags = 0;
                gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL);
        }
 
@@ -287,7 +262,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
         * This page will go to BIO.  Do we need to send this BIO off first?
         */
        if (args->bio && (args->last_block_in_bio != blocks[0] - 1))
-               args->bio = mpage_bio_submit(REQ_OP_READ, op_flags, args->bio);
+               args->bio = mpage_bio_submit(args->bio);
 
 alloc_new:
        if (args->bio == NULL) {
@@ -296,15 +271,16 @@ alloc_new:
                                                                page))
                                goto out;
                }
-               args->bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-                                       bio_max_segs(args->nr_pages), gfp);
+               args->bio = bio_alloc(bdev, bio_max_segs(args->nr_pages), op,
+                                     gfp);
                if (args->bio == NULL)
                        goto confused;
+               args->bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9);
        }
 
        length = first_hole << blkbits;
        if (bio_add_page(args->bio, page, length, 0) < length) {
-               args->bio = mpage_bio_submit(REQ_OP_READ, op_flags, args->bio);
+               args->bio = mpage_bio_submit(args->bio);
                goto alloc_new;
        }
 
@@ -312,7 +288,7 @@ alloc_new:
        nblocks = map_bh->b_size >> blkbits;
        if ((buffer_boundary(map_bh) && relative_block == nblocks) ||
            (first_hole != blocks_per_page))
-               args->bio = mpage_bio_submit(REQ_OP_READ, op_flags, args->bio);
+               args->bio = mpage_bio_submit(args->bio);
        else
                args->last_block_in_bio = blocks[blocks_per_page - 1];
 out:
@@ -320,7 +296,7 @@ out:
 
 confused:
        if (args->bio)
-               args->bio = mpage_bio_submit(REQ_OP_READ, op_flags, args->bio);
+               args->bio = mpage_bio_submit(args->bio);
        if (!PageUptodate(page))
                block_read_full_page(page, args->get_block);
        else
@@ -383,7 +359,7 @@ void mpage_readahead(struct readahead_control *rac, get_block_t get_block)
                put_page(page);
        }
        if (args.bio)
-               mpage_bio_submit(REQ_OP_READ, REQ_RAHEAD, args.bio);
+               mpage_bio_submit(args.bio);
 }
 EXPORT_SYMBOL(mpage_readahead);
 
@@ -400,7 +376,7 @@ int mpage_readpage(struct page *page, get_block_t get_block)
 
        args.bio = do_mpage_readpage(&args);
        if (args.bio)
-               mpage_bio_submit(REQ_OP_READ, 0, args.bio);
+               mpage_bio_submit(args.bio);
        return 0;
 }
 EXPORT_SYMBOL(mpage_readpage);
@@ -491,7 +467,6 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
        struct buffer_head map_bh;
        loff_t i_size = i_size_read(inode);
        int ret = 0;
-       int op_flags = wbc_to_write_flags(wbc);
 
        if (page_has_buffers(page)) {
                struct buffer_head *head = page_buffers(page);
@@ -599,7 +574,7 @@ page_is_mapped:
         * This page will go to BIO.  Do we need to send this BIO off first?
         */
        if (bio && mpd->last_block_in_bio != blocks[0] - 1)
-               bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
+               bio = mpage_bio_submit(bio);
 
 alloc_new:
        if (bio == NULL) {
@@ -608,13 +583,11 @@ alloc_new:
                                                                page, wbc))
                                goto out;
                }
-               bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-                               BIO_MAX_VECS, GFP_NOFS|__GFP_HIGH);
-               if (bio == NULL)
-                       goto confused;
-
+               bio = bio_alloc(bdev, BIO_MAX_VECS,
+                               REQ_OP_WRITE | wbc_to_write_flags(wbc),
+                               GFP_NOFS);
+               bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9);
                wbc_init_bio(wbc, bio);
-               bio->bi_write_hint = inode->i_write_hint;
        }
 
        /*
@@ -625,7 +598,7 @@ alloc_new:
        wbc_account_cgroup_owner(wbc, page, PAGE_SIZE);
        length = first_unmapped << blkbits;
        if (bio_add_page(bio, page, length, 0) < length) {
-               bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
+               bio = mpage_bio_submit(bio);
                goto alloc_new;
        }
 
@@ -635,7 +608,7 @@ alloc_new:
        set_page_writeback(page);
        unlock_page(page);
        if (boundary || (first_unmapped != blocks_per_page)) {
-               bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
+               bio = mpage_bio_submit(bio);
                if (boundary_block) {
                        write_boundary_block(boundary_bdev,
                                        boundary_block, 1 << blkbits);
@@ -647,7 +620,7 @@ alloc_new:
 
 confused:
        if (bio)
-               bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
+               bio = mpage_bio_submit(bio);
 
        if (mpd->use_writepage) {
                ret = mapping->a_ops->writepage(page, wbc);
@@ -703,11 +676,8 @@ mpage_writepages(struct address_space *mapping,
                };
 
                ret = write_cache_pages(mapping, wbc, __mpage_writepage, &mpd);
-               if (mpd.bio) {
-                       int op_flags = (wbc->sync_mode == WB_SYNC_ALL ?
-                                 REQ_SYNC : 0);
-                       mpage_bio_submit(REQ_OP_WRITE, op_flags, mpd.bio);
-               }
+               if (mpd.bio)
+                       mpage_bio_submit(mpd.bio);
        }
        blk_finish_plug(&plug);
        return ret;
@@ -724,11 +694,8 @@ int mpage_writepage(struct page *page, get_block_t get_block,
                .use_writepage = 0,
        };
        int ret = __mpage_writepage(page, wbc, &mpd);
-       if (mpd.bio) {
-               int op_flags = (wbc->sync_mode == WB_SYNC_ALL ?
-                         REQ_SYNC : 0);
-               mpage_bio_submit(REQ_OP_WRITE, op_flags, mpd.bio);
-       }
+       if (mpd.bio)
+               mpage_bio_submit(mpd.bio);
        return ret;
 }
 EXPORT_SYMBOL(mpage_writepage);