Skip to contentSkip to conversation

f2fs: cleanup in f2fs_create_flush_cmd_control() and f2fs_start_gc_thread()

PATCH In review Yangtao Li 3 participants 5 messages Oct 27, 2022 F2FS file system

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/2 f2fs: cleanup in f2fs_create_flush_cmd_control() and f2fs_start_gc_thread()

Just cleanup for readable, no functional changes.

---
 fs/f2fs/gc.c      | 14 ++++++--------
 fs/f2fs/segment.c |  3 +--
 2 files changed, 7 insertions(+), 10 deletions(-)
fs/f2fs/gc.c +6 -8
index 674a905063db..85d16f4106de 100644
@@ -171,13 +171,10 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
 {
 	struct f2fs_gc_kthread *gc_th;
 	dev_t dev = sbi->sb->s_bdev->bd_dev;
-	int err = 0;
 
 	gc_th = f2fs_kmalloc(sbi, sizeof(struct f2fs_gc_kthread), GFP_KERNEL);
-	if (!gc_th) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!gc_th)
+		return -ENOMEM;
 
 	gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME;
 	gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME;
@@ -192,12 +189,13 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
 	sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi,
 			"f2fs_gc-%u:%u", MAJOR(dev), MINOR(dev));
 	if (IS_ERR(gc_th->f2fs_gc_task)) {
-		err = PTR_ERR(gc_th->f2fs_gc_task);
+		int err = PTR_ERR(gc_th->f2fs_gc_task);
 		kfree(gc_th);
 		sbi->gc_thread = NULL;
+		return err;
 	}
-out:
-	return err;
+
+	return 0;
 }
 
 void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi)
fs/f2fs/segment.c +1 -2
index 282616e6852a..becceee8e337 100644
@@ -638,7 +638,6 @@ int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi)
 {
 	dev_t dev = sbi->sb->s_bdev->bd_dev;
 	struct flush_cmd_control *fcc;
-	int err;
 
 	if (SM_I(sbi)->fcc_info) {
 		fcc = SM_I(sbi)->fcc_info;
@@ -662,7 +661,7 @@ int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi)
 	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);
+		int err = PTR_ERR(fcc->f2fs_issue_flush);
 		kfree(fcc);
 		SM_I(sbi)->fcc_info = NULL;
 		return err;
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 f2fs: fix return val in f2fs_start_ckpt_thread()

Return PTR_ERR(cprc->f2fs_issue_ckpt) instead of -ENOMEM;

---
 fs/f2fs/checkpoint.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +2 -1
index 2a5d9256a6f4..12fd12f2bb97 100644
@@ -1899,8 +1899,9 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi)
 	cprc->f2fs_issue_ckpt = kthread_run(issue_checkpoint_thread, sbi,
 			"f2fs_ckpt-%u:%u", MAJOR(dev), MINOR(dev));
 	if (IS_ERR(cprc->f2fs_issue_ckpt)) {
+		int err = PTR_ERR(cprc->f2fs_issue_ckpt);
 		cprc->f2fs_issue_ckpt = NULL;
-		return -ENOMEM;
+		return err;
 	}
 
 	set_task_ioprio(cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH 2/2] f2fs: fix return val in f2fs_start_ckpt_thread()

I integrated two patches into single one. I think we don't need Fixes.

Quoted 11 lines · Chao Yu
Quoted 2 lines · Yangtao Li

Return PTR_ERR(cprc->f2fs_issue_ckpt) instead of -ENOMEM;

Fixes line?

Quoted 1 line

Thanks,

maintainer
#4 lore raw
In reply to Yangtao Li
Quoted 1 line · Yangtao Li

Just cleanup for readable, no functional changes.

How about doing such cleanup in one patch?

Thanks,

Quoted 65 lines
---
  fs/f2fs/gc.c      | 14 ++++++--------
  fs/f2fs/segment.c |  3 +--
  2 files changed, 7 insertions(+), 10 deletions(-)
fs/f2fs/gc.c +6 -8
index 674a905063db..85d16f4106de 100644
@@ -171,13 +171,10 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
  {
  	struct f2fs_gc_kthread *gc_th;
  	dev_t dev = sbi->sb->s_bdev->bd_dev;
-	int err = 0;
 
  	gc_th = f2fs_kmalloc(sbi, sizeof(struct f2fs_gc_kthread), GFP_KERNEL);
-	if (!gc_th) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!gc_th)
+		return -ENOMEM;
 
  	gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME;
  	gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME;
@@ -192,12 +189,13 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
  	sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi,
  			"f2fs_gc-%u:%u", MAJOR(dev), MINOR(dev));
  	if (IS_ERR(gc_th->f2fs_gc_task)) {
-		err = PTR_ERR(gc_th->f2fs_gc_task);
+		int err = PTR_ERR(gc_th->f2fs_gc_task);
  		kfree(gc_th);
  		sbi->gc_thread = NULL;
+		return err;
  	}
-out:
-	return err;
+
+	return 0;
  }
 
  void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi)
fs/f2fs/segment.c +1 -2
index 282616e6852a..becceee8e337 100644
@@ -638,7 +638,6 @@ int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi)
  {
  	dev_t dev = sbi->sb->s_bdev->bd_dev;
  	struct flush_cmd_control *fcc;
-	int err;
 
  	if (SM_I(sbi)->fcc_info) {
  		fcc = SM_I(sbi)->fcc_info;
@@ -662,7 +661,7 @@ int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi)
  	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);
+		int err = PTR_ERR(fcc->f2fs_issue_flush);
  		kfree(fcc);
  		SM_I(sbi)->fcc_info = NULL;
  		return err;