[RHEL7,COMMIT] ms/writeback: add wbc_to_write_flags()

Submitted by Konstantin Khorenko on Oct. 25, 2019, 10:17 a.m.

Details

Message ID 201910251017.x9PAHLdM004679@finist-ce7.sw.ru
State New
Series "block: backport writeback throttling"
Headers show

Commit Message

Konstantin Khorenko Oct. 25, 2019, 10:17 a.m.
The commit is pushed to "branch-rh7-3.10.0-1062.1.2.vz7.114.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.1.2.vz7.114.9
------>
commit 7f4e4674f3c9c9a31380d5ec0ada0a2cbb602d1c
Author: Jens Axboe <axboe@fb.com>
Date:   Fri Oct 25 13:17:21 2019 +0300

    ms/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>
    
    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@virtuozzo.com>
    
    =====================
    Patchset description:
    
    block: backport writeback throttling
    
    We have a problem that if we run heavy write load on one cpu
    simultaneousely with short direct reads on other cpu, the latter will
    hang significantly. Writeback throttling looks like a sollution for
    these reads, as it will decrease the priority of long running writeback.
    
    Running simple dd experiment we see that reads latency decreased after
    wbt patches applied:
    https://docs.google.com/spreadsheets/d/1HLtepwFL_N5zm0JcTqMtJoYnf-b6Slwld8DDgL0gNDI
    
    We've ran vconsolidate on custom kernel with these patches, though it
    does not show any performance improvement (likely because this test does
    not produce high rate of writeback), it does not crash or fail the test.
    
    https://jira.sw.ru/browse/PSBM-96243
    
    Jens Axboe (6):
      block: add REQ_BACKGROUND
      writeback: add wbc_to_write_flags()
      writeback: mark background writeback as such
      writeback: track if we're sleeping on progress in
        balance_dirty_pages()
      blk-wbt: add general throttling mechanism
      block: hook up writeback throttling
    
    Omar Sandoval (1):
      block: get rid of struct blk_issue_stat
    
    Pavel Tikhomirov (2):
      x86/asm: remove the unused get_limit() method
      block: enable CONFIG_BLK_WBT*
      blk-wbt: increase maximum queue depth to increase performance of writes
---
 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(-)

Patch hide | download patch | download mbox

diff --git a/fs/buffer.c b/fs/buffer.c
index 55d3cc7e5c6d..183910e7fcd6 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 3d1bdc06bf0b..f0e1be57183f 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -538,8 +538,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;
 }
 
@@ -598,8 +597,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 0e47883bc6a2..d62d15fa4863 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);