Skip to contentSkip to conversation

f2fs: introduce help function {create,destroy}_flush_cmd_control

PATCH In review Gu Zheng 1 participant 1 message Apr 11, 2014

Subsystems (2)
lore
Share & tools
lore

Gu Zheng

author
#0 lore raw

PATCH 7/7 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 |   55 ++++++++++++++++++++++++++++++++++++----------------
 fs/f2fs/super.c   |   29 ++-------------------------
 3 files changed, 43 insertions(+), 44 deletions(-)
fs/f2fs/f2fs.h +2 -1
index 780d7e2..863fde5 100644
@@ -1178,8 +1178,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 -17

80 lines not on this page · raw message

fs/f2fs/super.c +3 -26
index 4d562fb..b2b1863 100644
@@ -641,35 +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_i =
-					sbi->sm_info->cmd_control_info;
-
-		if (fcc_i) {
-			if (fcc_i->f2fs_issue_flush)
-				kthread_stop(fcc_i->f2fs_issue_flush);
-			fcc_i->issue_list = fcc_i->dispatch_list = NULL;
-			fcc_i->f2fs_issue_flush = 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_i =
-			kzalloc(sizeof(struct flush_cmd_control), GFP_KERNEL);
-
-		if (!fcc_i) {
-			err = -ENOMEM;
-			goto restore_gc;
-		}
-		spin_lock_init(&fcc_i->issue_lock);
-		init_waitqueue_head(&fcc_i->flush_wait_queue);
-		fcc_i->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
-				"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
-		if (IS_ERR(fcc_i->f2fs_issue_flush)) {
-			err = PTR_ERR(fcc_i->f2fs_issue_flush);
-			kfree(fcc_i);
+		err = create_flush_cmd_control(sbi);
+		if (err)
 			goto restore_gc;
-		}
-		sbi->sm_info->cmd_control_info = fcc_i;
 	}
 skip:
 	/* Update the POSIXACL Flag */
Signature · 10 lines
1.7.7



------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees