diff mbox series

generic: test i_blocks for large files

Message ID 20220812145050.43966-1-preichl@redhat.com (mailing list archive)
State New, archived
Headers show
Series generic: test i_blocks for large files | expand

Commit Message

Pavel Reichl Aug. 12, 2022, 2:50 p.m. UTC
This is a regression test for an incorrect
computation of i_blocks for files larger than
4 GiB. Bug was filed for exFAT.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
 tests/generic/693-inodes-for-large-files     | 49 ++++++++++++++++++++
 tests/generic/693-inodes-for-large-files.out |  1 +
 2 files changed, 50 insertions(+)
 create mode 100755 tests/generic/693-inodes-for-large-files
 create mode 100644 tests/generic/693-inodes-for-large-files.out

Comments

Zorro Lang Aug. 13, 2022, 5:44 a.m. UTC | #1
On Fri, Aug 12, 2022 at 04:50:50PM +0200, Pavel Reichl wrote:
> This is a regression test for an incorrect
> computation of i_blocks for files larger than
> 4 GiB. Bug was filed for exFAT.
> 
> Signed-off-by: Pavel Reichl <preichl@redhat.com>
> ---
>  tests/generic/693-inodes-for-large-files     | 49 ++++++++++++++++++++
>  tests/generic/693-inodes-for-large-files.out |  1 +
>  2 files changed, 50 insertions(+)
>  create mode 100755 tests/generic/693-inodes-for-large-files
>  create mode 100644 tests/generic/693-inodes-for-large-files.out
> 
> diff --git a/tests/generic/693-inodes-for-large-files b/tests/generic/693-inodes-for-large-files

I think case *number* is enough.

> new file mode 100755
> index 00000000..797d6a21
> --- /dev/null
> +++ b/tests/generic/693-inodes-for-large-files
> @@ -0,0 +1,49 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022  Red Hat Inc. All Rights Reserved.
> +#
> +# FS QA Test 693
> +#
> +# Verify that i_blocks for files larger than 4 GiB have correct
> +# values.
> +#
> +# This test verifies the problem fixed in kernel with commit
> +# 0c336d6e33f4 exfat: fix incorrect loading of i_blocks for large files
> +#
> +. ./common/preamble
> +_begin_fstest auto
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +	cd /
> +	rm -r -f $tmp.* $junk_dir
> +}
> +
> +_supported_fs generic
> +_require_test

If this test need 4G free space, I'm wondering if we need to make sure
there's enough space in $TEST_DIR, as we do in _require_scratch_size.

> +
> +junk_dir=$TEST_DIR/$seq
> +junk_file=$junk_dir/junk
> +mkdir -p $junk_dir
> +
> +$XFS_IO_PROG -f -c "truncate 4G" $junk_file

It helps to allocate 4g real space on exfat, due to exfat doesn't
support sparse file, but on other filesystems (e.g. xfs, ext4, btrfs)
it will get a file which i_blocks=0.

As a generic test case, if you really want to allocate 4g real space,
I think you have to real write data:

  $XFS_IO_PROG -f -c "pwrite -W 0 4g" $junk_file

If anyone knows any better idea, feel free to reply :)

> +
> +iblocks=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`

stat -c %b $junk_file ??

> +test -z "$iblocks" && echo 'Failed to parse the blocks'
> +
> +_test_cycle_mount
> +
> +iblocks_after_remount=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`

stat -c %b $junk_file ??

> +
> +test -z "$iblocks_after_remount" && echo 'Failed to parse the blocks'

When will we get an empty "$iblocks_after_remount" ?

> +
> +if [ "$iblocks" != "$iblocks_after_remount" ]; then
> +	echo "Number of blocks needs to be same: $iblocks, $iblocks_after_remount"
> +	status=1

If you "exit" directly, the status is 1 by default. But I think you don't need
to exit at here, due to above output will break golden image and fail this test.

