f2fs: compress: fix overwrite may reduce compress ratio unproperly
authorFengnan Chang <changfengnan@vivo.com>
Sat, 23 Oct 2021 03:08:00 +0000 (20:08 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 26 Oct 2021 21:04:31 +0000 (14:04 -0700)
commitb368cc5e26341113453e7458f03cdfe0eeb84a40
treee4164fd66d5fd80b12188b193c662401b220f399
parent71f2c8206202584c644eef5ca7efe91fc8305c1f
f2fs: compress: fix overwrite may reduce compress ratio unproperly

when overwrite only first block of cluster, since cluster is not full, it
will call f2fs_write_raw_pages when f2fs_write_multi_pages, and cause the
whole cluster become uncompressed eventhough data can be compressed.
this may will make random write bench score reduce a lot.

root# dd if=/dev/zero of=./fio-test bs=1M count=1

root# sync

root# echo 3 > /proc/sys/vm/drop_caches

root# f2fs_io get_cblocks ./fio-test

root# dd if=/dev/zero of=./fio-test bs=4K count=1 oflag=direct conv=notrunc

w/o patch:
root# f2fs_io get_cblocks ./fio-test
189

w/ patch:
root# f2fs_io get_cblocks ./fio-test
192

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c
fs/f2fs/data.c
fs/f2fs/f2fs.h