diff mbox series

[1/2] f2fs/006: add testcase to check out-of-space case

Message ID 20241015025106.3203676-1-chao@kernel.org (mailing list archive)
State New
Headers show
Series [1/2] f2fs/006: add testcase to check out-of-space case | expand

Commit Message

Chao Yu Oct. 15, 2024, 2:51 a.m. UTC
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>
---
 tests/f2fs/006     | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/f2fs/006.out |  6 ++++++
 2 files changed, 58 insertions(+)
 create mode 100755 tests/f2fs/006
 create mode 100644 tests/f2fs/006.out

Comments

Zorro Lang Oct. 23, 2024, 2:37 a.m. UTC | #1
On Tue, Oct 15, 2024 at 10:51:05AM +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>
> ---
>  tests/f2fs/006     | 52 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/f2fs/006.out |  6 ++++++
>  2 files changed, 58 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..b359ef8f
> --- /dev/null
> +++ b/tests/f2fs/006
> @@ -0,0 +1,52 @@
> +#! /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
> +
> +_cleanup()
> +{
> +	rm -f $img
> +	_scratch_unmount >> $seqres.full
> +	cd /
> +	rm -r -f $tmp.*
> +}
> +
> +_require_scratch
> +_scratch_mkfs >> $seqres.full
> +_scratch_mount >> $seqres.full
> +
> +img=$SCRATCH_MNT/f2fs.img
> +mnt=$SCRATCH_MNT/f2fs.mnt
> +testfile=$mnt/testfile
> +
> +mkdir $mnt
> +dd if=/dev/zero of=$img bs=1M count=100 2>/dev/null
> +$MKFS_F2FS_PROG -f $img >/dev/null 2>&1
> +sync
> +
> +# use mode=lfs to let f2fs always triggers OPU
> +mount -t $FSTYP -o loop,mode=lfs,checkpoint=disable:10%,noinline_dentry $img $mnt

Hi Chao,

Is the loop device necessary? What if use SCRATCH_DEV and SCRATCH_MNT directly?

Thanks,
Zorro

> +
> +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
> +
> +mount -o remount,checkpoint=enable $mnt
> +umount $mnt
> +
> +status=0
> +exit
> diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
> new file mode 100644
> index 00000000..a2c7ba48
> --- /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/f2fs.mnt/testfile': No space left on device
> +3+0 records in
> +2+0 records out
> -- 
> 2.40.1
>
Chao Yu Oct. 23, 2024, 2:53 a.m. UTC | #2
On 2024/10/23 10:37, Zorro Lang wrote:
> On Tue, Oct 15, 2024 at 10:51:05AM +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>
>> ---
>>   tests/f2fs/006     | 52 ++++++++++++++++++++++++++++++++++++++++++++++
>>   tests/f2fs/006.out |  6 ++++++
>>   2 files changed, 58 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..b359ef8f
>> --- /dev/null
>> +++ b/tests/f2fs/006
>> @@ -0,0 +1,52 @@
>> +#! /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
>> +
>> +_cleanup()
>> +{
>> +	rm -f $img
>> +	_scratch_unmount >> $seqres.full
>> +	cd /
>> +	rm -r -f $tmp.*
>> +}
>> +
>> +_require_scratch
>> +_scratch_mkfs >> $seqres.full
>> +_scratch_mount >> $seqres.full
>> +
>> +img=$SCRATCH_MNT/f2fs.img
>> +mnt=$SCRATCH_MNT/f2fs.mnt
>> +testfile=$mnt/testfile
>> +
>> +mkdir $mnt
>> +dd if=/dev/zero of=$img bs=1M count=100 2>/dev/null
>> +$MKFS_F2FS_PROG -f $img >/dev/null 2>&1
>> +sync
>> +
>> +# use mode=lfs to let f2fs always triggers OPU
>> +mount -t $FSTYP -o loop,mode=lfs,checkpoint=disable:10%,noinline_dentry $img $mnt
> 
> Hi Chao,
> 
> Is the loop device necessary? What if use SCRATCH_DEV and SCRATCH_MNT directly?

