Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0745a1a4 authored by Yangtao Li's avatar Yangtao Li Committed by Jaegeuk Kim
Browse files

f2fs: fix gc mode when gc_urgent_high_remaining is 1



Under the current logic, when gc_urgent_high_remaining is set to 1,
the mode will be switched to normal at the beginning, instead of
running in gc_urgent mode.

Let's switch the gc mode back to normal when the gc ends.

Fixes: 265576181b4a ("f2fs: remove gc_urgent_high_limited for cleanup")
Signed-off-by: default avatarYangtao Li <frank.li@vivo.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 4bca70ec
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -96,16 +96,6 @@ static int gc_thread_func(void *data)
		 * invalidated soon after by user update or deletion.
		 * So, I'd like to wait some time to collect dirty segments.
		 */
		if (sbi->gc_mode == GC_URGENT_HIGH) {
			spin_lock(&sbi->gc_urgent_high_lock);
			if (sbi->gc_urgent_high_remaining) {
				sbi->gc_urgent_high_remaining--;
				if (!sbi->gc_urgent_high_remaining)
					sbi->gc_mode = GC_NORMAL;
			}
			spin_unlock(&sbi->gc_urgent_high_lock);
		}

		if (sbi->gc_mode == GC_URGENT_HIGH ||
				sbi->gc_mode == GC_URGENT_MID) {
			wait_ms = gc_th->urgent_sleep_time;
@@ -162,6 +152,15 @@ static int gc_thread_func(void *data)
		/* balancing f2fs's metadata periodically */
		f2fs_balance_fs_bg(sbi, true);
next:
		if (sbi->gc_mode == GC_URGENT_HIGH) {
			spin_lock(&sbi->gc_urgent_high_lock);
			if (sbi->gc_urgent_high_remaining) {
				sbi->gc_urgent_high_remaining--;
				if (!sbi->gc_urgent_high_remaining)
					sbi->gc_mode = GC_NORMAL;
			}
			spin_unlock(&sbi->gc_urgent_high_lock);
		}
		sb_end_write(sbi->sb);

	} while (!kthread_should_stop());