Commit b8b902fd authored by Yongpeng Yang's avatar Yongpeng Yang Committed by Jaegeuk Kim
Browse files

f2fs: disallow setting an extension to both cold and hot



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: default avatarYongpeng Yang <yangyongpeng@xiaomi.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent ed78aeeb
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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;