summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-01-07 17:15:04 -0500
committerJaegeuk Kim <jaegeuk@kernel.org>2016-01-08 14:45:23 -0500
commit2c4db1a6f6b42e2a9fb611cbbeb71a3a9a358ee0 (patch)
treec61e7933ca50c9f69d54adc216e6384a186e3082
parent2a4b8e9fab9cea45d90179d9ee8e718c5ed26457 (diff)
f2fs: clean up f2fs_balance_fs
This patch adds one parameter to clean up all the callers of f2fs_balance_fs. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/data.c17
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/file.c17
-rw-r--r--fs/f2fs/inline.c3
-rw-r--r--fs/f2fs/inode.c2
-rw-r--r--fs/f2fs/namei.c22
-rw-r--r--fs/f2fs/segment.c6
-rw-r--r--fs/f2fs/xattr.c2
8 files changed, 33 insertions, 38 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 3cf86fda8138..6fae75ddae6d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -546,8 +546,7 @@ static int __allocate_data_blocks(struct inode *inode, loff_t offset,
546 f2fs_put_dnode(&dn); 546 f2fs_put_dnode(&dn);
547 f2fs_unlock_op(sbi); 547 f2fs_unlock_op(sbi);
548 548
549 if (dn.node_changed) 549 f2fs_balance_fs(sbi, dn.node_changed);
550 f2fs_balance_fs(sbi);
551 } 550 }
552 return err; 551 return err;
553 552
@@ -557,8 +556,7 @@ sync_out:
557 f2fs_put_dnode(&dn); 556 f2fs_put_dnode(&dn);
558out: 557out:
559 f2fs_unlock_op(sbi); 558 f2fs_unlock_op(sbi);
560 if (dn.node_changed) 559 f2fs_balance_fs(sbi, dn.node_changed);
561 f2fs_balance_fs(sbi);
562 return err; 560 return err;
563} 561}
564 562
@@ -657,8 +655,7 @@ get_next:
657 655
658 if (create) { 656 if (create) {
659 f2fs_unlock_op(sbi); 657 f2fs_unlock_op(sbi);
660 if (dn.node_changed) 658 f2fs_balance_fs(sbi, dn.node_changed);
661 f2fs_balance_fs(sbi);
662 f2fs_lock_op(sbi); 659 f2fs_lock_op(sbi);
663 } 660 }
664 661
@@ -718,8 +715,7 @@ put_out:
718unlock_out: 715unlock_out:
719 if (create) { 716 if (create) {
720 f2fs_unlock_op(sbi); 717 f2fs_unlock_op(sbi);
721 if (dn.node_changed) 718 f2fs_balance_fs(sbi, dn.node_changed);
722 f2fs_balance_fs(sbi);
723 } 719 }
724out: 720out:
725 trace_f2fs_map_blocks(inode, map, err); 721 trace_f2fs_map_blocks(inode, map, err);
@@ -1178,8 +1174,7 @@ out:
1178 if (err) 1174 if (err)
1179 ClearPageUptodate(page); 1175 ClearPageUptodate(page);
1180 unlock_page(page); 1176 unlock_page(page);
1181 if (need_balance_fs) 1177 f2fs_balance_fs(sbi, need_balance_fs);
1182 f2fs_balance_fs(sbi);
1183 if (wbc->for_reclaim || unlikely(f2fs_cp_error(sbi))) { 1178 if (wbc->for_reclaim || unlikely(f2fs_cp_error(sbi))) {
1184 f2fs_submit_merged_bio(sbi, DATA, WRITE); 1179 f2fs_submit_merged_bio(sbi, DATA, WRITE);
1185 remove_dirty_inode(inode); 1180 remove_dirty_inode(inode);
@@ -1506,7 +1501,7 @@ repeat:
1506 1501
1507 if (need_balance && has_not_enough_free_secs(sbi, 0)) { 1502 if (need_balance && has_not_enough_free_secs(sbi, 0)) {
1508 unlock_page(page); 1503 unlock_page(page);
1509 f2fs_balance_fs(sbi); 1504 f2fs_balance_fs(sbi, true);
1510 lock_page(page); 1505 lock_page(page);
1511 if (page->mapping != mapping) { 1506 if (page->mapping != mapping) {
1512 /* The page got truncated from under us */ 1507 /* The page got truncated from under us */
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 461b32923c14..412865482a0b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1780,7 +1780,7 @@ void destroy_node_manager_caches(void);
1780 */ 1780 */
1781void register_inmem_page(struct inode *, struct page *); 1781void register_inmem_page(struct inode *, struct page *);
1782int commit_inmem_pages(struct inode *, bool); 1782int commit_inmem_pages(struct inode *, bool);
1783void f2fs_balance_fs(struct f2fs_sb_info *); 1783void f2fs_balance_fs(struct f2fs_sb_info *, bool);
1784void f2fs_balance_fs_bg(struct f2fs_sb_info *); 1784void f2fs_balance_fs_bg(struct f2fs_sb_info *);
1785int f2fs_issue_flush(struct f2fs_sb_info *); 1785int f2fs_issue_flush(struct f2fs_sb_info *);
1786int create_flush_cmd_control(struct f2fs_sb_info *); 1786int create_flush_cmd_control(struct f2fs_sb_info *);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 69bc65fd862c..ff06827aa369 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -55,8 +55,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
55 f2fs_put_dnode(&dn); 55 f2fs_put_dnode(&dn);
56 f2fs_unlock_op(sbi); 56 f2fs_unlock_op(sbi);
57 57
58 if (dn.node_changed) 58 f2fs_balance_fs(sbi, dn.node_changed);
59 f2fs_balance_fs(sbi);
60 59
61 file_update_time(vma->vm_file); 60 file_update_time(vma->vm_file);
62 lock_page(page); 61 lock_page(page);
@@ -677,7 +676,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
677 err = f2fs_truncate(inode, true); 676 err = f2fs_truncate(inode, true);
678 if (err) 677 if (err)
679 return err; 678 return err;
680 f2fs_balance_fs(F2FS_I_SB(inode)); 679 f2fs_balance_fs(F2FS_I_SB(inode), true);
681 } else { 680 } else {
682 /* 681 /*
683 * do not trim all blocks after i_size if target size is 682 * do not trim all blocks after i_size if target size is
@@ -732,7 +731,7 @@ static int fill_zero(struct inode *inode, pgoff_t index,
732 if (!len) 731 if (!len)
733 return 0; 732 return 0;
734 733
735 f2fs_balance_fs(sbi); 734 f2fs_balance_fs(sbi, true);
736 735
737 f2fs_lock_op(sbi); 736 f2fs_lock_op(sbi);
738 page = get_new_data_page(inode, NULL, index, false); 737 page = get_new_data_page(inode, NULL, index, false);
@@ -818,7 +817,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
818 loff_t blk_start, blk_end; 817 loff_t blk_start, blk_end;
819 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 818 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
820 819
821 f2fs_balance_fs(sbi); 820 f2fs_balance_fs(sbi, true);
822 821
823 blk_start = (loff_t)pg_start << PAGE_CACHE_SHIFT; 822 blk_start = (loff_t)pg_start << PAGE_CACHE_SHIFT;
824 blk_end = (loff_t)pg_end << PAGE_CACHE_SHIFT; 823 blk_end = (loff_t)pg_end << PAGE_CACHE_SHIFT;
@@ -921,7 +920,7 @@ static int f2fs_do_collapse(struct inode *inode, pgoff_t start, pgoff_t end)
921 int ret = 0; 920 int ret = 0;
922 921
923 for (; end < nrpages; start++, end++) { 922 for (; end < nrpages; start++, end++) {
924 f2fs_balance_fs(sbi); 923 f2fs_balance_fs(sbi, true);
925 f2fs_lock_op(sbi); 924 f2fs_lock_op(sbi);
926 ret = __exchange_data_block(inode, end, start, true); 925 ret = __exchange_data_block(inode, end, start, true);
927 f2fs_unlock_op(sbi); 926 f2fs_unlock_op(sbi);
@@ -1103,7 +1102,7 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
1103 if (ret) 1102 if (ret)
1104 return ret; 1103 return ret;
1105 1104
1106 f2fs_balance_fs(sbi); 1105 f2fs_balance_fs(sbi, true);
1107 1106
1108 ret = truncate_blocks(inode, i_size_read(inode), true); 1107 ret = truncate_blocks(inode, i_size_read(inode), true);
1109 if (ret) 1108 if (ret)
@@ -1155,7 +1154,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
1155 if (ret) 1154 if (ret)
1156 return ret; 1155 return ret;
1157 1156
1158 f2fs_balance_fs(sbi); 1157 f2fs_balance_fs(sbi, true);
1159 1158
1160 pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT; 1159 pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
1161 pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT; 1160 pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;
@@ -1653,7 +1652,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
1653 pg_start = range->start >> PAGE_CACHE_SHIFT; 1652 pg_start = range->start >> PAGE_CACHE_SHIFT;
1654 pg_end = (range->start + range->len) >> PAGE_CACHE_SHIFT; 1653 pg_end = (range->start + range->len) >> PAGE_CACHE_SHIFT;
1655 1654
1656 f2fs_balance_fs(sbi); 1655 f2fs_balance_fs(sbi, true);
1657 1656
1658 mutex_lock(&inode->i_mutex); 1657 mutex_lock(&inode->i_mutex);
1659 1658
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 5ffbd169b719..c3f0b7d4cfca 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -200,8 +200,7 @@ out:
200 200
201 f2fs_put_page(page, 1); 201 f2fs_put_page(page, 1);
202 202
203 if (dn.node_changed) 203 f2fs_balance_fs(sbi, dn.node_changed);
204 f2fs_balance_fs(sbi);
205 204
206 return err; 205 return err;
207} 206}
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index cabc1ff108a1..2ac4b780e8b4 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -303,7 +303,7 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
303 * during the urgent cleaning time when runing out of free sections. 303 * during the urgent cleaning time when runing out of free sections.
304 */ 304 */
305 if (update_inode_page(inode)) 305 if (update_inode_page(inode))
306 f2fs_balance_fs(sbi); 306 f2fs_balance_fs(sbi, true);
307 return 0; 307 return 0;
308} 308}
309 309
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 0d61a6864ab1..53d6227f5581 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -140,7 +140,7 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
140 inode->i_mapping->a_ops = &f2fs_dblock_aops; 140 inode->i_mapping->a_ops = &f2fs_dblock_aops;
141 ino = inode->i_ino; 141 ino = inode->i_ino;
142 142
143 f2fs_balance_fs(sbi); 143 f2fs_balance_fs(sbi, true);
144 144
145 f2fs_lock_op(sbi); 145 f2fs_lock_op(sbi);
146 err = f2fs_add_link(dentry, inode); 146 err = f2fs_add_link(dentry, inode);
@@ -172,7 +172,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
172 !f2fs_is_child_context_consistent_with_parent(dir, inode)) 172 !f2fs_is_child_context_consistent_with_parent(dir, inode))
173 return -EPERM; 173 return -EPERM;
174 174
175 f2fs_balance_fs(sbi); 175 f2fs_balance_fs(sbi, true);
176 176
177 inode->i_ctime = CURRENT_TIME; 177 inode->i_ctime = CURRENT_TIME;
178 ihold(inode); 178 ihold(inode);
@@ -221,7 +221,7 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
221 return 0; 221 return 0;
222 } 222 }
223 223
224 f2fs_balance_fs(sbi); 224 f2fs_balance_fs(sbi, true);
225 225
226 f2fs_lock_op(sbi); 226 f2fs_lock_op(sbi);
227 227
@@ -302,7 +302,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
302 if (!de) 302 if (!de)
303 goto fail; 303 goto fail;
304 304
305 f2fs_balance_fs(sbi); 305 f2fs_balance_fs(sbi, true);
306 306
307 f2fs_lock_op(sbi); 307 f2fs_lock_op(sbi);
308 err = acquire_orphan_inode(sbi); 308 err = acquire_orphan_inode(sbi);
@@ -361,7 +361,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
361 inode->i_op = &f2fs_symlink_inode_operations; 361 inode->i_op = &f2fs_symlink_inode_operations;
362 inode->i_mapping->a_ops = &f2fs_dblock_aops; 362 inode->i_mapping->a_ops = &f2fs_dblock_aops;
363 363
364 f2fs_balance_fs(sbi); 364 f2fs_balance_fs(sbi, true);
365 365
366 f2fs_lock_op(sbi); 366 f2fs_lock_op(sbi);
367 err = f2fs_add_link(dentry, inode); 367 err = f2fs_add_link(dentry, inode);
@@ -452,7 +452,7 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
452 inode->i_mapping->a_ops = &f2fs_dblock_aops; 452 inode->i_mapping->a_ops = &f2fs_dblock_aops;
453 mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_HIGH_ZERO); 453 mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_HIGH_ZERO);
454 454
455 f2fs_balance_fs(sbi); 455 f2fs_balance_fs(sbi, true);
456 456
457 set_inode_flag(F2FS_I(inode), FI_INC_LINK); 457 set_inode_flag(F2FS_I(inode), FI_INC_LINK);
458 f2fs_lock_op(sbi); 458 f2fs_lock_op(sbi);
@@ -498,7 +498,7 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
498 init_special_inode(inode, inode->i_mode, rdev); 498 init_special_inode(inode, inode->i_mode, rdev);
499 inode->i_op = &f2fs_special_inode_operations; 499 inode->i_op = &f2fs_special_inode_operations;
500 500
501 f2fs_balance_fs(sbi); 501 f2fs_balance_fs(sbi, true);
502 502
503 f2fs_lock_op(sbi); 503 f2fs_lock_op(sbi);
504 err = f2fs_add_link(dentry, inode); 504 err = f2fs_add_link(dentry, inode);
@@ -539,7 +539,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
539 inode->i_mapping->a_ops = &f2fs_dblock_aops; 539 inode->i_mapping->a_ops = &f2fs_dblock_aops;
540 } 540 }
541 541
542 f2fs_balance_fs(sbi); 542 f2fs_balance_fs(sbi, true);
543 543
544 f2fs_lock_op(sbi); 544 f2fs_lock_op(sbi);
545 err = acquire_orphan_inode(sbi); 545 err = acquire_orphan_inode(sbi);
@@ -642,7 +642,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
642 if (!new_entry) 642 if (!new_entry)
643 goto out_whiteout; 643 goto out_whiteout;
644 644
645 f2fs_balance_fs(sbi); 645 f2fs_balance_fs(sbi, true);
646 646
647 f2fs_lock_op(sbi); 647 f2fs_lock_op(sbi);
648 648
@@ -675,7 +675,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
675 update_inode_page(old_inode); 675 update_inode_page(old_inode);
676 update_inode_page(new_inode); 676 update_inode_page(new_inode);
677 } else { 677 } else {
678 f2fs_balance_fs(sbi); 678 f2fs_balance_fs(sbi, true);
679 679
680 f2fs_lock_op(sbi); 680 f2fs_lock_op(sbi);
681 681
@@ -816,7 +816,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
816 goto out_new_dir; 816 goto out_new_dir;
817 } 817 }
818 818
819 f2fs_balance_fs(sbi); 819 f2fs_balance_fs(sbi, true);
820 820
821 f2fs_lock_op(sbi); 821 f2fs_lock_op(sbi);
822 822
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a3474bad5770..c7bbc915d962 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -213,7 +213,7 @@ int commit_inmem_pages(struct inode *inode, bool abort)
213 * inode becomes free by iget_locked in f2fs_iget. 213 * inode becomes free by iget_locked in f2fs_iget.
214 */ 214 */
215 if (!abort) { 215 if (!abort) {
216 f2fs_balance_fs(sbi); 216 f2fs_balance_fs(sbi, true);
217 f2fs_lock_op(sbi); 217 f2fs_lock_op(sbi);
218 } 218 }
219 219
@@ -262,8 +262,10 @@ int commit_inmem_pages(struct inode *inode, bool abort)
262 * This function balances dirty node and dentry pages. 262 * This function balances dirty node and dentry pages.
263 * In addition, it controls garbage collection. 263 * In addition, it controls garbage collection.
264 */ 264 */
265void f2fs_balance_fs(struct f2fs_sb_info *sbi) 265void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
266{ 266{
267 if (!need)
268 return;
267 /* 269 /*
268 * We should do GC or end up with checkpoint, if there are so many dirty 270 * We should do GC or end up with checkpoint, if there are so many dirty
269 * dir/node pages without enough free segments. 271 * dir/node pages without enough free segments.
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 862368a32e53..822a8af89c12 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -609,7 +609,7 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
609 if (ipage) 609 if (ipage)
610 return __f2fs_setxattr(inode, index, name, value, 610 return __f2fs_setxattr(inode, index, name, value,
611 size, ipage, flags); 611 size, ipage, flags);
612 f2fs_balance_fs(sbi); 612 f2fs_balance_fs(sbi, true);
613 613
614 f2fs_lock_op(sbi); 614 f2fs_lock_op(sbi);
615 /* protect xattr_ver */ 615 /* protect xattr_ver */