[Devel] [PATCH RH7 3/9] writeback: add wbc_to_write_flags()
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Sat Sep 21 11:32:21 MSK 2019
From: Jens Axboe <axboe at fb.com>
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 at fb.com>
Reviewed-by: Jan Kara <jack at suse.cz>
Reviewed-by: Christoph Hellwig <hch at lst.de>
https://jira.sw.ru/browse/PSBM-96243
(cherry picked from commit 7637241e651ec36e409412869f986dd5f097735f)
Make wbc_to_write_flags return REQ_SYNC | REQ_NOIDLE as we don't
have commit a2b809672ee6 ("block: replace REQ_NOIDLE with REQ_IDLE")
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
fs/buffer.c | 3 +--
fs/f2fs/data.c | 2 +-
fs/f2fs/node.c | 2 +-
fs/gfs2/meta_io.c | 3 +--
fs/xfs/xfs_aops.c | 6 ++----
include/linux/writeback.h | 9 +++++++++
mm/page_io.c | 3 +--
7 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 2774c8bfb24e..4f7f05821e28 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1660,8 +1660,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_op = (wbc->sync_mode == WB_SYNC_ALL ?
- WRITE_SYNC : WRITE);
+ int write_op = WRITE | wbc_to_write_flags(wbc);
head = create_page_buffers(page, inode,
(1 << BH_Dirty)|(1 << BH_Uptodate));
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index f412cf901c1f..59a5fbbbb803 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -596,7 +596,7 @@ static int f2fs_write_data_pages(struct address_space *mapping,
ret = write_cache_pages(mapping, wbc, __f2fs_writepage, mapping);
if (locked)
mutex_unlock(&sbi->writepages);
- f2fs_submit_bio(sbi, DATA, (wbc->sync_mode == WB_SYNC_ALL));
+ f2fs_submit_bio(sbi, DATA, wbc_to_write_flags(wbc));
remove_dirty_dir_inode(inode);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 3df43b4efd89..b945a2c84267 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1116,7 +1116,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
}
if (wrote)
- f2fs_submit_bio(sbi, NODE, wbc->sync_mode == WB_SYNC_ALL);
+ f2fs_submit_bio(sbi, NODE, wbc_to_write_flags(wbc));
return nwritten;
}
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 8efc17222f4f..2fff9717590b 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
{
struct buffer_head *bh, *head;
int nr_underway = 0;
- int write_op = REQ_META | REQ_PRIO |
- (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
+ int write_op = REQ_META | REQ_PRIO | WRITE | wbc_to_write_flags(wbc);
BUG_ON(!PageLocked(page));
BUG_ON(!page_has_buffers(page));
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 86d17b28ebb0..e433934482fb 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -514,8 +514,7 @@ xfs_submit_ioend(
return status;
}
- submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE,
- ioend->io_bio);
+ submit_bio(WRITE | wbc_to_write_flags(wbc), ioend->io_bio);
return 0;
}
@@ -574,8 +573,7 @@ xfs_chain_bio(
bio_chain(ioend->io_bio, new);
bio_get(ioend->io_bio); /* for xfs_destroy_ioend */
- submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE,
- ioend->io_bio);
+ submit_bio(WRITE | wbc_to_write_flags(wbc), ioend->io_bio);
ioend->io_bio = new;
}
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index ac32152d95a5..fd3ec1c7b8a7 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -7,6 +7,7 @@
#include <linux/sched.h>
#include <linux/workqueue.h>
#include <linux/fs.h>
+#include <linux/blk_types.h>
#include <linux/rh_kabi.h>
@@ -87,6 +88,14 @@ struct writeback_control {
RH_KABI_RESERVE(2)
};
+static inline int wbc_to_write_flags(struct writeback_control *wbc)
+{
+ if (wbc->sync_mode == WB_SYNC_ALL)
+ return REQ_SYNC | REQ_NOIDLE;
+
+ return 0;
+}
+
/*
* fs/fs-writeback.c
*/
diff --git a/mm/page_io.c b/mm/page_io.c
index 0dc764df6ad2..0f29c247d64a 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -274,8 +274,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
ret = -ENOMEM;
goto out;
}
- if (wbc->sync_mode == WB_SYNC_ALL)
- rw |= REQ_SYNC;
+ rw |= wbc_to_write_flags(wbc) & ~REQ_NOIDLE;
count_vm_event(PSWPOUT);
set_page_writeback(page);
unlock_page(page);
--
2.21.0
More information about the Devel
mailing list