> +	exit
> +fi
> +
> +status=0
> +
> +exit
> diff --git a/tests/generic/693-inodes-for-large-files.out b/tests/generic/693-inodes-for-large-files.out
> new file mode 100644
> index 00000000..f39aa77c
> --- /dev/null
> +++ b/tests/generic/693-inodes-for-large-files.out
> @@ -0,0 +1 @@
> +QA output created by 693-inodes-for-large-files

Silence is golden ??

> -- 
> 2.37.1
>
Pavel Reichl Aug. 13, 2022, 9 a.m. UTC | #2
On 8/13/22 07:44, Zorro Lang wrote:
> On Fri, Aug 12, 2022 at 04:50:50PM +0200, Pavel Reichl wrote:
>> This is a regression test for an incorrect
>> computation of i_blocks for files larger than
>> 4 GiB. Bug was filed for exFAT.
>>
>> Signed-off-by: Pavel Reichl <preichl@redhat.com>
>> ---
>>   tests/generic/693-inodes-for-large-files     | 49 ++++++++++++++++++++
>>   tests/generic/693-inodes-for-large-files.out |  1 +
>>   2 files changed, 50 insertions(+)
>>   create mode 100755 tests/generic/693-inodes-for-large-files
>>   create mode 100644 tests/generic/693-inodes-for-large-files.out
>>
>> diff --git a/tests/generic/693-inodes-for-large-files b/tests/generic/693-inodes-for-large-files
> I think case *number* is enough.
0K, the 'new' script asked, so I provided:-)
>
>> new file mode 100755
>> index 00000000..797d6a21
>> --- /dev/null
>> +++ b/tests/generic/693-inodes-for-large-files
>> @@ -0,0 +1,49 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2022  Red Hat Inc. All Rights Reserved.
>> +#
>> +# FS QA Test 693
>> +#
>> +# Verify that i_blocks for files larger than 4 GiB have correct
>> +# values.
>> +#
>> +# This test verifies the problem fixed in kernel with commit
>> +# 0c336d6e33f4 exfat: fix incorrect loading of i_blocks for large files
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto
>> +
>> +# Override the default cleanup function.
>> +_cleanup()
>> +{
>> +	cd /
>> +	rm -r -f $tmp.* $junk_dir
>> +}
>> +
>> +_supported_fs generic
>> +_require_test
> If this test need 4G free space, I'm wondering if we need to make sure
> there's enough space in $TEST_DIR, as we do in _require_scratch_size.
OK, I'll look into it.
>
>> +
>> +junk_dir=$TEST_DIR/$seq
>> +junk_file=$junk_dir/junk
>> +mkdir -p $junk_dir
>> +
>> +$XFS_IO_PROG -f -c "truncate 4G" $junk_file
> It helps to allocate 4g real space on exfat, due to exfat doesn't
> support sparse file, but on other filesystems (e.g. xfs, ext4, btrfs)
> it will get a file which i_blocks=0.
OK, I know that and I think it's fine - I just need a test for 
consistency after remounting.
>
> As a generic test case, if you really want to allocate 4g real space,
> I think you have to real write data:
>
>    $XFS_IO_PROG -f -c "pwrite -W 0 4g" $junk_file
>
> If anyone knows any better idea, feel free to reply :)
>
>> +
>> +iblocks=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`
> stat -c %b $junk_file ??
>
>> +test -z "$iblocks" && echo 'Failed to parse the blocks'
>> +
>> +_test_cycle_mount
>> +
>> +iblocks_after_remount=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`
> stat -c %b $junk_file ??
>
>> +
>> +test -z "$iblocks_after_remount" && echo 'Failed to parse the blocks'
> When will we get an empty "$iblocks_after_remount" ?
It is just a check that both xfs_io and grep worked as expected.
>
>> +
>> +if [ "$iblocks" != "$iblocks_after_remount" ]; then
>> +	echo "Number of blocks needs to be same: $iblocks, $iblocks_after_remount"
>> +	status=1
> If you "exit" directly, the status is 1 by default. But I think you don't need
> to exit at here, due to above output will break golden image and fail this test.
OK, I'll fix that. Thanks!
>
>> +	exit
>> +fi
>> +
>> +status=0
>> +
>> +exit
>> diff --git a/tests/generic/693-inodes-for-large-files.out b/tests/generic/693-inodes-for-large-files.out
>> new file mode 100644
>> index 00000000..f39aa77c
>> --- /dev/null
>> +++ b/tests/generic/693-inodes-for-large-files.out
>> @@ -0,0 +1 @@
>> +QA output created by 693-inodes-for-large-files
> Silence is golden ??

