writeback: add wbc_to_write_flags()
authorJens Axboe <axboe@fb.com>
Tue, 1 Nov 2016 16:00:38 +0000 (10:00 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 2 Nov 2016 16:24:03 +0000 (10:24 -0600)
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>
fs/buffer.c
fs/f2fs/data.c
fs/f2fs/node.c
fs/gfs2/meta_io.c
fs/mpage.c
fs/xfs/xfs_aops.c
include/linux/writeback.h
mm/page_io.c

index bc7c2bb30a9bfa0f9accff7cfa8142b3aa07af24..af5776da814af7d678ef98a90d9f2d9e488bb64b 100644 (file)
@@ -1697,7 +1697,7 @@ int __block_write_full_page(struct inode *inode, struct page *page,
        struct buffer_head *bh, *head;
        unsigned int blocksize, bbits;
        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,
                                        (1 << BH_Dirty)|(1 << BH_Uptodate));
index b80bf10603d74821588ca5122e64c206036dc1a9..9e5561fa4cb638219d44052ca8d3f7ff248f0695 100644 (file)
@@ -1249,7 +1249,7 @@ static int f2fs_write_data_page(struct page *page,
                .sbi = sbi,
                .type = DATA,
                .op = REQ_OP_WRITE,
-               .op_flags = (wbc->sync_mode == WB_SYNC_ALL) ? REQ_SYNC : 0,
+               .op_flags = wbc_to_write_flags(wbc),
                .page = page,
                .encrypted_page = NULL,
        };
index 932f3f8bb57bba26b6e7da11edc491dae18523a7..d1e29deb4598f3b6c264b6678fb780b2cea9d67b 100644 (file)
@@ -1570,7 +1570,7 @@ static int f2fs_write_node_page(struct page *page,
                .sbi = sbi,
                .type = NODE,
                .op = REQ_OP_WRITE,
-               .op_flags = (wbc->sync_mode == WB_SYNC_ALL) ? REQ_SYNC : 0,
+               .op_flags = wbc_to_write_flags(wbc),
                .page = page,
                .encrypted_page = NULL,
        };
index e562b1191c9c8d5abc6a2b5d3d21bcae8c640c66..49db8ef13fdff5308e7e49e5765f91cb58d9ab33 100644 (file)
@@ -37,8 +37,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
 {
        struct buffer_head *bh, *head;
        int nr_underway = 0;
-       int write_flags = REQ_META | REQ_PRIO |
-               (wbc->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0);
+       int write_flags = REQ_META | REQ_PRIO | wbc_to_write_flags(wbc);
 
        BUG_ON(!PageLocked(page));
        BUG_ON(!page_has_buffers(page));
index f35e2819d0c699487c692e94e74ac794edd3c206..98fc11aa7e0b725b56154f44c37d11c842397df9 100644 (file)
@@ -489,7 +489,7 @@ 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->sync_mode == WB_SYNC_ALL ? REQ_SYNC : 0);
+       int op_flags = wbc_to_write_flags(wbc);
 
        if (page_has_buffers(page)) {
                struct buffer_head *head = page_buffers(page);
index 594e02c485b23d0359254ca31b03ffcebb4d90fb..6be5204a06d3ac1fc8da7e486b92ac00cf0a45bb 100644 (file)
@@ -495,9 +495,7 @@ xfs_submit_ioend(
 
        ioend->io_bio->bi_private = ioend;
        ioend->io_bio->bi_end_io = xfs_end_bio;
-       ioend->io_bio->bi_opf = REQ_OP_WRITE;
-       if (wbc->sync_mode == WB_SYNC_ALL)
-               ioend->io_bio->bi_opf |= REQ_SYNC;
+       ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
 
        /*
         * If we are failing the IO now, just mark the ioend with an
@@ -569,9 +567,7 @@ xfs_chain_bio(
 
        bio_chain(ioend->io_bio, new);
        bio_get(ioend->io_bio);         /* for xfs_destroy_ioend */
-       ioend->io_bio->bi_opf = REQ_OP_WRITE;
-       if (wbc->sync_mode == WB_SYNC_ALL)
-               ioend->io_bio->bi_opf |= REQ_SYNC;
+       ioend->io_bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
        submit_bio(ioend->io_bio);
        ioend->io_bio = new;
 }
index e4c38703bf4e5c6efe837c60f64ff66a0a8a4ad3..50c96ee8108f90ed527ec9f7c28abe32420b225a 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/fs.h>
 #include <linux/flex_proportions.h>
 #include <linux/backing-dev-defs.h>
+#include <linux/blk_types.h>
 
 struct bio;
 
@@ -102,6 +103,14 @@ struct writeback_control {
 #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
  * and are measured against each other in.  There always is one global
index a2651f58c86a25f3cc9190c8b98aaf5bf615a174..23f6d0d3470fb3a92e7932890c340055540baf55 100644 (file)
@@ -320,10 +320,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
                ret = -ENOMEM;
                goto out;
        }
-       if (wbc->sync_mode == WB_SYNC_ALL)
-               bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC);
-       else
-               bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
+       bio->bi_opf = REQ_OP_WRITE | wbc_to_write_flags(wbc);
        count_vm_event(PSWPOUT);
        set_page_writeback(page);
        unlock_page(page);