diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2014-04-27 02:21:33 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-05-06 21:21:57 -0400 |
commit | 2163d19815b3dfdb243cee2de2478ae7efce1942 (patch) | |
tree | 43272bf3bc723edc42205898e2c6955d8d87f343 | |
parent | a688b9d9e5cbec76edab74e724297b5488c07829 (diff) |
f2fs: introduce help function {create,destroy}_flush_cmd_control
Introduce help function {create,destroy}_flush_cmd_control to clean up
the create/destory flush merge operation.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/f2fs.h | 3 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 60 | ||||
-rw-r--r-- | fs/f2fs/super.c | 27 |
3 files changed, 43 insertions, 47 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index fa0ec8116f48..1ca958ab40e3 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -1184,8 +1184,9 @@ void destroy_node_manager_caches(void); | |||
1184 | */ | 1184 | */ |
1185 | void f2fs_balance_fs(struct f2fs_sb_info *); | 1185 | void f2fs_balance_fs(struct f2fs_sb_info *); |
1186 | void f2fs_balance_fs_bg(struct f2fs_sb_info *); | 1186 | void f2fs_balance_fs_bg(struct f2fs_sb_info *); |
1187 | int issue_flush_thread(void *); | ||
1188 | int f2fs_issue_flush(struct f2fs_sb_info *); | 1187 | int f2fs_issue_flush(struct f2fs_sb_info *); |
1188 | int create_flush_cmd_control(struct f2fs_sb_info *); | ||
1189 | void destroy_flush_cmd_control(struct f2fs_sb_info *); | ||
1189 | void invalidate_blocks(struct f2fs_sb_info *, block_t); | 1190 | void invalidate_blocks(struct f2fs_sb_info *, block_t); |
1190 | void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); | 1191 | void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); |
1191 | void clear_prefree_segments(struct f2fs_sb_info *); | 1192 | void clear_prefree_segments(struct f2fs_sb_info *); |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 9ac4f861c6f6..2ecbffb91f37 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -197,7 +197,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) | |||
197 | f2fs_sync_fs(sbi->sb, true); | 197 | f2fs_sync_fs(sbi->sb, true); |
198 | } | 198 | } |
199 | 199 | ||
200 | int issue_flush_thread(void *data) | 200 | static int issue_flush_thread(void *data) |
201 | { | 201 | { |
202 | struct f2fs_sb_info *sbi = data; | 202 | struct f2fs_sb_info *sbi = data; |
203 | struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; | 203 | struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; |
@@ -264,6 +264,40 @@ int f2fs_issue_flush(struct f2fs_sb_info *sbi) | |||
264 | return ret; | 264 | return ret; |
265 | } | 265 | } |
266 | 266 | ||
267 | int create_flush_cmd_control(struct f2fs_sb_info *sbi) | ||
268 | { | ||
269 | dev_t dev = sbi->sb->s_bdev->bd_dev; | ||
270 | struct flush_cmd_control *fcc; | ||
271 | int err = 0; | ||
272 | |||
273 | fcc = kzalloc(sizeof(struct flush_cmd_control), GFP_KERNEL); | ||
274 | if (!fcc) | ||
275 | return -ENOMEM; | ||
276 | spin_lock_init(&fcc->issue_lock); | ||
277 | init_waitqueue_head(&fcc->flush_wait_queue); | ||
278 | fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, | ||
279 | "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); | ||
280 | if (IS_ERR(fcc->f2fs_issue_flush)) { | ||
281 | err = PTR_ERR(fcc->f2fs_issue_flush); | ||
282 | kfree(fcc); | ||
283 | return err; | ||
284 | } | ||
285 | sbi->sm_info->cmd_control_info = fcc; | ||
286 | |||
287 | return err; | ||
288 | } | ||
289 | |||
290 | void destroy_flush_cmd_control(struct f2fs_sb_info *sbi) | ||
291 | { | ||
292 | struct flush_cmd_control *fcc = | ||
293 | sbi->sm_info->cmd_control_info; | ||
294 | |||
295 | if (fcc && fcc->f2fs_issue_flush) | ||
296 | kthread_stop(fcc->f2fs_issue_flush); | ||
297 | kfree(fcc); | ||
298 | sbi->sm_info->cmd_control_info = NULL; | ||
299 | } | ||
300 | |||
267 | static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, | 301 | static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, |
268 | enum dirty_type dirty_type) | 302 | enum dirty_type dirty_type) |
269 | { | 303 | { |
@@ -1845,7 +1879,6 @@ int build_segment_manager(struct f2fs_sb_info *sbi) | |||
1845 | { | 1879 | { |
1846 | struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); | 1880 | struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); |
1847 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); | 1881 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); |
1848 | dev_t dev = sbi->sb->s_bdev->bd_dev; | ||
1849 | struct f2fs_sm_info *sm_info; | 1882 | struct f2fs_sm_info *sm_info; |
1850 | int err; | 1883 | int err; |
1851 | 1884 | ||
@@ -1874,22 +1907,9 @@ int build_segment_manager(struct f2fs_sb_info *sbi) | |||
1874 | sm_info->max_discards = 0; | 1907 | sm_info->max_discards = 0; |
1875 | 1908 | ||
1876 | if (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) { | 1909 | if (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) { |
1877 | struct flush_cmd_control *fcc = | 1910 | err = create_flush_cmd_control(sbi); |
1878 | kzalloc(sizeof(struct flush_cmd_control), GFP_KERNEL); | 1911 | if (err) |
1879 | |||
1880 | if (!fcc) | ||
1881 | return -ENOMEM; | ||
1882 | spin_lock_init(&fcc->issue_lock); | ||
1883 | init_waitqueue_head(&fcc->flush_wait_queue); | ||
1884 | |||
1885 | fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, | ||
1886 | "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); | ||
1887 | if (IS_ERR(fcc->f2fs_issue_flush)) { | ||
1888 | err = PTR_ERR(fcc->f2fs_issue_flush); | ||
1889 | kfree(fcc); | ||
1890 | return err; | 1912 | return err; |
1891 | } | ||
1892 | sm_info->cmd_control_info = fcc; | ||
1893 | } | 1913 | } |
1894 | 1914 | ||
1895 | err = build_sit_info(sbi); | 1915 | err = build_sit_info(sbi); |
@@ -1998,14 +2018,10 @@ static void destroy_sit_info(struct f2fs_sb_info *sbi) | |||
1998 | void destroy_segment_manager(struct f2fs_sb_info *sbi) | 2018 | void destroy_segment_manager(struct f2fs_sb_info *sbi) |
1999 | { | 2019 | { |
2000 | struct f2fs_sm_info *sm_info = SM_I(sbi); | 2020 | struct f2fs_sm_info *sm_info = SM_I(sbi); |
2001 | struct flush_cmd_control *fcc; | ||
2002 | 2021 | ||
2003 | if (!sm_info) | 2022 | if (!sm_info) |
2004 | return; | 2023 | return; |
2005 | fcc = sm_info->cmd_control_info; | 2024 | destroy_flush_cmd_control(sbi); |
2006 | if (fcc && fcc->f2fs_issue_flush) | ||
2007 | kthread_stop(fcc->f2fs_issue_flush); | ||
2008 | kfree(fcc); | ||
2009 | destroy_dirty_segmap(sbi); | 2025 | destroy_dirty_segmap(sbi); |
2010 | destroy_curseg(sbi); | 2026 | destroy_curseg(sbi); |
2011 | destroy_free_segmap(sbi); | 2027 | destroy_free_segmap(sbi); |
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index a7ed92e2948a..b2b18637cb9e 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -641,33 +641,12 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) | |||
641 | * or if flush_merge is not passed in mount option. | 641 | * or if flush_merge is not passed in mount option. |
642 | */ | 642 | */ |
643 | if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) { | 643 | if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) { |
644 | struct flush_cmd_control *fcc = | 644 | destroy_flush_cmd_control(sbi); |
645 | sbi->sm_info->cmd_control_info; | ||
646 | |||
647 | if (fcc && fcc->f2fs_issue_flush) | ||
648 | kthread_stop(fcc->f2fs_issue_flush); | ||
649 | kfree(fcc); | ||
650 | sbi->sm_info->cmd_control_info = NULL; | ||
651 | } else if (test_opt(sbi, FLUSH_MERGE) && | 645 | } else if (test_opt(sbi, FLUSH_MERGE) && |
652 | !sbi->sm_info->cmd_control_info) { | 646 | !sbi->sm_info->cmd_control_info) { |
653 | dev_t dev = sbi->sb->s_bdev->bd_dev; | 647 | err = create_flush_cmd_control(sbi); |
654 | struct flush_cmd_control *fcc = | 648 | if (err) |
655 | kzalloc(sizeof(struct flush_cmd_control), GFP_KERNEL); | ||
656 | |||
657 | if (!fcc) { | ||
658 | err = -ENOMEM; | ||
659 | goto restore_gc; | ||
660 | } | ||
661 | spin_lock_init(&fcc->issue_lock); | ||
662 | init_waitqueue_head(&fcc->flush_wait_queue); | ||
663 | fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, | ||
664 | "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); | ||
665 | if (IS_ERR(fcc->f2fs_issue_flush)) { | ||
666 | err = PTR_ERR(fcc->f2fs_issue_flush); | ||
667 | kfree(fcc); | ||
668 | goto restore_gc; | 649 | goto restore_gc; |
669 | } | ||
670 | sbi->sm_info->cmd_control_info = fcc; | ||
671 | } | 650 | } |
672 | skip: | 651 | skip: |
673 | /* Update the POSIXACL Flag */ | 652 | /* Update the POSIXACL Flag */ |