Hi Zorro,

It uses loop device to limit image size, so that we can speed
up padding steps of the test since it depends on ENOSPC state.

Or maybe we can mkfs.f2fs $SCRATCH_DEV w/ specified sector size?
Any suggestion?

Thanks,

> 
> Thanks,
> Zorro
> 
>> +
>> +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
>> +
>> +mount -o remount,checkpoint=enable $mnt
>> +umount $mnt
>> +
>> +status=0
>> +exit
>> diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
>> new file mode 100644
>> index 00000000..a2c7ba48
>> --- /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/f2fs.mnt/testfile': No space left on device
>> +3+0 records in
>> +2+0 records out
>> -- 
>> 2.40.1
>>
>
Zorro Lang Oct. 23, 2024, 3:17 a.m. UTC | #3
On Wed, Oct 23, 2024 at 10:53:09AM +0800, Chao Yu wrote:
> On 2024/10/23 10:37, Zorro Lang wrote:
> > On Tue, Oct 15, 2024 at 10:51:05AM +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>
> > > ---
> > >   tests/f2fs/006     | 52 ++++++++++++++++++++++++++++++++++++++++++++++
> > >   tests/f2fs/006.out |  6 ++++++
> > >   2 files changed, 58 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..b359ef8f
> > > --- /dev/null
> > > +++ b/tests/f2fs/006
> > > @@ -0,0 +1,52 @@
> > > +#! /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
> > > +
> > > +_cleanup()
> > > +{
> > > +	rm -f $img
> > > +	_scratch_unmount >> $seqres.full
> > > +	cd /
> > > +	rm -r -f $tmp.*
> > > +}
> > > +
> > > +_require_scratch
> > > +_scratch_mkfs >> $seqres.full
> > > +_scratch_mount >> $seqres.full
> > > +
> > > +img=$SCRATCH_MNT/f2fs.img
> > > +mnt=$SCRATCH_MNT/f2fs.mnt
> > > +testfile=$mnt/testfile
> > > +
> > > +mkdir $mnt
> > > +dd if=/dev/zero of=$img bs=1M count=100 2>/dev/null
> > > +$MKFS_F2FS_PROG -f $img >/dev/null 2>&1
> > > +sync
> > > +
> > > +# use mode=lfs to let f2fs always triggers OPU
> > > +mount -t $FSTYP -o loop,mode=lfs,checkpoint=disable:10%,noinline_dentry $img $mnt
> > 
> > Hi Chao,
> > 
> > Is the loop device necessary? What if use SCRATCH_DEV and SCRATCH_MNT directly?
> 
> Hi Zorro,
> 
> It uses loop device to limit image size, so that we can speed
> up padding steps of the test since it depends on ENOSPC state.
> 
> Or maybe we can mkfs.f2fs $SCRATCH_DEV w/ specified sector size?
> Any suggestion?

Can scratch_mkfs_sized() help? I saw it supports f2fs.

Thanks,
Zorro

