f2fs: fix to check upper boundary for gc_valid_thresh_ratio
authorChao Yu <chao@kernel.org>
Fri, 27 Jun 2025 02:38:17 +0000 (10:38 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 30 Jun 2025 16:44:52 +0000 (16:44 +0000)
This patch adds missing upper boundary check while setting
gc_valid_thresh_ratio via sysfs.

Fixes: e791d00bd06c ("f2fs: add valid block ratio not to do excessive GC for one time GC")
Cc: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/sysfs.c

index 2b5c35ce7b8c7aab4198a06c5ae2663aeb117ce2..d74472d96026a70fb38cbf17d10fe61d6f8846da 100644 (file)
@@ -635,6 +635,13 @@ out:
                return count;
        }
 
+       if (!strcmp(a->attr.name, "gc_valid_thresh_ratio")) {
+               if (t > 100)
+                       return -EINVAL;
+               *ui = (unsigned int)t;
+               return count;
+       }
+
 #ifdef CONFIG_F2FS_IOSTAT
        if (!strcmp(a->attr.name, "iostat_enable")) {
                sbi->iostat_enable = !!t;