linux-stable/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 f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem 2022-03-04 09:15:53 -08:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
acl.c f2fs: port to vfs{g,u}id_t and associated helpers 2022-10-04 13:31:43 -07:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
compress.c f2fs: add helper to check compression level 2024-02-16 19:06:31 +01:00
data.c f2fs: fix to wait on block writeback for post_read case 2024-01-25 15:27:34 -08:00
debug.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
dir.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
extent_cache.c f2fs: inode: fix to do sanity check on extent cache correctly 2023-05-17 11:53:59 +02:00
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 f2fs: optimize iteration over sparse directories 2023-10-06 14:56:44 +02:00
gc.h f2fs: Fix system crash due to lack of free space in LFS 2023-05-24 17:32:38 +01:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c f2fs: avoid false alarm of circular locking 2023-09-19 12:28:05 +02:00
inode.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
iostat.c f2fs: fix to avoid potential memory corruption in __update_iostat_latency() 2023-03-11 13:55:21 +01:00
iostat.h f2fs: iostat: support accounting compressed IO 2022-08-29 21:15:51 -07:00
namei.c f2fs: fix to avoid dirent corruption 2024-01-25 15:27:32 -08:00
node.c f2fs: fix to check return value of f2fs_recover_xattr_data 2024-01-25 15:27:36 -08:00
node.h f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
recovery.c f2fs: fix write pointers on zoned device after roll forward 2024-02-05 20:12:55 +00:00
segment.c f2fs: flush inode if atomic file is aborted 2023-09-19 12:28:05 +02:00
segment.h f2fs: Fix system crash due to lack of free space in LFS 2023-05-24 17:32:38 +01:00
shrinker.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
super.c f2fs: add helper to check compression level 2024-02-16 19:06:31 +01:00
sysfs.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 13:55:18 +01:00
xattr.c f2fs: fix to check return value of f2fs_recover_xattr_data 2024-01-25 15:27:36 -08:00
xattr.h