> 
> Thanks,
> 
> > 
> > Thanks,
> > Zorro
> > 
> > > +
> > > +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
> > > +
> > > +mount -o remount,checkpoint=enable $mnt
> > > +umount $mnt
> > > +
> > > +status=0
> > > +exit
> > > diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
> > > new file mode 100644
> > > index 00000000..a2c7ba48
> > > --- /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/f2fs.mnt/testfile': No space left on device
> > > +3+0 records in
> > > +2+0 records out
> > > -- 
> > > 2.40.1
> > > 
> > 
>
Chao Yu Oct. 23, 2024, 3:27 a.m. UTC | #4
On 2024/10/23 11:17, Zorro Lang wrote:
> On Wed, Oct 23, 2024 at 10:53:09AM +0800, Chao Yu wrote:
>> On 2024/10/23 10:37, Zorro Lang wrote:
>>> On Tue, Oct 15, 2024 at 10:51:05AM +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>
>>>> ---
>>>>    tests/f2fs/006     | 52 ++++++++++++++++++++++++++++++++++++++++++++++
>>>>    tests/f2fs/006.out |  6 ++++++
>>>>    2 files changed, 58 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..b359ef8f
>>>> --- /dev/null
>>>> +++ b/tests/f2fs/006
>>>> @@ -0,0 +1,52 @@
>>>> +#! /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
>>>> +
>>>> +_cleanup()
>>>> +{
>>>> +	rm -f $img
>>>> +	_scratch_unmount >> $seqres.full
>>>> +	cd /
>>>> +	rm -r -f $tmp.*
>>>> +}
>>>> +
>>>> +_require_scratch
>>>> +_scratch_mkfs >> $seqres.full
>>>> +_scratch_mount >> $seqres.full
>>>> +
>>>> +img=$SCRATCH_MNT/f2fs.img
>>>> +mnt=$SCRATCH_MNT/f2fs.mnt
>>>> +testfile=$mnt/testfile
>>>> +
>>>> +mkdir $mnt
>>>> +dd if=/dev/zero of=$img bs=1M count=100 2>/dev/null
>>>> +$MKFS_F2FS_PROG -f $img >/dev/null 2>&1
>>>> +sync
>>>> +
>>>> +# use mode=lfs to let f2fs always triggers OPU
>>>> +mount -t $FSTYP -o loop,mode=lfs,checkpoint=disable:10%,noinline_dentry $img $mnt
>>>
>>> Hi Chao,
>>>
>>> Is the loop device necessary? What if use SCRATCH_DEV and SCRATCH_MNT directly?
>>
>> Hi Zorro,
>>
>> It uses loop device to limit image size, so that we can speed
>> up padding steps of the test since it depends on ENOSPC state.
>>
>> Or maybe we can mkfs.f2fs $SCRATCH_DEV w/ specified sector size?
>> Any suggestion?
> 
> Can scratch_mkfs_sized() help? I saw it supports f2fs.

Yes, let me update this patch, thanks.

Thanks,

> 
> Thanks,
> Zorro
> 
>>
>> Thanks,
>>
>>>
>>> Thanks,
>>> Zorro
>>>
>>>> +
>>>> +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
>>>> +
>>>> +mount -o remount,checkpoint=enable $mnt
>>>> +umount $mnt
>>>> +
>>>> +status=0
>>>> +exit
>>>> diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
>>>> new file mode 100644
>>>> index 00000000..a2c7ba48
>>>> --- /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/f2fs.mnt/testfile': No space left on device
>>>> +3+0 records in
>>>> +2+0 records out
>>>> -- 
>>>> 2.40.1
>>>>
>>>
>>
>
diff mbox series

Patch

diff --git a/tests/f2fs/006 b/tests/f2fs/006
new file mode 100755
index 00000000..b359ef8f
--- /dev/null
+++ b/tests/f2fs/006
@@ -0,0 +1,52 @@ 
+#! /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
+
+_cleanup()
+{
+	rm -f $img
+	_scratch_unmount >> $seqres.full
+	cd /
+	rm -r -f $tmp.*
+}
+
+_require_scratch
+_scratch_mkfs >> $seqres.full
+_scratch_mount >> $seqres.full
+
+img=$SCRATCH_MNT/f2fs.img
+mnt=$SCRATCH_MNT/f2fs.mnt
+testfile=$mnt/testfile
+
+mkdir $mnt
+dd if=/dev/zero of=$img bs=1M count=100 2>/dev/null
+$MKFS_F2FS_PROG -f $img >/dev/null 2>&1
+sync
+
+# use mode=lfs to let f2fs always triggers OPU
+mount -t $FSTYP -o loop,mode=lfs,checkpoint=disable:10%,noinline_dentry $img $mnt
+
+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
+
+mount -o remount,checkpoint=enable $mnt
+umount $mnt
+
+status=0
+exit
diff --git a/tests/f2fs/006.out b/tests/f2fs/006.out
new file mode 100644
index 00000000..a2c7ba48
--- /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/f2fs.mnt/testfile': No space left on device
+3+0 records in
+2+0 records out