Well I don't echo that in the script, but if that's custom I'll do it.


Thanks for the comments!

>
>> -- 
>> 2.37.1
>>
Zorro Lang Aug. 14, 2022, 3:45 a.m. UTC | #3
On Sat, Aug 13, 2022 at 11:00:54AM +0200, Pavel Reichl wrote:
> 
> On 8/13/22 07:44, Zorro Lang wrote:
> > On Fri, Aug 12, 2022 at 04:50:50PM +0200, Pavel Reichl wrote:
> > > This is a regression test for an incorrect
> > > computation of i_blocks for files larger than
> > > 4 GiB. Bug was filed for exFAT.
> > > 
> > > Signed-off-by: Pavel Reichl <preichl@redhat.com>
> > > ---
> > >   tests/generic/693-inodes-for-large-files     | 49 ++++++++++++++++++++
> > >   tests/generic/693-inodes-for-large-files.out |  1 +
> > >   2 files changed, 50 insertions(+)
> > >   create mode 100755 tests/generic/693-inodes-for-large-files
> > >   create mode 100644 tests/generic/693-inodes-for-large-files.out
> > > 
> > > diff --git a/tests/generic/693-inodes-for-large-files b/tests/generic/693-inodes-for-large-files
> > I think case *number* is enough.
> 0K, the 'new' script asked, so I provided:-)
> > 
> > > new file mode 100755
> > > index 00000000..797d6a21
> > > --- /dev/null
> > > +++ b/tests/generic/693-inodes-for-large-files
> > > @@ -0,0 +1,49 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +# Copyright (c) 2022  Red Hat Inc. All Rights Reserved.
> > > +#
> > > +# FS QA Test 693
> > > +#
> > > +# Verify that i_blocks for files larger than 4 GiB have correct
> > > +# values.
> > > +#
> > > +# This test verifies the problem fixed in kernel with commit
> > > +# 0c336d6e33f4 exfat: fix incorrect loading of i_blocks for large files
> > > +#
> > > +. ./common/preamble
> > > +_begin_fstest auto
> > > +
> > > +# Override the default cleanup function.
> > > +_cleanup()
> > > +{
> > > +	cd /
> > > +	rm -r -f $tmp.* $junk_dir
> > > +}
> > > +
> > > +_supported_fs generic
> > > +_require_test
> > If this test need 4G free space, I'm wondering if we need to make sure
> > there's enough space in $TEST_DIR, as we do in _require_scratch_size.
> OK, I'll look into it.
> > 
> > > +
> > > +junk_dir=$TEST_DIR/$seq
> > > +junk_file=$junk_dir/junk
> > > +mkdir -p $junk_dir
> > > +
> > > +$XFS_IO_PROG -f -c "truncate 4G" $junk_file
> > It helps to allocate 4g real space on exfat, due to exfat doesn't
> > support sparse file, but on other filesystems (e.g. xfs, ext4, btrfs)
> > it will get a file which i_blocks=0.
> OK, I know that and I think it's fine - I just need a test for consistency
> after remounting.

So you don't need to allocate 4g real space? If so, that helps the test faster,
but that depends on what are you really trying to test. I just saw you try to
get 4g i_blocks, so thought you might need 4g real space.

Thanks,
Zorro

