Skip to contentSkip to conversation

f2fs: fix wrong continue condition in GC

PATCH In review Jaegeuk Kim 2 participants 5 messages Aug 13, 2022 – Aug 20, 2022 F2FS file system

lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix wrong continue condition in GC

We should decrease the frozen counter.

Fixes 325163e9892b ("f2fs: add gc_urgent_high_remaining sysfs node")
---
 fs/f2fs/gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/gc.c +1 -1
index 6da21d405ce1..7e4b41240d59 100644
@@ -102,7 +102,7 @@ static int gc_thread_func(void *data)
 					sbi->gc_urgent_high_limited = false;
 					spin_unlock(&sbi->gc_urgent_high_lock);
 					sbi->gc_mode = GC_NORMAL;
-					continue;
+					goto next;
 				}
 				sbi->gc_urgent_high_remaining--;
 			}
Signature · 1 line
2.37.1.595.g718a3a8f04-goog
maintainer
#1 lore raw
Quoted 14 lines · Jaegeuk Kim

We should decrease the frozen counter.

Fixes 325163e9892b ("f2fs: add gc_urgent_high_remaining sysfs node")
---
  fs/f2fs/gc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/gc.c +0 -0
index 6da21d405ce1..7e4b41240d59 100644

fs/f2fs/gc.c static int gc_thread_func(void *data) · line 108

Quoted 8 lines
fs/f2fs/gc.c +1 -1
@@ -102,7 +102,7 @@ static int gc_thread_func(void *data)
  					sbi->gc_urgent_high_limited = false;
  					spin_unlock(&sbi->gc_urgent_high_lock);
  					sbi->gc_mode = GC_NORMAL;
-					continue;
+					goto next;
  				}
  				sbi->gc_urgent_high_remaining--;
  			}

Why not:

	if (!sbi->gc_urgent_high_remaining) {
		sbi->gc_urgent_high_limited = false;
		spin_unlock(&sbi->gc_urgent_high_lock);
		sbi->gc_mode = GC_NORMAL;
	} else {
		sbi->gc_urgent_high_remaining--;
	}

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#2 lore raw
Quoted 26 lines · Chao Yu
Quoted 14 lines · Jaegeuk Kim

We should decrease the frozen counter.

Fixes 325163e9892b ("f2fs: add gc_urgent_high_remaining sysfs node")
---
  fs/f2fs/gc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/gc.c +0 -0
index 6da21d405ce1..7e4b41240d59 100644

fs/f2fs/gc.c static int gc_thread_func(void *data) · line 108

Quoted 8 lines
fs/f2fs/gc.c +1 -1
@@ -102,7 +102,7 @@ static int gc_thread_func(void *data)
  					sbi->gc_urgent_high_limited = false;
  					spin_unlock(&sbi->gc_urgent_high_lock);
  					sbi->gc_mode = GC_NORMAL;
-					continue;
+					goto next;
  				}
  				sbi->gc_urgent_high_remaining--;
  			}

Why not:

Quoted 3 lines
	if (!sbi->gc_urgent_high_remaining) {
		sbi->gc_urgent_high_limited = false;
		spin_unlock(&sbi->gc_urgent_high_lock);

Should not call spin_unlock, if so. Anyway, let me send v2.

Quoted 6 lines
		sbi->gc_mode = GC_NORMAL;
	} else {
		sbi->gc_urgent_high_remaining--;
	}

Thanks,

author maintainer
#3 lore raw
In reply to Jaegeuk Kim

We should decrease the frozen counter.

Fixes 325163e9892b ("f2fs: add gc_urgent_high_remaining sysfs node")

---

Change log from v1:
- fix by refactoring the flow

 fs/f2fs/gc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
fs/f2fs/gc.c +4 -8
index 6da21d405ce1..45f90e3c46d4 100644
@@ -97,14 +97,10 @@ static int gc_thread_func(void *data)
 		 */
 		if (sbi->gc_mode == GC_URGENT_HIGH) {
 			spin_lock(&sbi->gc_urgent_high_lock);
-			if (sbi->gc_urgent_high_limited) {
-				if (!sbi->gc_urgent_high_remaining) {
-					sbi->gc_urgent_high_limited = false;
-					spin_unlock(&sbi->gc_urgent_high_lock);
-					sbi->gc_mode = GC_NORMAL;
-					continue;
-				}
-				sbi->gc_urgent_high_remaining--;
+			if (sbi->gc_urgent_high_limited &&
+					!sbi->gc_urgent_high_remaining--) {
+				sbi->gc_urgent_high_limited = false;
+				sbi->gc_mode = GC_NORMAL;
 			}
 			spin_unlock(&sbi->gc_urgent_high_lock);
 		}
Signature · 1 line
2.37.1.595.g718a3a8f04-goog