diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-07-13 22:33:19 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-07-15 18:21:23 -0400 |
commit | 9dfa1baff76d08843aaf5e3c78f6da6950957702 (patch) | |
tree | 72de844844bf3a78ed02ba11e36b405246bf8a0d /fs/f2fs | |
parent | 82e0a5aa5ddf794b3e1b21fcd091228736871882 (diff) |
f2fs: use blk_plug in all the possible paths
This patch reverts 19a5f5e2ef37 (f2fs: drop any block plugging),
and adds blk_plug in write paths additionally.
The main reason is that blk_start_plug can be used to wake up from low-power
mode before submitting further bios.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/checkpoint.c | 7 | ||||
-rw-r--r-- | fs/f2fs/data.c | 3 | ||||
-rw-r--r-- | fs/f2fs/file.c | 6 | ||||
-rw-r--r-- | fs/f2fs/gc.c | 5 | ||||
-rw-r--r-- | fs/f2fs/node.c | 3 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 7 |
6 files changed, 29 insertions, 2 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 8ea895389ae4..be1c54b62388 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -265,6 +265,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping, | |||
265 | struct writeback_control *wbc) | 265 | struct writeback_control *wbc) |
266 | { | 266 | { |
267 | struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); | 267 | struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); |
268 | struct blk_plug plug; | ||
268 | long diff, written; | 269 | long diff, written; |
269 | 270 | ||
270 | /* collect a number of dirty meta pages and write together */ | 271 | /* collect a number of dirty meta pages and write together */ |
@@ -277,7 +278,9 @@ static int f2fs_write_meta_pages(struct address_space *mapping, | |||
277 | /* if mounting is failed, skip writing node pages */ | 278 | /* if mounting is failed, skip writing node pages */ |
278 | mutex_lock(&sbi->cp_mutex); | 279 | mutex_lock(&sbi->cp_mutex); |
279 | diff = nr_pages_to_write(sbi, META, wbc); | 280 | diff = nr_pages_to_write(sbi, META, wbc); |
281 | blk_start_plug(&plug); | ||
280 | written = sync_meta_pages(sbi, META, wbc->nr_to_write); | 282 | written = sync_meta_pages(sbi, META, wbc->nr_to_write); |
283 | blk_finish_plug(&plug); | ||
281 | mutex_unlock(&sbi->cp_mutex); | 284 | mutex_unlock(&sbi->cp_mutex); |
282 | wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff); | 285 | wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff); |
283 | return 0; | 286 | return 0; |
@@ -899,8 +902,11 @@ static int block_operations(struct f2fs_sb_info *sbi) | |||
899 | .nr_to_write = LONG_MAX, | 902 | .nr_to_write = LONG_MAX, |
900 | .for_reclaim = 0, | 903 | .for_reclaim = 0, |
901 | }; | 904 | }; |
905 | struct blk_plug plug; | ||
902 | int err = 0; | 906 | int err = 0; |
903 | 907 | ||
908 | blk_start_plug(&plug); | ||
909 | |||
904 | retry_flush_dents: | 910 | retry_flush_dents: |
905 | f2fs_lock_all(sbi); | 911 | f2fs_lock_all(sbi); |
906 | /* write all the dirty dentry pages */ | 912 | /* write all the dirty dentry pages */ |
@@ -937,6 +943,7 @@ retry_flush_nodes: | |||
937 | goto retry_flush_nodes; | 943 | goto retry_flush_nodes; |
938 | } | 944 | } |
939 | out: | 945 | out: |
946 | blk_finish_plug(&plug); | ||
940 | return err; | 947 | return err; |
941 | } | 948 | } |
942 | 949 | ||
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index adfe47b21991..87a458fb8afe 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
@@ -1438,6 +1438,7 @@ static int f2fs_write_data_pages(struct address_space *mapping, | |||
1438 | { | 1438 | { |
1439 | struct inode *inode = mapping->host; | 1439 | struct inode *inode = mapping->host; |
1440 | struct f2fs_sb_info *sbi = F2FS_I_SB(inode); | 1440 | struct f2fs_sb_info *sbi = F2FS_I_SB(inode); |
1441 | struct blk_plug plug; | ||
1441 | int ret; | 1442 | int ret; |
1442 | 1443 | ||
1443 | /* deal with chardevs and other special file */ | 1444 | /* deal with chardevs and other special file */ |
@@ -1463,7 +1464,9 @@ static int f2fs_write_data_pages(struct address_space *mapping, | |||
1463 | 1464 | ||
1464 | trace_f2fs_writepages(mapping->host, wbc, DATA); | 1465 | trace_f2fs_writepages(mapping->host, wbc, DATA); |
1465 | 1466 | ||
1467 | blk_start_plug(&plug); | ||
1466 | ret = f2fs_write_cache_pages(mapping, wbc); | 1468 | ret = f2fs_write_cache_pages(mapping, wbc); |
1469 | blk_finish_plug(&plug); | ||
1467 | /* | 1470 | /* |
1468 | * if some pages were truncated, we cannot guarantee its mapping->host | 1471 | * if some pages were truncated, we cannot guarantee its mapping->host |
1469 | * to detect pending bios. | 1472 | * to detect pending bios. |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 72e52cd15b60..47f1f5e36d1c 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -2102,6 +2102,7 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
2102 | { | 2102 | { |
2103 | struct file *file = iocb->ki_filp; | 2103 | struct file *file = iocb->ki_filp; |
2104 | struct inode *inode = file_inode(file); | 2104 | struct inode *inode = file_inode(file); |
2105 | struct blk_plug plug; | ||
2105 | ssize_t ret; | 2106 | ssize_t ret; |
2106 | 2107 | ||
2107 | if (f2fs_encrypted_inode(inode) && | 2108 | if (f2fs_encrypted_inode(inode) && |
@@ -2113,8 +2114,11 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
2113 | ret = generic_write_checks(iocb, from); | 2114 | ret = generic_write_checks(iocb, from); |
2114 | if (ret > 0) { | 2115 | if (ret > 0) { |
2115 | ret = f2fs_preallocate_blocks(iocb, from); | 2116 | ret = f2fs_preallocate_blocks(iocb, from); |
2116 | if (!ret) | 2117 | if (!ret) { |
2118 | blk_start_plug(&plug); | ||
2117 | ret = __generic_file_write_iter(iocb, from); | 2119 | ret = __generic_file_write_iter(iocb, from); |
2120 | blk_finish_plug(&plug); | ||
2121 | } | ||
2118 | } | 2122 | } |
2119 | inode_unlock(inode); | 2123 | inode_unlock(inode); |
2120 | 2124 | ||
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 5c8acf754513..de6c41c32c62 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c | |||
@@ -808,6 +808,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, | |||
808 | { | 808 | { |
809 | struct page *sum_page; | 809 | struct page *sum_page; |
810 | struct f2fs_summary_block *sum; | 810 | struct f2fs_summary_block *sum; |
811 | struct blk_plug plug; | ||
811 | unsigned int segno = start_segno; | 812 | unsigned int segno = start_segno; |
812 | unsigned int end_segno = start_segno + sbi->segs_per_sec; | 813 | unsigned int end_segno = start_segno + sbi->segs_per_sec; |
813 | int seg_freed = 0; | 814 | int seg_freed = 0; |
@@ -825,6 +826,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, | |||
825 | unlock_page(sum_page); | 826 | unlock_page(sum_page); |
826 | } | 827 | } |
827 | 828 | ||
829 | blk_start_plug(&plug); | ||
830 | |||
828 | for (segno = start_segno; segno < end_segno; segno++) { | 831 | for (segno = start_segno; segno < end_segno; segno++) { |
829 | 832 | ||
830 | if (get_valid_blocks(sbi, segno, 1) == 0) | 833 | if (get_valid_blocks(sbi, segno, 1) == 0) |
@@ -862,6 +865,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, | |||
862 | f2fs_submit_merged_bio(sbi, | 865 | f2fs_submit_merged_bio(sbi, |
863 | (type == SUM_TYPE_NODE) ? NODE : DATA, WRITE); | 866 | (type == SUM_TYPE_NODE) ? NODE : DATA, WRITE); |
864 | 867 | ||
868 | blk_finish_plug(&plug); | ||
869 | |||
865 | if (gc_type == FG_GC) { | 870 | if (gc_type == FG_GC) { |
866 | while (start_segno < end_segno) | 871 | while (start_segno < end_segno) |
867 | if (get_valid_blocks(sbi, start_segno++, 1) == 0) | 872 | if (get_valid_blocks(sbi, start_segno++, 1) == 0) |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index d78f61d647c0..79a93c6e632f 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -1618,6 +1618,7 @@ static int f2fs_write_node_pages(struct address_space *mapping, | |||
1618 | struct writeback_control *wbc) | 1618 | struct writeback_control *wbc) |
1619 | { | 1619 | { |
1620 | struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); | 1620 | struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); |
1621 | struct blk_plug plug; | ||
1621 | long diff; | 1622 | long diff; |
1622 | 1623 | ||
1623 | /* balancing f2fs's metadata in background */ | 1624 | /* balancing f2fs's metadata in background */ |
@@ -1631,7 +1632,9 @@ static int f2fs_write_node_pages(struct address_space *mapping, | |||
1631 | 1632 | ||
1632 | diff = nr_pages_to_write(sbi, NODE, wbc); | 1633 | diff = nr_pages_to_write(sbi, NODE, wbc); |
1633 | wbc->sync_mode = WB_SYNC_NONE; | 1634 | wbc->sync_mode = WB_SYNC_NONE; |
1635 | blk_start_plug(&plug); | ||
1634 | sync_node_pages(sbi, wbc); | 1636 | sync_node_pages(sbi, wbc); |
1637 | blk_finish_plug(&plug); | ||
1635 | wbc->nr_to_write = max((long)0, wbc->nr_to_write - diff); | 1638 | wbc->nr_to_write = max((long)0, wbc->nr_to_write - diff); |
1636 | return 0; | 1639 | return 0; |
1637 | 1640 | ||
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index e87aa058f57a..d45e6bbf8493 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -381,8 +381,13 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) | |||
381 | excess_prefree_segs(sbi) || | 381 | excess_prefree_segs(sbi) || |
382 | excess_dirty_nats(sbi) || | 382 | excess_dirty_nats(sbi) || |
383 | (is_idle(sbi) && f2fs_time_over(sbi, CP_TIME))) { | 383 | (is_idle(sbi) && f2fs_time_over(sbi, CP_TIME))) { |
384 | if (test_opt(sbi, DATA_FLUSH)) | 384 | if (test_opt(sbi, DATA_FLUSH)) { |
385 | struct blk_plug plug; | ||
386 | |||
387 | blk_start_plug(&plug); | ||
385 | sync_dirty_inodes(sbi, FILE_INODE); | 388 | sync_dirty_inodes(sbi, FILE_INODE); |
389 | blk_finish_plug(&plug); | ||
390 | } | ||
386 | f2fs_sync_fs(sbi->sb, true); | 391 | f2fs_sync_fs(sbi->sb, true); |
387 | stat_inc_bg_cp_count(sbi->stat_info); | 392 | stat_inc_bg_cp_count(sbi->stat_info); |
388 | } | 393 | } |