> > 
> > As a generic test case, if you really want to allocate 4g real space,
> > I think you have to real write data:
> > 
> >    $XFS_IO_PROG -f -c "pwrite -W 0 4g" $junk_file
> > 
> > If anyone knows any better idea, feel free to reply :)
> > 
> > > +
> > > +iblocks=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`
> > stat -c %b $junk_file ??
> > 
> > > +test -z "$iblocks" && echo 'Failed to parse the blocks'
> > > +
> > > +_test_cycle_mount
> > > +
> > > +iblocks_after_remount=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`
> > stat -c %b $junk_file ??
> > 
> > > +
> > > +test -z "$iblocks_after_remount" && echo 'Failed to parse the blocks'
> > When will we get an empty "$iblocks_after_remount" ?
> It is just a check that both xfs_io and grep worked as expected.
> > 
> > > +
> > > +if [ "$iblocks" != "$iblocks_after_remount" ]; then
> > > +	echo "Number of blocks needs to be same: $iblocks, $iblocks_after_remount"
> > > +	status=1
> > If you "exit" directly, the status is 1 by default. But I think you don't need
> > to exit at here, due to above output will break golden image and fail this test.
> OK, I'll fix that. Thanks!
> > 
> > > +	exit
> > > +fi
> > > +
> > > +status=0
> > > +
> > > +exit
> > > diff --git a/tests/generic/693-inodes-for-large-files.out b/tests/generic/693-inodes-for-large-files.out
> > > new file mode 100644
> > > index 00000000..f39aa77c
> > > --- /dev/null
> > > +++ b/tests/generic/693-inodes-for-large-files.out
> > > @@ -0,0 +1 @@
> > > +QA output created by 693-inodes-for-large-files
> > Silence is golden ??
> 
> Well I don't echo that in the script, but if that's custom I'll do it.
> 
> 
> Thanks for the comments!
> 
> > 
> > > -- 
> > > 2.37.1
> > > 
>
diff mbox series

Patch

diff --git a/tests/generic/693-inodes-for-large-files b/tests/generic/693-inodes-for-large-files
new file mode 100755
index 00000000..797d6a21
--- /dev/null
+++ b/tests/generic/693-inodes-for-large-files
@@ -0,0 +1,49 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022  Red Hat Inc. All Rights Reserved.
+#
+# FS QA Test 693
+#
+# Verify that i_blocks for files larger than 4 GiB have correct
+# values.
+#
+# This test verifies the problem fixed in kernel with commit
+# 0c336d6e33f4 exfat: fix incorrect loading of i_blocks for large files
+#
+. ./common/preamble
+_begin_fstest auto
+
+# Override the default cleanup function.
+_cleanup()
+{
+	cd /
+	rm -r -f $tmp.* $junk_dir
+}
+
+_supported_fs generic
+_require_test
+
+junk_dir=$TEST_DIR/$seq
+junk_file=$junk_dir/junk
+mkdir -p $junk_dir
+
+$XFS_IO_PROG -f -c "truncate 4G" $junk_file
+
+iblocks=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`
+test -z "$iblocks" && echo 'Failed to parse the blocks'
+
+_test_cycle_mount
+
+iblocks_after_remount=`$XFS_IO_PROG -c "stat" $junk_file | grep 'stat.blocks'`
+
+test -z "$iblocks_after_remount" && echo 'Failed to parse the blocks'
+
+if [ "$iblocks" != "$iblocks_after_remount" ]; then
+	echo "Number of blocks needs to be same: $iblocks, $iblocks_after_remount"
+	status=1
+	exit
+fi
+
+status=0
+
+exit
diff --git a/tests/generic/693-inodes-for-large-files.out b/tests/generic/693-inodes-for-large-files.out
new file mode 100644
index 00000000..f39aa77c
--- /dev/null
+++ b/tests/generic/693-inodes-for-large-files.out
@@ -0,0 +1 @@ 
+QA output created by 693-inodes-for-large-files