f2fs: compress: fix overwrite may reduce compress ratio unproperly
PATCH 1/1 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
--- fs/f2fs/data.c | 3 +++ 1 file changed, 3 insertions(+)
fs/f2fs/data.c +3 -0
@@ -3025,6 +3025,9 @@ static int f2fs_write_cache_pages(struct address_space *mapping, 1)) { retry =1 ;break ; + } else if (ret2 && nr_pages - i < cc.cluster_size) { + retry =1 ; +break ; } }else { goto lock_page;
Signature · 8 lines
2.32.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
This patch may will make random write bench score reduce a lot. In my test, use fio test randwrite, config as below:
[global]
direct=1
numjobs=1time_based
runtime=60
ioengine=sync
iodepth=16
filename=fio-test
buffer_pattern=0x000000
[file5]
name=fio-rand-write
rw=randwrite
bs=4K
size=128M
w/o patch:
WRITE: bw=12.5MiB/s (13.1MB/s), 12.5MiB/s-12.5MiB/s (13.1MB/s-13.1MB/s), io=750MiB (787MB), run=60001-60001msec w/ patch:
WRITE: bw=5823KiB/s (5963kB/s), 5823KiB/s-5823KiB/s (5963kB/s-5963kB/s), io=341MiB (358MB), run=60001-60001msec
Quoted 51 lines
-----Original Message-----
From: 常凤楠
Sent: Monday, October 11, 2021 8:04 PM
To: [email protected]; [email protected]
Cc: [email protected]; 常凤楠 <[email protected]>
Subject: [PATCH] f2fs: compress: fix overwrite may reduce compress ratio unproperlywhen overwrite only first block of cluster, since cluster is not full, it will call
f2fs_write_raw_pageswhenf2fs_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_cachesroot#
f2fs_ioget_cblocks./fio-testroot# dd if=/dev/zero of=./fio-test bs=4K count=1 oflag=direct conv=notrunc
w/o patch:
root#f2fs_ioget_cblocks./fio-test
189w/ patch:
root#f2fs_ioget_cblocks./fio-test
192Signed-off-by Fengnan Chang <[email protected]>--- fs/f2fs/data.c | 3 +++ 1 file changed, 3 insertions(+)fs/f2fs/data.c index f4fd6c246c9a..267db5d3993e renamed from fs/f2fs/data.c +0
-0100644
fs/f2fs/data.c +3
-0@@ -3025,6 +3025,9 @@ static int f2fs_write_cache_pages(struct address_space *mapping, 1)) { retry =1 ;break ; + } else if (ret2 && nr_pages - i < cc.cluster_size) { + retry =1 ; +break ; } }else {
Quoted 3 lines
goto
lock_page;
--
2.32.0
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 33 lines · Fengnan Chang
when overwrite only first block of cluster, since cluster is not full, it will call
f2fs_write_raw_pageswhenf2fs_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_cachesroot#
f2fs_ioget_cblocks./fio-testroot# dd if=/dev/zero of=./fio-test bs=4K count=1 oflag=direct conv=notrunc
w/o patch:
root#f2fs_ioget_cblocks./fio-test
189w/ patch:
root#f2fs_ioget_cblocks./fio-test
192Signed-off-by Fengnan Chang <[email protected]>--- fs/f2fs/data.c | 3 +++ 1 file changed, 3 insertions(+)fs/f2fs/data.c +0
-0
fs/f2fs/data.c static int f2fs_write_cache_pages(struct address_space *mapping, · line 3028
Quoted 4 lines
fs/f2fs/data.c +1
-0@@ -3025,6 +3025,9 @@ static int f2fs_write_cache_pages(struct address_space *mapping, 1)) { retry =1 ;break ; + } else if (ret2 && nr_pages - i < cc.cluster_size) {
What about:
i = 0, nr_pages = 4,
pvec.pages[0].index = 0
pvec.pages[1].index = 4
pvec.pages[2].index = 5
pvec.pages[3].index = 6
Thanks,
fs/f2fs/data.c static int f2fs_write_cache_pages(struct address_space *mapping, · line 3033
Quoted 6 lines
fs/f2fs/data.c +2
-0+ retry =1 ; +break ; } }else { goto lock_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel