提交 eed25cd5 编写于 作者: M Mike Christie 提交者: Jens Axboe

mpage: use bio op accessors

Separate the op from the rq_flag_bits and have the mpage code
set/get the bio using bio_set_op_attrs/bio_op.
Signed-off-by: NMike Christie <mchristi@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NHannes Reinecke <hare@suse.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 67ed2596
...@@ -56,11 +56,11 @@ static void mpage_end_io(struct bio *bio) ...@@ -56,11 +56,11 @@ static void mpage_end_io(struct bio *bio)
bio_put(bio); bio_put(bio);
} }
static struct bio *mpage_bio_submit(int rw, struct bio *bio) static struct bio *mpage_bio_submit(int op, int op_flags, struct bio *bio)
{ {
bio->bi_end_io = mpage_end_io; bio->bi_end_io = mpage_end_io;
bio->bi_rw = rw; bio_set_op_attrs(bio, op, op_flags);
guard_bio_eod(rw, bio); guard_bio_eod(op, bio);
submit_bio(bio); submit_bio(bio);
return NULL; return NULL;
} }
...@@ -270,7 +270,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, ...@@ -270,7 +270,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
* This page will go to BIO. Do we need to send this BIO off first? * This page will go to BIO. Do we need to send this BIO off first?
*/ */
if (bio && (*last_block_in_bio != blocks[0] - 1)) if (bio && (*last_block_in_bio != blocks[0] - 1))
bio = mpage_bio_submit(READ, bio); bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
alloc_new: alloc_new:
if (bio == NULL) { if (bio == NULL) {
...@@ -287,7 +287,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, ...@@ -287,7 +287,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
length = first_hole << blkbits; length = first_hole << blkbits;
if (bio_add_page(bio, page, length, 0) < length) { if (bio_add_page(bio, page, length, 0) < length) {
bio = mpage_bio_submit(READ, bio); bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
goto alloc_new; goto alloc_new;
} }
...@@ -295,7 +295,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, ...@@ -295,7 +295,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
nblocks = map_bh->b_size >> blkbits; nblocks = map_bh->b_size >> blkbits;
if ((buffer_boundary(map_bh) && relative_block == nblocks) || if ((buffer_boundary(map_bh) && relative_block == nblocks) ||
(first_hole != blocks_per_page)) (first_hole != blocks_per_page))
bio = mpage_bio_submit(READ, bio); bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
else else
*last_block_in_bio = blocks[blocks_per_page - 1]; *last_block_in_bio = blocks[blocks_per_page - 1];
out: out:
...@@ -303,7 +303,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, ...@@ -303,7 +303,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
confused: confused:
if (bio) if (bio)
bio = mpage_bio_submit(READ, bio); bio = mpage_bio_submit(REQ_OP_READ, 0, bio);
if (!PageUptodate(page)) if (!PageUptodate(page))
block_read_full_page(page, get_block); block_read_full_page(page, get_block);
else else
...@@ -385,7 +385,7 @@ mpage_readpages(struct address_space *mapping, struct list_head *pages, ...@@ -385,7 +385,7 @@ mpage_readpages(struct address_space *mapping, struct list_head *pages,
} }
BUG_ON(!list_empty(pages)); BUG_ON(!list_empty(pages));
if (bio) if (bio)
mpage_bio_submit(READ, bio); mpage_bio_submit(REQ_OP_READ, 0, bio);
return 0; return 0;
} }
EXPORT_SYMBOL(mpage_readpages); EXPORT_SYMBOL(mpage_readpages);
...@@ -406,7 +406,7 @@ int mpage_readpage(struct page *page, get_block_t get_block) ...@@ -406,7 +406,7 @@ int mpage_readpage(struct page *page, get_block_t get_block)
bio = do_mpage_readpage(bio, page, 1, &last_block_in_bio, bio = do_mpage_readpage(bio, page, 1, &last_block_in_bio,
&map_bh, &first_logical_block, get_block, gfp); &map_bh, &first_logical_block, get_block, gfp);
if (bio) if (bio)
mpage_bio_submit(READ, bio); mpage_bio_submit(REQ_OP_READ, 0, bio);
return 0; return 0;
} }
EXPORT_SYMBOL(mpage_readpage); EXPORT_SYMBOL(mpage_readpage);
...@@ -487,7 +487,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, ...@@ -487,7 +487,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
struct buffer_head map_bh; struct buffer_head map_bh;
loff_t i_size = i_size_read(inode); loff_t i_size = i_size_read(inode);
int ret = 0; int ret = 0;
int wr = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); int op_flags = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : 0);
if (page_has_buffers(page)) { if (page_has_buffers(page)) {
struct buffer_head *head = page_buffers(page); struct buffer_head *head = page_buffers(page);
...@@ -596,7 +596,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, ...@@ -596,7 +596,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
* This page will go to BIO. Do we need to send this BIO off first? * 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) if (bio && mpd->last_block_in_bio != blocks[0] - 1)
bio = mpage_bio_submit(wr, bio); bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
alloc_new: alloc_new:
if (bio == NULL) { if (bio == NULL) {
...@@ -623,7 +623,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, ...@@ -623,7 +623,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
wbc_account_io(wbc, page, PAGE_SIZE); wbc_account_io(wbc, page, PAGE_SIZE);
length = first_unmapped << blkbits; length = first_unmapped << blkbits;
if (bio_add_page(bio, page, length, 0) < length) { if (bio_add_page(bio, page, length, 0) < length) {
bio = mpage_bio_submit(wr, bio); bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
goto alloc_new; goto alloc_new;
} }
...@@ -633,7 +633,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, ...@@ -633,7 +633,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
set_page_writeback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
if (boundary || (first_unmapped != blocks_per_page)) { if (boundary || (first_unmapped != blocks_per_page)) {
bio = mpage_bio_submit(wr, bio); bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
if (boundary_block) { if (boundary_block) {
write_boundary_block(boundary_bdev, write_boundary_block(boundary_bdev,
boundary_block, 1 << blkbits); boundary_block, 1 << blkbits);
...@@ -645,7 +645,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, ...@@ -645,7 +645,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
confused: confused:
if (bio) if (bio)
bio = mpage_bio_submit(wr, bio); bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);
if (mpd->use_writepage) { if (mpd->use_writepage) {
ret = mapping->a_ops->writepage(page, wbc); ret = mapping->a_ops->writepage(page, wbc);
...@@ -702,9 +702,9 @@ mpage_writepages(struct address_space *mapping, ...@@ -702,9 +702,9 @@ mpage_writepages(struct address_space *mapping,
ret = write_cache_pages(mapping, wbc, __mpage_writepage, &mpd); ret = write_cache_pages(mapping, wbc, __mpage_writepage, &mpd);
if (mpd.bio) { if (mpd.bio) {
int wr = (wbc->sync_mode == WB_SYNC_ALL ? int op_flags = (wbc->sync_mode == WB_SYNC_ALL ?
WRITE_SYNC : WRITE); WRITE_SYNC : 0);
mpage_bio_submit(wr, mpd.bio); mpage_bio_submit(REQ_OP_WRITE, op_flags, mpd.bio);
} }
} }
blk_finish_plug(&plug); blk_finish_plug(&plug);
...@@ -723,9 +723,9 @@ int mpage_writepage(struct page *page, get_block_t get_block, ...@@ -723,9 +723,9 @@ int mpage_writepage(struct page *page, get_block_t get_block,
}; };
int ret = __mpage_writepage(page, wbc, &mpd); int ret = __mpage_writepage(page, wbc, &mpd);
if (mpd.bio) { if (mpd.bio) {
int wr = (wbc->sync_mode == WB_SYNC_ALL ? int op_flags = (wbc->sync_mode == WB_SYNC_ALL ?
WRITE_SYNC : WRITE); WRITE_SYNC : 0);
mpage_bio_submit(wr, mpd.bio); mpage_bio_submit(REQ_OP_WRITE, op_flags, mpd.bio);
} }
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册