aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2016-11-01 12:00:38 -0400
committerJens Axboe <axboe@fb.com>2016-11-02 12:24:03 -0400
commit7637241e651ec36e409412869f986dd5f097735f (patch)
treef91af371cfe570476ba301a33bcb4c3780c430b1
parent1d796d6a9641fbfcd90fcfaf6fb4894a13d0304f (diff)
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: Jens Axboe <axboe@fb.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/f2fs/data.c2
-rw-r--r--fs/f2fs/node.c2
-rw-r--r--fs/gfs2/meta_io.c3
-rw-r--r--fs/mpage.c2
-rw-r--r--fs/xfs/xfs_aops.c8
-rw-r--r--include/linux/writeback.h9
-rw-r--r--mm/page_io.c5
8 files changed, 17 insertions, 16 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index bc7c2bb30a9b..af5776da814a 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1697,7 +1697,7 @@ int __block_write_full_page(struct inode *inode, struct page *page,
1697 struct buffer_head *bh, *head; 1697 struct buffer_head *bh, *head;
1698 unsigned int blocksize, bbits; 1698 unsigned int blocksize, bbits;
1699 int nr_underway = 0; 1699 int nr_underway = 0;
1700 int write_flags = (wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0); 1700 int write_flags = wbc_to_write_flags(wbc);
1701 1701
1702 head = create_page_buffers(page, inode, 1702 head = create_page_buffers(page, inode,
1703 (1 << BH_Dirty)|(1 << BH_Uptodate)); 1703 (1 << BH_Dirty)|(1 << BH_Uptodate));
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b80bf10603d7..9e5561fa4cb6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1249,7 +1249,7 @@ static int f2fs_write_data_page(struct page *page,
1249 .sbi = sbi, 1249 .sbi = sbi,
1250 .type = DATA, 1250 .type = DATA,
1251 .op = REQ_OP_WRITE, 1251 .op = REQ_OP_WRITE,
1252 .op_flags = (wbc->sync_mode == WB_SYNC_ALL) ? REQ_SYNC : 0, 1252 .op_flags = wbc_to_write_flags(wbc),
1253 .page = page, 1253 .page = page,
1254 .encrypted_page = NULL, 1254 .encrypted_page = NULL,
1255 }; 1255 };
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 932f3f8bb57b..d1e29deb4598 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1570,7 +1570,7 @@ static int f2fs_write_node_page(struct page *page,
1570 .sbi = sbi, 1570 .sbi = sbi,
1571 .type = NODE, 1571 .type = NODE,
1572 .op = REQ_OP_WRITE, 1572 .op = REQ_OP_WRITE,
1573 .op_flags = (wbc->sync_mode == WB_SYNC_ALL) ? REQ_SYNC : 0, 1573 .op_flags = wbc_to_write_flags(wbc),
1574 .page = page, 1574 .page = page,
1575 .encrypted_page = NULL, 1575 .encrypted_page = NULL,
1576 }; 1576 };
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index e562b1191c9c..49db8ef13fdf 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -37,8 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
37{ 37{
38 struct buffer_head *bh, *head; 38 struct buffer_head *bh, *head;
39 int nr_underway = 0; 39 int nr_underway = 0;
40 int write_flags = REQ_META | REQ_PRIO | 40 int write_flags = REQ_META | REQ_PRIO | wbc_to_write_flags(wbc);
41 (wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0);
42 41
43 BUG_ON(!PageLocked(page)); 42 BUG_ON(!PageLocked(page));
44 BUG_ON(!page_has_buffers(page)); 43 BUG_ON(!page_has_buffers(page));
diff --git a/fs/mpage.c b/fs/mpage.c
index f35e2819d0c6..98fc11aa7e0b 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -489,7 +489,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
489 struct buffer_head map_bh; 489 struct buffer_head map_bh;
490 loff_t i_size = i_size_read(inode); 490 loff_t i_size = i_size_read(inode);
491 int ret = 0; 491 int ret = 0;
492 int op_flags = (wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0); 492 int op_flags = wbc_to_write_flags(wbc);
493 493
494 if (page_has_buffers(page)) { 494 if (page_has_buffers(page)) {
495 struct buffer_head *head = page_buffers(page); 495 struct buffer_head *head = page_buffers(page);
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 594e02c485b2..6be5204a06d3 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -495,9 +495,7 @@ xfs_submit_ioend(
495 495
496 ioend->io_bio->bi_private = ioend; 496 ioend->io_bio->bi_private = ioend;
497 ioend->io_bio->bi_end_io = xfs_end_bio; 497 ioend->io_bio->bi_end_io = xfs_end_bio;
498 ioend->io_bio->bi_opf = REQ_OP_WRITE; 498 ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
499 if (wbc->sync_mode == WB_SYNC_ALL)
500 ioend->io_bio->bi_opf |= REQ_SYNC;
501 499
502 /* 500 /*
503 * If we are failing the IO now, just mark the ioend with an 501 * If we are failing the IO now, just mark the ioend with an
@@ -569,9 +567,7 @@ xfs_chain_bio(
569 567
570 bio_chain(ioend->io_bio, new); 568 bio_chain(ioend->io_bio, new);
571 bio_get(ioend->io_bio); /* for xfs_destroy_ioend */ 569 bio_get(ioend->io_bio); /* for xfs_destroy_ioend */
572 ioend->io_bio->bi_opf = REQ_OP_WRITE; 570 ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
573 if (wbc->sync_mode == WB_SYNC_ALL)
574 ioend->io_bio->bi_opf |= REQ_SYNC;
575 submit_bio(ioend->io_bio); 571 submit_bio(ioend->io_bio);
576 ioend->io_bio = new; 572 ioend->io_bio = new;
577} 573}
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index e4c38703bf4e..50c96ee8108f 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -9,6 +9,7 @@
9#include <linux/fs.h> 9#include <linux/fs.h>
10#include <linux/flex_proportions.h> 10#include <linux/flex_proportions.h>
11#include <linux/backing-dev-defs.h> 11#include <linux/backing-dev-defs.h>
12#include <linux/blk_types.h>
12 13
13struct bio; 14struct bio;
14 15
@@ -102,6 +103,14 @@ struct writeback_control {
102#endif 103#endif
103}; 104};
104 105
106static inline int wbc_to_write_flags(struct writeback_control *wbc)
107{
108 if (wbc->sync_mode == WB_SYNC_ALL)
109 return REQ_SYNC;
110
111 return 0;
112}
113
105/* 114/*
106 * A wb_domain represents a domain that wb's (bdi_writeback's) belong to 115 * A wb_domain represents a domain that wb's (bdi_writeback's) belong to
107 * and are measured against each other in. There always is one global 116 * and are measured against each other in. There always is one global
diff --git a/mm/page_io.c b/mm/page_io.c
index a2651f58c86a..23f6d0d3470f 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -320,10 +320,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
320 ret = -ENOMEM; 320 ret = -ENOMEM;
321 goto out; 321 goto out;
322 } 322 }
323 if (wbc->sync_mode == WB_SYNC_ALL) 323 bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
324 bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC);
325 else
326 bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
327 count_vm_event(PSWPOUT); 324 count_vm_event(PSWPOUT);
328 set_page_writeback(page); 325 set_page_writeback(page);
329 unlock_page(page); 326 unlock_page(page);