]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: disallow setting an extension to both cold and hot
authorYongpeng Yang <yangyongpeng@xiaomi.com>
Fri, 10 Apr 2026 15:05:37 +0000 (23:05 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 13 Apr 2026 22:52:57 +0000 (22:52 +0000)
An extension should not exist in both the cold and hot extension lists
simultaneously. When adding a hot extension, check whether it already
exists in the cold list, and vice versa. Reject the operation with
-EINVAL if a conflict is found.

Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/namei.c

index 6ef21deeef1c8a594efe156c3b339d78105dae9f..2e9c6be5651899f67feca28cb445c6ac87d655f0 100644 (file)
@@ -83,6 +83,21 @@ int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
        if (set) {
                if (total_count == F2FS_MAX_EXTENSION)
                        return -EINVAL;
+
+               if (hot) {
+                       start = 0;
+                       count = cold_count;
+               } else {
+                       start = cold_count;
+                       count = total_count;
+               }
+               for (i = start; i < count; i++) {
+                       if (!strcmp(name, extlist[i])) {
+                               f2fs_warn(sbi, "extension '%s' already exists in %s list",
+                                         name, hot ? "cold" : "hot");
+                               return -EINVAL;
+                       }
+               }
        } else {
                if (!hot && !cold_count)
                        return -EINVAL;