generic: test i_blocks for truncated large files
PATCH 1/1 generic: test i_blocks for truncated large files
This is a regression test for an incorrect computation of i_blocks for truncated files larger than 4 GiB. Bug was filed for exFAT.
Test is based on reproducer provied by Christophe Vu-Brugier as part of kernel patch-fix submission.
--- tests/generic/698 | 47 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/698.out | 2 ++ 2 files changed, 49 insertions(+) create mode 100755 tests/generic/698 create mode 100644 tests/generic/698.out
tests/generic/698 new file +47 -0
@@ -0,0 +1,47 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 698 +# +# Verify that i_blocks for truncated files larger than 4 GiB have correct +# values. +# +# This test verifies the problem fixed in kernel with commit +# 92fba084b79e exfat: fix i_blocks for files truncated over 4 GiB +# +. ./common/preamble +_begin_fstest auto + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* $junk_dir +} + +_supported_fs generic +_require_test +_require_fs_space $TEST_DIR $((5 * 1024 * 1024)) #kB + +echo "Silence is golden" + +junk_dir=$TEST_DIR/$seq +junk_file=$junk_dir/junk +mkdir -p $junk_dir + +$XFS_IO_PROG -f -c "pwrite -W 0 5G" $junk_file > /dev/null + + +truncate -s $((4 * 1024 * 1024 * 1024)) $junk_file + +iblocks_after_truncate=`stat -c '%b' $junk_file` +iblocks_expected=$((4 * 1024 * 1024 * 2)) + +if [ "$iblocks_expected" != "$iblocks_after_truncate" ]; then + echo "Number of blocks needs to be same: $iblocks_expected, $iblocks_after_truncate" +fi + +status=0 + +exit
tests/generic/698.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 698 +Silence is golden
Signature · 1 line
2.37.3
Quoted 8 lines · Pavel Reichl
This is a regression test for an incorrect computation of
i_blocksfor truncated files larger than 4 GiB. Bug was filed for exFAT.Test is based on reproducer provied by Christophe Vu-Brugier as part of kernel patch-fix submission.
Signed-off-by Pavel Reichl <[email protected]>---
Hi Pavel,
Your patch has been merged as generic/694,
Quoted 27 lines
tests/generic/698 | 47 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/698.out | 2 ++ 2 files changed, 49 insertions(+) create mode 100755 tests/generic/698 create mode 100644 tests/generic/698.outtests/generic/698 new file +15
-0@@ -0,0 +1,47 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 698 +# +# Verify that i_blocks for truncated files larger than 4 GiB have correct +# values. +# +# This test verifies the problem fixed in kernel with commit +# 92fba084b79e exfat: fix i_blocks for files truncated over 4 GiB +# +. ./common/preamble +_begin_fstest auto +
tests/generic/698 line 25
Quoted 10 lines
tests/generic/698 new file +10
-0+# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* $junk_dir +} + +_supported_fs generic +_require_test +_require_fs_space $TEST_DIR $((5 * 1024 * 1024)) #kB
_fixed_by_kernel_commit 92fba084b79e \
exfat: fix i_blocks for files truncated over 4 GiB
tests/generic/698 line 35
Quoted 10 lines
tests/generic/698 new file +10
-0+ +echo "Silence is golden" + +junk_dir=$TEST_DIR/$seq +junk_file=$junk_dir/junk +mkdir -p $junk_dir + +$XFS_IO_PROG -f -c "pwrite -W 0 5G" $junk_file > /dev/null + +
Useless empty lines
tests/generic/698 line 39
Quoted 4 lines
tests/generic/698 new file +4
-0+truncate -s $((4 * 1024 * 1024 * 1024)) $junk_file + +iblocks_after_truncate=`stat -c '%b' $junk_file` +iblocks_expected=$((4 * 1024 * 1024 * 2))
I think you suspect that the stat -c %B xxx always be 512. I don't know if it's always 512 on Linux, or better to check %B size at first.
Thanks,
Zorro
Quoted 19 lines
tests/generic/698 new file +8
-0+ +if [ "$iblocks_expected" != "$iblocks_after_truncate" ]; then + echo "Number of blocks needs to be same: $iblocks_expected, $iblocks_after_truncate" +fi + +status=0 + +exittests/generic/698.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 698 +Silence is goldenSignature · 1 line
2.37.3
Quoted 7 lines · Zorro Lang
Quoted 6 lines · Pavel Reichl
This is a regression test for an incorrect computation of
i_blocksfor truncated files larger than 4 GiB. Bug was filed for exFAT.Test is based on reproducer provied by Christophe Vu-Brugier as part of kernel patch-fix submission.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Pavel Reichl <[email protected]>---
Hi Pavel,
Your patch has been merged as generic/694,
Oh, ignore this line ^^ :)
Quoted 85 lines
Quoted 28 lines
tests/generic/698 | 47 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/698.out | 2 ++ 2 files changed, 49 insertions(+) create mode 100755 tests/generic/698 create mode 100644 tests/generic/698.outtests/generic/698 new file +15
-0@@ -0,0 +1,47 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 698 +# +# Verify that i_blocks for truncated files larger than 4 GiB have correct +# values. +# +# This test verifies the problem fixed in kernel with commit +# 92fba084b79e exfat: fix i_blocks for files truncated over 4 GiB +# +. ./common/preamble +_begin_fstest auto +tests/generic/698 line 25
Quoted 10 lines
tests/generic/698 new file +10
-0+# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* $junk_dir +} + +_supported_fs generic +_require_test +_require_fs_space $TEST_DIR $((5 * 1024 * 1024)) #kB
_fixed_by_kernel_commit92fba084b79e\
exfat: fixi_blocksfor files truncated over 4 GiBtests/generic/698 line 35
Quoted 10 lines
tests/generic/698 new file +10
-0+ +echo "Silence is golden" + +junk_dir=$TEST_DIR/$seq +junk_file=$junk_dir/junk +mkdir -p $junk_dir + +$XFS_IO_PROG -f -c "pwrite -W 0 5G" $junk_file > /dev/null + +Useless empty lines
tests/generic/698 line 39
Quoted 4 lines
tests/generic/698 new file +4
-0+truncate -s $((4 * 1024 * 1024 * 1024)) $junk_file + +iblocks_after_truncate=`stat -c '%b' $junk_file` +iblocks_expected=$((4 * 1024 * 1024 * 2))I think you suspect that the
stat -c %B xxxalways be 512. I don't know if it's always 512 on Linux, or better to check %B size at first.Thanks,
ZorroQuoted 19 lines
tests/generic/698 new file +8
-0+ +if [ "$iblocks_expected" != "$iblocks_after_truncate" ]; then + echo "Number of blocks needs to be same: $iblocks_expected, $iblocks_after_truncate" +fi + +status=0 + +exittests/generic/698.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 698 +Silence is goldenSignature · 1 line
2.37.3
Quoted 49 lines · Pavel Reichl
This is a regression test for an incorrect computation of
i_blocksfor truncated files larger than 4 GiB. Bug was filed for exFAT.Test is based on reproducer provied by Christophe Vu-Brugier as part of kernel patch-fix submission.
Signed-off-by Pavel Reichl <[email protected]>--- tests/generic/698 | 47 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/698.out | 2 ++ 2 files changed, 49 insertions(+) create mode 100755 tests/generic/698 create mode 100644 tests/generic/698.outtests/generic/698 new file +29
-0@@ -0,0 +1,47 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 698 +# +# Verify that i_blocks for truncated files larger than 4 GiB have correct +# values. +# +# This test verifies the problem fixed in kernel with commit +# 92fba084b79e exfat: fix i_blocks for files truncated over 4 GiB +# +. ./common/preamble +_begin_fstest auto + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* $junk_dir +} + +_supported_fs generic +_require_test +_require_fs_space $TEST_DIR $((5 * 1024 * 1024)) #kB + +echo "Silence is golden" + +junk_dir=$TEST_DIR/$seq
tests/generic/698 line 39
Quoted 10 lines
tests/generic/698 new file +10
-0+junk_file=$junk_dir/junk +mkdir -p $junk_dir + +$XFS_IO_PROG -f -c "pwrite -W 0 5G" $junk_file > /dev/null + + +truncate -s $((4 * 1024 * 1024 * 1024)) $junk_file + +iblocks_after_truncate=`stat -c '%b' $junk_file` +iblocks_expected=$((4 * 1024 * 1024 * 2))
What happens if the filesystem allocates a substantial number of blocks to store block mappings (e.g. ext2)? Those are accounted to i_blocks.
tests/generic/698 line 42
Quoted 3 lines
tests/generic/698 new file +3
-0+ +if [ "$iblocks_expected" != "$iblocks_after_truncate" ]; then + echo "Number of blocks needs to be same: $iblocks_expected, $iblocks_after_truncate"
_within_range?
--D
Quoted 16 lines
tests/generic/698 new file +5
-0+fi + +status=0 + +exittests/generic/698.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 698 +Silence is goldenSignature · 1 line
2.37.3