Skip to contentSkip to conversation

f2fs: introduce help function {create,destroy}_flush_cmd_control

PATCH New Gu Zheng 1 participant 1 message Apr 27, 2014

Subsystems (2)
lore
Share & tools
lore

Gu Zheng

author
#0 lore raw

PATCH 2/2 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.

---
 fs/f2fs/f2fs.h    |    3 +-
 fs/f2fs/segment.c |   60 +++++++++++++++++++++++++++++++++-------------------
 fs/f2fs/super.c   |   27 ++---------------------
 3 files changed, 43 insertions(+), 47 deletions(-)
fs/f2fs/f2fs.h +2 -1
index fa0ec81..1ca958a 100644
@@ -1184,8 +1184,9 @@ void destroy_node_manager_caches(void);
  */
 void f2fs_balance_fs(struct f2fs_sb_info *);
 void f2fs_balance_fs_bg(struct f2fs_sb_info *);
-int issue_flush_thread(void *);
 int f2fs_issue_flush(struct f2fs_sb_info *);
+int create_flush_cmd_control(struct f2fs_sb_info *);
+void destroy_flush_cmd_control(struct f2fs_sb_info *);
 void invalidate_blocks(struct f2fs_sb_info *, block_t);
 void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
 void clear_prefree_segments(struct f2fs_sb_info *);
fs/f2fs/segment.c +38 -22

94 lines not on this page · raw message

fs/f2fs/super.c +3 -24
index 98832ef..b2b1863 100644
@@ -641,33 +641,12 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 	 * or if flush_merge is not passed in mount option.
 	 */
 	if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) {
-		struct flush_cmd_control *fcc =
-					sbi->sm_info->cmd_control_info;
-
-		if (fcc && fcc->f2fs_issue_flush)
-			kthread_stop(fcc->f2fs_issue_flush);
-		kfree(fcc);
-		sbi->sm_info->cmd_control_info = NULL;
+		destroy_flush_cmd_control(sbi);
 	} else if (test_opt(sbi, FLUSH_MERGE) &&
 					!sbi->sm_info->cmd_control_info) {
-		dev_t dev = sbi->sb->s_bdev->bd_dev;
-		struct flush_cmd_control *fcc =
-			kzalloc(sizeof(struct flush_cmd_control), GFP_KERNEL);
-
-		if (!fcc) {
-			err = -ENOMEM;
-			goto restore_gc;
-		}
-		spin_lock_init(&fcc->issue_lock);
-		init_waitqueue_head(&fcc->flush_wait_queue);
-		fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
-				"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
-		if (IS_ERR(fcc->f2fs_issue_flush)) {
-			err = PTR_ERR(fcc->f2fs_issue_flush);
-			kfree(fcc);
+		err = create_flush_cmd_control(sbi);
+		if (err)
 			goto restore_gc;
-		}
-		sbi->sm_info->cmd_control_info = fcc;
 	}
 skip:
 	/* Update the POSIXACL Flag */
Signature · 9 lines
1.7.7


------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform