Commit 7637241e authored by Jens Axboe's avatar Jens Axboe

writeback: add wbc_to_write_flags()

Add wbc_to_write_flags(), which returns the write modifier flags to use,
based on a struct writeback_control. No functional changes in this
patch, but it prepares us for factoring other wbc fields for write type.
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 1d796d6a
...@@ -1697,7 +1697,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, ...@@ -1697,7 +1697,7 @@ int __block_write_full_page(struct inode *inode, struct page *page,
struct buffer_head *bh, *head; struct buffer_head *bh, *head;
unsigned int blocksize, bbits; unsigned int blocksize, bbits;
int nr_underway = 0; int nr_underway = 0;
int write_flags = (wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0); int write_flags = wbc_to_write_flags(wbc);
head = create_page_buffers(page, inode, head = create_page_buffers(page, inode,
(1 << BH_Dirty)|(1 << BH_Uptodate)); (1 << BH_Dirty)|(1 << BH_Uptodate));
......
...@@ -1249,7 +1249,7 @@ static int f2fs_write_data_page(struct page *page, ...@@ -1249,7 +1249,7 @@ static int f2fs_write_data_page(struct page *page,
.sbi = sbi, .sbi = sbi,
.type = DATA, .type = DATA,
.op = REQ_OP_WRITE, .op = REQ_OP_WRITE,
.op_flags = (wbc->sync_mode == WB_SYNC_ALL) ? REQ_SYNC : 0, .op_flags = wbc_to_write_flags(wbc),
.page = page, .page = page,
.encrypted_page = NULL, .encrypted_page = NULL,
}; };
......
...@@ -1570,7 +1570,7 @@ static int f2fs_write_node_page(struct page *page, ...@@ -1570,7 +1570,7 @@ static int f2fs_write_node_page(struct page *page,
.sbi = sbi, .sbi = sbi,
.type = NODE, .type = NODE,
.op = REQ_OP_WRITE, .op = REQ_OP_WRITE,
.op_flags = (wbc->sync_mode == WB_SYNC_ALL) ? REQ_SYNC : 0, .op_flags = wbc_to_write_flags(wbc),
.page = page, .page = page,
.encrypted_page = NULL, .encrypted_page = NULL,
}; };
......
...@@ -37,8 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb ...@@ -37,8 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
{ {
struct buffer_head *bh, *head; struct buffer_head *bh, *head;
int nr_underway = 0; int nr_underway = 0;
int write_flags = REQ_META | REQ_PRIO | int write_flags = REQ_META | REQ_PRIO | wbc_to_write_flags(wbc);
(wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0);
BUG_ON(!PageLocked(page)); BUG_ON(!PageLocked(page));
BUG_ON(!page_has_buffers(page)); BUG_ON(!page_has_buffers(page));
......
...@@ -489,7 +489,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, ...@@ -489,7 +489,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 op_flags = (wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0); int op_flags = wbc_to_write_flags(wbc);
if (page_has_buffers(page)) { if (page_has_buffers(page)) {
struct buffer_head *head = page_buffers(page); struct buffer_head *head = page_buffers(page);
......
...@@ -495,9 +495,7 @@ xfs_submit_ioend( ...@@ -495,9 +495,7 @@ xfs_submit_ioend(
ioend->io_bio->bi_private = ioend; ioend->io_bio->bi_private = ioend;
ioend->io_bio->bi_end_io = xfs_end_bio; ioend->io_bio->bi_end_io = xfs_end_bio;
ioend->io_bio->bi_opf = REQ_OP_WRITE; ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
if (wbc->sync_mode == WB_SYNC_ALL)
ioend->io_bio->bi_opf |= REQ_SYNC;
/* /*
* If we are failing the IO now, just mark the ioend with an * If we are failing the IO now, just mark the ioend with an
...@@ -569,9 +567,7 @@ xfs_chain_bio( ...@@ -569,9 +567,7 @@ xfs_chain_bio(
bio_chain(ioend->io_bio, new); bio_chain(ioend->io_bio, new);
bio_get(ioend->io_bio); /* for xfs_destroy_ioend */ bio_get(ioend->io_bio); /* for xfs_destroy_ioend */
ioend->io_bio->bi_opf = REQ_OP_WRITE; ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
if (wbc->sync_mode == WB_SYNC_ALL)
ioend->io_bio->bi_opf |= REQ_SYNC;
submit_bio(ioend->io_bio); submit_bio(ioend->io_bio);
ioend->io_bio = new; ioend->io_bio = new;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/flex_proportions.h> #include <linux/flex_proportions.h>
#include <linux/backing-dev-defs.h> #include <linux/backing-dev-defs.h>
#include <linux/blk_types.h>
struct bio; struct bio;
...@@ -102,6 +103,14 @@ struct writeback_control { ...@@ -102,6 +103,14 @@ struct writeback_control {
#endif #endif
}; };
static inline int wbc_to_write_flags(struct writeback_control *wbc)
{
if (wbc->sync_mode == WB_SYNC_ALL)
return REQ_SYNC;
return 0;
}
/* /*
* A wb_domain represents a domain that wb's (bdi_writeback's) belong to * A wb_domain represents a domain that wb's (bdi_writeback's) belong to
* and are measured against each other in. There always is one global * and are measured against each other in. There always is one global
......
...@@ -320,10 +320,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, ...@@ -320,10 +320,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
if (wbc->sync_mode == WB_SYNC_ALL) bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC);
else
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
count_vm_event(PSWPOUT); count_vm_event(PSWPOUT);
set_page_writeback(page); set_page_writeback(page);
unlock_page(page); unlock_page(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment