Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: add f2fs_init_write_merge_io function

Almost all other initialization of variables in f2fs_fill_super are
extraced to a single function. Also do it for write_io[], which can
make code more clean.

This patch just refactors the code, theres no functional change.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Reviewed-by: Chao Yu <chao@kernel.org>
[Jaegeuk Kim: clean up]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Yufen Yu and committed by
Jaegeuk Kim
908ea654 78901cfa

+32 -24
+28
fs/f2fs/data.c
··· 584 584 return false; 585 585 } 586 586 587 + int f2fs_init_write_merge_io(struct f2fs_sb_info *sbi) 588 + { 589 + int i; 590 + 591 + for (i = 0; i < NR_PAGE_TYPE; i++) { 592 + int n = (i == META) ? 1 : NR_TEMP_TYPE; 593 + int j; 594 + 595 + sbi->write_io[i] = f2fs_kmalloc(sbi, 596 + array_size(n, sizeof(struct f2fs_bio_info)), 597 + GFP_KERNEL); 598 + if (!sbi->write_io[i]) 599 + return -ENOMEM; 600 + 601 + for (j = HOT; j < n; j++) { 602 + init_f2fs_rwsem(&sbi->write_io[i][j].io_rwsem); 603 + sbi->write_io[i][j].sbi = sbi; 604 + sbi->write_io[i][j].bio = NULL; 605 + spin_lock_init(&sbi->write_io[i][j].io_lock); 606 + INIT_LIST_HEAD(&sbi->write_io[i][j].io_list); 607 + INIT_LIST_HEAD(&sbi->write_io[i][j].bio_list); 608 + init_f2fs_rwsem(&sbi->write_io[i][j].bio_list_lock); 609 + } 610 + } 611 + 612 + return 0; 613 + } 614 + 587 615 static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi, 588 616 enum page_type type, enum temp_type temp) 589 617 {
+1
fs/f2fs/f2fs.h
··· 3713 3713 void f2fs_destroy_bio_entry_cache(void); 3714 3714 void f2fs_submit_bio(struct f2fs_sb_info *sbi, 3715 3715 struct bio *bio, enum page_type type); 3716 + int f2fs_init_write_merge_io(struct f2fs_sb_info *sbi); 3716 3717 void f2fs_submit_merged_write(struct f2fs_sb_info *sbi, enum page_type type); 3717 3718 void f2fs_submit_merged_write_cond(struct f2fs_sb_info *sbi, 3718 3719 struct inode *inode, struct page *page,
+3 -24
fs/f2fs/super.c
··· 4091 4091 set_sbi_flag(sbi, SBI_POR_DOING); 4092 4092 spin_lock_init(&sbi->stat_lock); 4093 4093 4094 - for (i = 0; i < NR_PAGE_TYPE; i++) { 4095 - int n = (i == META) ? 1 : NR_TEMP_TYPE; 4096 - int j; 4097 - 4098 - sbi->write_io[i] = 4099 - f2fs_kmalloc(sbi, 4100 - array_size(n, 4101 - sizeof(struct f2fs_bio_info)), 4102 - GFP_KERNEL); 4103 - if (!sbi->write_io[i]) { 4104 - err = -ENOMEM; 4105 - goto free_bio_info; 4106 - } 4107 - 4108 - for (j = HOT; j < n; j++) { 4109 - init_f2fs_rwsem(&sbi->write_io[i][j].io_rwsem); 4110 - sbi->write_io[i][j].sbi = sbi; 4111 - sbi->write_io[i][j].bio = NULL; 4112 - spin_lock_init(&sbi->write_io[i][j].io_lock); 4113 - INIT_LIST_HEAD(&sbi->write_io[i][j].io_list); 4114 - INIT_LIST_HEAD(&sbi->write_io[i][j].bio_list); 4115 - init_f2fs_rwsem(&sbi->write_io[i][j].bio_list_lock); 4116 - } 4117 - } 4094 + err = f2fs_init_write_merge_io(sbi); 4095 + if (err) 4096 + goto free_bio_info; 4118 4097 4119 4098 init_f2fs_rwsem(&sbi->cp_rwsem); 4120 4099 init_f2fs_rwsem(&sbi->quota_sem);