acrn-kernel/fs/f2fs
Sheng Yong cf3d57ad6f f2fs: add helper to check compression level
commit c571fbb5b5 upstream.

This patch adds a helper function to check if compression level is
valid.

Meanwhile, this patch fixes a reported issue [1]:

The issue is easily reproducible by:

1. dd if=/dev/zero of=test.img count=100 bs=1M
2. mkfs.f2fs -f -O compression,extra_attr ./test.img
3. mount -t f2fs -o compress_algorithm=zstd:6,compress_chksum,atgc,gc_merge,lazytime ./test.img /mnt

resulting in

[   60.789982] F2FS-fs (loop0): invalid zstd compress level: 6

A bugzilla report has been submitted in
https://bugzilla.kernel.org/show_bug.cgi?id=218471

[1] https://lore.kernel.org/lkml/ZcWDOjKEnPDxZ0Or@google.com/T/

The root cause is commit 00e120b5e4 ("f2fs: assign default compression
level") tries to check low boundary of compress level w/ zstd_min_clevel(),
however, since commit e0c1b49f5b ("lib: zstd: Upgrade to latest upstream
zstd version 1.4.10"), zstd supports negative compress level, it cast type
for negative value returned from zstd_min_clevel() to unsigned int in below
check condition, result in repored issue.

	if (level < zstd_min_clevel() || ...

This patch fixes this issue by casting type for level to int before
comparison.

Fixes: 00e120b5e4 ("f2fs: assign default compression level")
Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-16 19:06:31 +01:00
..
Kconfig
Makefile
acl.c
acl.h
checkpoint.c
compress.c f2fs: add helper to check compression level 2024-02-16 19:06:31 +01:00
data.c
debug.c
dir.c
extent_cache.c
f2fs.h f2fs: add helper to check compression level 2024-02-16 19:06:31 +01:00
file.c f2fs: fix to tag gcing flag on page during block migration 2024-02-05 20:12:56 +00:00
gc.c
gc.h
hash.c
inline.c
inode.c
iostat.c
iostat.h
namei.c
node.c f2fs: fix to check return value of f2fs_recover_xattr_data 2024-01-25 15:27:36 -08:00
node.h
recovery.c f2fs: fix write pointers on zoned device after roll forward 2024-02-05 20:12:55 +00:00
segment.c
segment.h
shrinker.c
super.c f2fs: add helper to check compression level 2024-02-16 19:06:31 +01:00
sysfs.c
verity.c
xattr.c f2fs: fix to check return value of f2fs_recover_xattr_data 2024-01-25 15:27:36 -08:00
xattr.h