]> git.baikalelectronics.ru Git - kernel.git/commit
f2fs: Fix type of section block count variables
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 19 Aug 2020 01:34:48 +0000 (10:34 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 9 Sep 2020 03:31:33 +0000 (20:31 -0700)
commit1aa579de235d0a4c60fd8a0e9b2ed8c1f74c41bc
tree2e44c6a19c7af918f74464b51dd26830dd7c7955
parent32d75fa35a58a024b127186b3897c72f2fb020f4
f2fs: Fix type of section block count variables

Commit 4aa19f3a341d ("f2fs: get the right gc victim section when section
has several segments") added code to count blocks of each section using
variables with type 'unsigned short', which has 2 bytes size in many
systems. However, the counts can be larger than the 2 bytes range and
type conversion results in wrong values. Especially when the f2fs
sections have blocks as many as USHRT_MAX + 1, the count is handled as 0.
This triggers eternal loop in init_dirty_segmap() at mount system call.
Fix this by changing the type of the variables to block_t.

Fixes: 4aa19f3a341d ("f2fs: get the right gc victim section when section has several segments")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c