* [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case
@ 2024-10-23 8:16 Chao Yu via Linux-f2fs-devel
2024-10-23 8:16 ` [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata Chao Yu via Linux-f2fs-devel
2024-10-25 3:44 ` [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Zorro Lang
0 siblings, 2 replies; 6+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2024-10-23 8:16 UTC (permalink / raw)
To: Zorro Lang; +Cc: Jaegeuk Kim, fstests, linux-f2fs-devel
This is a regression test to check whether f2fs handles dirty
data correctly when checkpoint is disabled, if lfs mode is on,
it will trigger OPU for all overwritten data, this will cost
free segments, so f2fs must account overwritten data as OPU
data when calculating free space, otherwise, it may run out
of free segments in f2fs' allocation function, resulting in
panic.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- add _fixed_by_kernel_commit()
- use _scratch_mkfs_sized() rather than formating size-specified
loop device
- code cleanup
tests/f2fs/006 | 38 ++++++++++++++++++++++++++++++++++++++
tests/f2fs/006.out | 6 ++++++
2 files changed, 44 insertions(+)
create mode 100755 tests/f2fs/006
create mode 100644 tests/f2fs/006.out
diff --git a/tests/f2fs/006 b/tests/f2fs/006
new file mode 100755
index 00000000..63d00018
--- /dev/null
+++ b/tests/f2fs/006
@@ -0,0 +1,38 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo. All Rights Reserved.
+#
+# FS QA Test No. f2fs/006
+#
+# This is a regression test to check whether f2fs handles dirty
+# data correctly when checkpoint is disabled, if lfs mode is on,
+# it will trigger OPU for all overwritten data, this will cost
+# free segments, so f2fs must account overwritten data as OPU
+# data when calculating free space, otherwise, it may run out
+# of free segments in f2fs' allocation function, resulting in
+# panic.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+ "f2fs: fix to account dirty data in __get_secs_required()"
+
+testfile=$SCRATCH_MNT/testfile
+
+_require_scratch
+_scratch_mkfs_sized $((1024*1024*100)) >> $seqres.full
+
+# use mode=lfs to let f2fs always triggers OPU
+_scratch_mount -o mode=lfs,checkpoint=disable:10%,noinline_dentry >> $seqres.full
+
+dd if=/dev/zero of=$testfile bs=1M count=50 2>/dev/null
+
+# it may run out of free space of f2fs and hang kernel
+dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync
+dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync
+
+_scratch_remount checkpoint=enable
+
+status=0
+exit
diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
new file mode 100644
index 00000000..0d7b3910
--- /dev/null
+++ b/tests/f2fs/006.out
@@ -0,0 +1,6 @@
+QA output created by 006
+50+0 records in
+50+0 records out
+dd: error writing '/mnt/scratch_f2fs/testfile': No space left on device
+3+0 records in
+2+0 records out
--
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata
2024-10-23 8:16 [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Chao Yu via Linux-f2fs-devel
@ 2024-10-23 8:16 ` Chao Yu via Linux-f2fs-devel
2024-10-25 3:58 ` Zorro Lang
2024-10-25 3:44 ` [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Zorro Lang
1 sibling, 1 reply; 6+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2024-10-23 8:16 UTC (permalink / raw)
To: Zorro Lang; +Cc: Jaegeuk Kim, Qi Han, fstests, linux-f2fs-devel
metadata of compressed inode should always be consistent after file
compression, reservation, releasement and decompression, let's add
a testcase to check it.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Qi Han <hanqi@vivo.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- add _fixed_by_kernel_commit()
- code cleanup
- add error handling for _scratch_mkfs()
tests/f2fs/007 | 116 +++++++++++++++++++++++++++++++++++++++++++++
tests/f2fs/007.out | 4 ++
2 files changed, 120 insertions(+)
create mode 100755 tests/f2fs/007
create mode 100644 tests/f2fs/007.out
diff --git a/tests/f2fs/007 b/tests/f2fs/007
new file mode 100755
index 00000000..8979c21c
--- /dev/null
+++ b/tests/f2fs/007
@@ -0,0 +1,116 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oppo. All Rights Reserved.
+#
+# FS QA Test No. f2fs/007
+#
+# This is a regression test to check whether compressed metadata
+# can become inconsistent after file compression, reservation
+# releasement, and decompression.
+#
+. ./common/preamble
+_begin_fstest auto quick rw compress
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+ "f2fs: compress: fix inconsistent update of i_blocks in release_compress_blocks and reserve_compress_blocks"
+
+testfile_prefix=$SCRATCH_MNT/testfile
+fio_config=$tmp.fio
+
+cat >$fio_config <<EOF
+[write_compressed_data_30]
+name=mytest
+ioengine=psync
+rw=write
+direct=0
+bs=1M
+filesize=1M
+numjobs=1
+filename=${testfile_prefix}30
+buffer_compress_percentage=30
+
+[write_compressed_data_60]
+name=mytest
+ioengine=psync
+rw=write
+direct=0
+bs=1M
+filesize=1M
+numjobs=1
+filename=${testfile_prefix}60
+buffer_compress_percentage=60
+
+[write_compressed_data_90]
+name=mytest
+ioengine=psync
+rw=write
+direct=0
+bs=1M
+filesize=1M
+numjobs=1
+filename=${testfile_prefix}90
+buffer_compress_percentage=90
+EOF
+
+_require_scratch
+_require_fio $fio_config
+_scratch_mkfs "-f -O extra_attr,compression" >> $seqres.full || _fail "mkfs failed"
+_scratch_mount "-o compress_mode=user,compress_extension=*" >> $seqres.full
+
+echo -e "Run fio to initialize file w/ specified compress ratio" >> $seqres.full
+cat $fio_config >> $seqres.full
+$FIO_PROG $fio_config >> $seqres.full
+_scratch_unmount
+
+# force to repaire if filesystem is corrupted
+export FSCK_OPTIONS="-f $FSCK_OPTIONS"
+
+for i in 30 60 90; do
+ testfile=$testfile_prefix$i
+
+ _scratch_mount "-o compress_mode=user" >> $seqres.full
+ $F2FS_IO_PROG compress $testfile >> $seqres.full
+ cblocks=`$F2FS_IO_PROG get_cblocks $testfile`
+ echo "compression ratio is: "$cblocks" / 256"
+
+ _scratch_unmount
+
+ # 1. check after compression
+ _check_scratch_fs
+ if [ $? -ne 0 ]; then
+ _fail "filesystem becomes corrupted after compress"
+ fi
+
+ _scratch_mount >> $seqres.full
+ $F2FS_IO_PROG release_cblocks $testfile >> $seqres.full
+ _scratch_unmount
+
+ # 2. check after releasement
+ _check_scratch_fs
+ if [ $? -ne 0 ]; then
+ _fail "filesystem becomes corrupted after release_cblocks"
+ fi
+
+ _scratch_mount >> $seqres.full
+ $F2FS_IO_PROG reserve_cblocks $testfile >> $seqres.full
+ _scratch_unmount
+
+ # 3. check after rservation
+ _check_scratch_fs
+ if [ $? -ne 0 ]; then
+ _fail "filesystem becomes corrupted after reserve_cblocks"
+ fi
+
+ _scratch_mount "-o compress_mode=user" >> $seqres.full
+ $F2FS_IO_PROG decompress $testfile >> $seqres.full
+ _scratch_unmount
+
+ # 4. check after decompression
+ _check_scratch_fs
+ if [ $? -ne 0 ]; then
+ _fail "filesystem becomes corrupted after decompress"
+ fi
+done
+
+status=0
+exit
diff --git a/tests/f2fs/007.out b/tests/f2fs/007.out
new file mode 100644
index 00000000..2ea71c18
--- /dev/null
+++ b/tests/f2fs/007.out
@@ -0,0 +1,4 @@
+QA output created by 007
+compression ratio is: 64 / 256
+compression ratio is: 128 / 256
+compression ratio is: 192 / 256
--
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata
2024-10-23 8:16 ` [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata Chao Yu via Linux-f2fs-devel
@ 2024-10-25 3:58 ` Zorro Lang
2024-10-28 9:56 ` Chao Yu via Linux-f2fs-devel
0 siblings, 1 reply; 6+ messages in thread
From: Zorro Lang @ 2024-10-25 3:58 UTC (permalink / raw)
To: Chao Yu; +Cc: Jaegeuk Kim, Qi Han, fstests, linux-f2fs-devel
On Wed, Oct 23, 2024 at 04:16:02PM +0800, Chao Yu wrote:
> metadata of compressed inode should always be consistent after file
> compression, reservation, releasement and decompression, let's add
> a testcase to check it.
>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> Cc: Qi Han <hanqi@vivo.com>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v2:
> - add _fixed_by_kernel_commit()
> - code cleanup
> - add error handling for _scratch_mkfs()
> tests/f2fs/007 | 116 +++++++++++++++++++++++++++++++++++++++++++++
> tests/f2fs/007.out | 4 ++
> 2 files changed, 120 insertions(+)
> create mode 100755 tests/f2fs/007
> create mode 100644 tests/f2fs/007.out
>
> diff --git a/tests/f2fs/007 b/tests/f2fs/007
> new file mode 100755
> index 00000000..8979c21c
> --- /dev/null
> +++ b/tests/f2fs/007
> @@ -0,0 +1,116 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Oppo. All Rights Reserved.
> +#
> +# FS QA Test No. f2fs/007
> +#
> +# This is a regression test to check whether compressed metadata
> +# can become inconsistent after file compression, reservation
> +# releasement, and decompression.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw compress
> +
> +_fixed_by_kernel_commit xxxxxxxxxxxx \
> + "f2fs: compress: fix inconsistent update of i_blocks in release_compress_blocks and reserve_compress_blocks"
> +
> +testfile_prefix=$SCRATCH_MNT/testfile
> +fio_config=$tmp.fio
> +
> +cat >$fio_config <<EOF
> +[write_compressed_data_30]
> +name=mytest
> +ioengine=psync
> +rw=write
> +direct=0
> +bs=1M
> +filesize=1M
> +numjobs=1
> +filename=${testfile_prefix}30
> +buffer_compress_percentage=30
> +
> +[write_compressed_data_60]
> +name=mytest
> +ioengine=psync
> +rw=write
> +direct=0
> +bs=1M
> +filesize=1M
> +numjobs=1
> +filename=${testfile_prefix}60
> +buffer_compress_percentage=60
> +
> +[write_compressed_data_90]
> +name=mytest
> +ioengine=psync
> +rw=write
> +direct=0
> +bs=1M
> +filesize=1M
> +numjobs=1
> +filename=${testfile_prefix}90
> +buffer_compress_percentage=90
> +EOF
> +
> +_require_scratch
Better to move _require_scratch before "testfile_prefix=$SCRATCH_MNT/testfile".
Due to we'd better to make sure there's $SCRATCH_MNT, before using it.
> +_require_fio $fio_config
> +_scratch_mkfs "-f -O extra_attr,compression" >> $seqres.full || _fail "mkfs failed"
> +_scratch_mount "-o compress_mode=user,compress_extension=*" >> $seqres.full
> +
> +echo -e "Run fio to initialize file w/ specified compress ratio" >> $seqres.full
> +cat $fio_config >> $seqres.full
> +$FIO_PROG $fio_config >> $seqres.full
> +_scratch_unmount
> +
> +# force to repaire if filesystem is corrupted
> +export FSCK_OPTIONS="-f $FSCK_OPTIONS"
> +
> +for i in 30 60 90; do
> + testfile=$testfile_prefix$i
> +
> + _scratch_mount "-o compress_mode=user" >> $seqres.full
> + $F2FS_IO_PROG compress $testfile >> $seqres.full
> + cblocks=`$F2FS_IO_PROG get_cblocks $testfile`
> + echo "compression ratio is: "$cblocks" / 256"
> +
> + _scratch_unmount
> +
> + # 1. check after compression
> + _check_scratch_fs
> + if [ $? -ne 0 ]; then
> + _fail "filesystem becomes corrupted after compress"
> + fi
> +
> + _scratch_mount >> $seqres.full
> + $F2FS_IO_PROG release_cblocks $testfile >> $seqres.full
> + _scratch_unmount
> +
> + # 2. check after releasement
> + _check_scratch_fs
> + if [ $? -ne 0 ]; then
> + _fail "filesystem becomes corrupted after release_cblocks"
The _fail is not necessary, due to _check_scratch_fs will do "exit 1"
if it find a corruption. If you need some message, maybe echo it before
calling _check_scratch_fs?
> + fi
> +
> + _scratch_mount >> $seqres.full
> + $F2FS_IO_PROG reserve_cblocks $testfile >> $seqres.full
> + _scratch_unmount
> +
> + # 3. check after rservation
> + _check_scratch_fs
> + if [ $? -ne 0 ]; then
> + _fail "filesystem becomes corrupted after reserve_cblocks"
> + fi
Same as above
> +
> + _scratch_mount "-o compress_mode=user" >> $seqres.full
> + $F2FS_IO_PROG decompress $testfile >> $seqres.full
> + _scratch_unmount
> +
> + # 4. check after decompression
> + _check_scratch_fs
> + if [ $? -ne 0 ]; then
> + _fail "filesystem becomes corrupted after decompress"
> + fi
Same as above.
Thanks,
Zorro
> +done
> +
> +status=0
> +exit
> diff --git a/tests/f2fs/007.out b/tests/f2fs/007.out
> new file mode 100644
> index 00000000..2ea71c18
> --- /dev/null
> +++ b/tests/f2fs/007.out
> @@ -0,0 +1,4 @@
> +QA output created by 007
> +compression ratio is: 64 / 256
> +compression ratio is: 128 / 256
> +compression ratio is: 192 / 256
> --
> 2.40.1
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata
2024-10-25 3:58 ` Zorro Lang
@ 2024-10-28 9:56 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2024-10-28 9:56 UTC (permalink / raw)
To: Zorro Lang; +Cc: Jaegeuk Kim, Qi Han, fstests, linux-f2fs-devel
On 2024/10/25 11:58, Zorro Lang wrote:
> On Wed, Oct 23, 2024 at 04:16:02PM +0800, Chao Yu wrote:
>> metadata of compressed inode should always be consistent after file
>> compression, reservation, releasement and decompression, let's add
>> a testcase to check it.
>>
>> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
>> Cc: Qi Han <hanqi@vivo.com>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> v2:
>> - add _fixed_by_kernel_commit()
>> - code cleanup
>> - add error handling for _scratch_mkfs()
>> tests/f2fs/007 | 116 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/f2fs/007.out | 4 ++
>> 2 files changed, 120 insertions(+)
>> create mode 100755 tests/f2fs/007
>> create mode 100644 tests/f2fs/007.out
>>
>> diff --git a/tests/f2fs/007 b/tests/f2fs/007
>> new file mode 100755
>> index 00000000..8979c21c
>> --- /dev/null
>> +++ b/tests/f2fs/007
>> @@ -0,0 +1,116 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Oppo. All Rights Reserved.
>> +#
>> +# FS QA Test No. f2fs/007
>> +#
>> +# This is a regression test to check whether compressed metadata
>> +# can become inconsistent after file compression, reservation
>> +# releasement, and decompression.
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick rw compress
>> +
>> +_fixed_by_kernel_commit xxxxxxxxxxxx \
>> + "f2fs: compress: fix inconsistent update of i_blocks in release_compress_blocks and reserve_compress_blocks"
>> +
>> +testfile_prefix=$SCRATCH_MNT/testfile
>> +fio_config=$tmp.fio
>> +
>> +cat >$fio_config <<EOF
>> +[write_compressed_data_30]
>> +name=mytest
>> +ioengine=psync
>> +rw=write
>> +direct=0
>> +bs=1M
>> +filesize=1M
>> +numjobs=1
>> +filename=${testfile_prefix}30
>> +buffer_compress_percentage=30
>> +
>> +[write_compressed_data_60]
>> +name=mytest
>> +ioengine=psync
>> +rw=write
>> +direct=0
>> +bs=1M
>> +filesize=1M
>> +numjobs=1
>> +filename=${testfile_prefix}60
>> +buffer_compress_percentage=60
>> +
>> +[write_compressed_data_90]
>> +name=mytest
>> +ioengine=psync
>> +rw=write
>> +direct=0
>> +bs=1M
>> +filesize=1M
>> +numjobs=1
>> +filename=${testfile_prefix}90
>> +buffer_compress_percentage=90
>> +EOF
>> +
>> +_require_scratch
>
> Better to move _require_scratch before "testfile_prefix=$SCRATCH_MNT/testfile".
> Due to we'd better to make sure there's $SCRATCH_MNT, before using it.
>
>> +_require_fio $fio_config
>> +_scratch_mkfs "-f -O extra_attr,compression" >> $seqres.full || _fail "mkfs failed"
>> +_scratch_mount "-o compress_mode=user,compress_extension=*" >> $seqres.full
>> +
>> +echo -e "Run fio to initialize file w/ specified compress ratio" >> $seqres.full
>> +cat $fio_config >> $seqres.full
>> +$FIO_PROG $fio_config >> $seqres.full
>> +_scratch_unmount
>> +
>> +# force to repaire if filesystem is corrupted
>> +export FSCK_OPTIONS="-f $FSCK_OPTIONS"
>> +
>> +for i in 30 60 90; do
>> + testfile=$testfile_prefix$i
>> +
>> + _scratch_mount "-o compress_mode=user" >> $seqres.full
>> + $F2FS_IO_PROG compress $testfile >> $seqres.full
>> + cblocks=`$F2FS_IO_PROG get_cblocks $testfile`
>> + echo "compression ratio is: "$cblocks" / 256"
>> +
>> + _scratch_unmount
>> +
>> + # 1. check after compression
>> + _check_scratch_fs
>> + if [ $? -ne 0 ]; then
>> + _fail "filesystem becomes corrupted after compress"
>> + fi
>> +
>> + _scratch_mount >> $seqres.full
>> + $F2FS_IO_PROG release_cblocks $testfile >> $seqres.full
>> + _scratch_unmount
>> +
>> + # 2. check after releasement
>> + _check_scratch_fs
>> + if [ $? -ne 0 ]; then
>> + _fail "filesystem becomes corrupted after release_cblocks"
>
> The _fail is not necessary, due to _check_scratch_fs will do "exit 1"
> if it find a corruption. If you need some message, maybe echo it before
> calling _check_scratch_fs?
>
>> + fi
>> +
>> + _scratch_mount >> $seqres.full
>> + $F2FS_IO_PROG reserve_cblocks $testfile >> $seqres.full
>> + _scratch_unmount
>> +
>> + # 3. check after rservation
>> + _check_scratch_fs
>> + if [ $? -ne 0 ]; then
>> + _fail "filesystem becomes corrupted after reserve_cblocks"
>> + fi
>
> Same as above
>
>> +
>> + _scratch_mount "-o compress_mode=user" >> $seqres.full
>> + $F2FS_IO_PROG decompress $testfile >> $seqres.full
>> + _scratch_unmount
>> +
>> + # 4. check after decompression
>> + _check_scratch_fs
>> + if [ $? -ne 0 ]; then
>> + _fail "filesystem becomes corrupted after decompress"
>> + fi
>
> Same as above.
Okay, let me update the patch.
Thanks,
>
> Thanks,
> Zorro
>
>> +done
>> +
>> +status=0
>> +exit
>> diff --git a/tests/f2fs/007.out b/tests/f2fs/007.out
>> new file mode 100644
>> index 00000000..2ea71c18
>> --- /dev/null
>> +++ b/tests/f2fs/007.out
>> @@ -0,0 +1,4 @@
>> +QA output created by 007
>> +compression ratio is: 64 / 256
>> +compression ratio is: 128 / 256
>> +compression ratio is: 192 / 256
>> --
>> 2.40.1
>>
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case
2024-10-23 8:16 [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Chao Yu via Linux-f2fs-devel
2024-10-23 8:16 ` [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata Chao Yu via Linux-f2fs-devel
@ 2024-10-25 3:44 ` Zorro Lang
2024-10-28 9:47 ` Chao Yu via Linux-f2fs-devel
1 sibling, 1 reply; 6+ messages in thread
From: Zorro Lang @ 2024-10-25 3:44 UTC (permalink / raw)
To: Chao Yu; +Cc: Jaegeuk Kim, fstests, linux-f2fs-devel
On Wed, Oct 23, 2024 at 04:16:01PM +0800, Chao Yu wrote:
> This is a regression test to check whether f2fs handles dirty
> data correctly when checkpoint is disabled, if lfs mode is on,
> it will trigger OPU for all overwritten data, this will cost
> free segments, so f2fs must account overwritten data as OPU
> data when calculating free space, otherwise, it may run out
> of free segments in f2fs' allocation function, resulting in
> panic.
>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v2:
> - add _fixed_by_kernel_commit()
> - use _scratch_mkfs_sized() rather than formating size-specified
> loop device
> - code cleanup
> tests/f2fs/006 | 38 ++++++++++++++++++++++++++++++++++++++
> tests/f2fs/006.out | 6 ++++++
> 2 files changed, 44 insertions(+)
> create mode 100755 tests/f2fs/006
> create mode 100644 tests/f2fs/006.out
>
> diff --git a/tests/f2fs/006 b/tests/f2fs/006
> new file mode 100755
> index 00000000..63d00018
> --- /dev/null
> +++ b/tests/f2fs/006
> @@ -0,0 +1,38 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Oppo. All Rights Reserved.
> +#
> +# FS QA Test No. f2fs/006
> +#
> +# This is a regression test to check whether f2fs handles dirty
> +# data correctly when checkpoint is disabled, if lfs mode is on,
> +# it will trigger OPU for all overwritten data, this will cost
> +# free segments, so f2fs must account overwritten data as OPU
> +# data when calculating free space, otherwise, it may run out
> +# of free segments in f2fs' allocation function, resulting in
> +# panic.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +_fixed_by_kernel_commit xxxxxxxxxxxx \
> + "f2fs: fix to account dirty data in __get_secs_required()"
> +
> +testfile=$SCRATCH_MNT/testfile
> +
> +_require_scratch
> +_scratch_mkfs_sized $((1024*1024*100)) >> $seqres.full
> +
> +# use mode=lfs to let f2fs always triggers OPU
> +_scratch_mount -o mode=lfs,checkpoint=disable:10%,noinline_dentry >> $seqres.full
> +
> +dd if=/dev/zero of=$testfile bs=1M count=50 2>/dev/null
> +
> +# it may run out of free space of f2fs and hang kernel
> +dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync
> +dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync
What kind of failure should be printed at here if test on unfixed kernel?
I got:
# diff -u /root/git/xfstests/tests/f2fs/006.out /root/git/xfstests/results//default/f2fs/006.out.bad|less
--- /root/git/xfstests/tests/f2fs/006.out 2024-10-25 11:33:54.693883281 +0800
+++ /root/git/xfstests/results//default/f2fs/006.out.bad 2024-10-25 11:34:55.907252401 +0800
@@ -1,6 +1,6 @@
QA output created by 006
50+0 records in
50+0 records out
-dd: error writing '/mnt/scratch_f2fs/testfile': No space left on device
-3+0 records in
-2+0 records out
+dd: fsync failed for '/mnt/scratch/testfile': Input/output error
+50+0 records in
+50+0 records out
Does that mean the bug is reproduced?
> +
> +_scratch_remount checkpoint=enable
> +
> +status=0
> +exit
> diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
> new file mode 100644
> index 00000000..0d7b3910
> --- /dev/null
> +++ b/tests/f2fs/006.out
> @@ -0,0 +1,6 @@
> +QA output created by 006
> +50+0 records in
> +50+0 records out
> +dd: error writing '/mnt/scratch_f2fs/testfile': No space left on device
The "/mnt/scratch_f2fs" should be SCRATCH_MNT, please use _filter_scratch()
by importing common/filter.
> +3+0 records in
> +2+0 records out
> --
> 2.40.1
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case
2024-10-25 3:44 ` [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Zorro Lang
@ 2024-10-28 9:47 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2024-10-28 9:47 UTC (permalink / raw)
To: Zorro Lang; +Cc: Jaegeuk Kim, fstests, linux-f2fs-devel
On 2024/10/25 11:44, Zorro Lang wrote:
> On Wed, Oct 23, 2024 at 04:16:01PM +0800, Chao Yu wrote:
>> This is a regression test to check whether f2fs handles dirty
>> data correctly when checkpoint is disabled, if lfs mode is on,
>> it will trigger OPU for all overwritten data, this will cost
>> free segments, so f2fs must account overwritten data as OPU
>> data when calculating free space, otherwise, it may run out
>> of free segments in f2fs' allocation function, resulting in
>> panic.
>>
>> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> v2:
>> - add _fixed_by_kernel_commit()
>> - use _scratch_mkfs_sized() rather than formating size-specified
>> loop device
>> - code cleanup
>> tests/f2fs/006 | 38 ++++++++++++++++++++++++++++++++++++++
>> tests/f2fs/006.out | 6 ++++++
>> 2 files changed, 44 insertions(+)
>> create mode 100755 tests/f2fs/006
>> create mode 100644 tests/f2fs/006.out
>>
>> diff --git a/tests/f2fs/006 b/tests/f2fs/006
>> new file mode 100755
>> index 00000000..63d00018
>> --- /dev/null
>> +++ b/tests/f2fs/006
>> @@ -0,0 +1,38 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Oppo. All Rights Reserved.
>> +#
>> +# FS QA Test No. f2fs/006
>> +#
>> +# This is a regression test to check whether f2fs handles dirty
>> +# data correctly when checkpoint is disabled, if lfs mode is on,
>> +# it will trigger OPU for all overwritten data, this will cost
>> +# free segments, so f2fs must account overwritten data as OPU
>> +# data when calculating free space, otherwise, it may run out
>> +# of free segments in f2fs' allocation function, resulting in
>> +# panic.
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick
>> +
>> +_fixed_by_kernel_commit xxxxxxxxxxxx \
>> + "f2fs: fix to account dirty data in __get_secs_required()"
>> +
>> +testfile=$SCRATCH_MNT/testfile
>> +
>> +_require_scratch
>> +_scratch_mkfs_sized $((1024*1024*100)) >> $seqres.full
>> +
>> +# use mode=lfs to let f2fs always triggers OPU
>> +_scratch_mount -o mode=lfs,checkpoint=disable:10%,noinline_dentry >> $seqres.full
>> +
>> +dd if=/dev/zero of=$testfile bs=1M count=50 2>/dev/null
>> +
>> +# it may run out of free space of f2fs and hang kernel
>> +dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync
>> +dd if=/dev/zero of=$testfile bs=1M count=50 conv=notrunc conv=fsync
>
> What kind of failure should be printed at here if test on unfixed kernel?
It will panic kernel w/o fix, can you please check dmesg?
> I got:
>
> # diff -u /root/git/xfstests/tests/f2fs/006.out /root/git/xfstests/results//default/f2fs/006.out.bad|less
> --- /root/git/xfstests/tests/f2fs/006.out 2024-10-25 11:33:54.693883281 +0800
> +++ /root/git/xfstests/results//default/f2fs/006.out.bad 2024-10-25 11:34:55.907252401 +0800
> @@ -1,6 +1,6 @@
> QA output created by 006
> 50+0 records in
> 50+0 records out
> -dd: error writing '/mnt/scratch_f2fs/testfile': No space left on device
> -3+0 records in
> -2+0 records out
> +dd: fsync failed for '/mnt/scratch/testfile': Input/output error
> +50+0 records in
> +50+0 records out
>
> Does that mean the bug is reproduced?
> >> +
>> +_scratch_remount checkpoint=enable
>> +
>> +status=0
>> +exit
>> diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
>> new file mode 100644
>> index 00000000..0d7b3910
>> --- /dev/null
>> +++ b/tests/f2fs/006.out
>> @@ -0,0 +1,6 @@
>> +QA output created by 006
>> +50+0 records in
>> +50+0 records out
>> +dd: error writing '/mnt/scratch_f2fs/testfile': No space left on device
>
> The "/mnt/scratch_f2fs" should be SCRATCH_MNT, please use _filter_scratch()
> by importing common/filter.
Correct, let me fix this.
Thanks,
>
>> +3+0 records in
>> +2+0 records out
>> --
>> 2.40.1
>>
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-28 9:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 8:16 [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Chao Yu via Linux-f2fs-devel
2024-10-23 8:16 ` [f2fs-dev] [PATCH v2 2/2] f2fs/007: add testcase to check consistency of compressed inode metadata Chao Yu via Linux-f2fs-devel
2024-10-25 3:58 ` Zorro Lang
2024-10-28 9:56 ` Chao Yu via Linux-f2fs-devel
2024-10-25 3:44 ` [f2fs-dev] [PATCH v2 1/2] f2fs/006: add testcase to check out-of-space case Zorro Lang
2024-10-28 9:47 ` Chao Yu via Linux-f2fs-devel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).