xfstests: ext4/023: reproduces incorrect right shift (insert range)
PATCH 1/1 xfstests: ext4/023: reproduces incorrect right shift (insert range)
Test tries to insert many blocks at the same offset to reproduce the following layout:
block #0 block #1
|ext0 ext1|ext2 ext3 ...|
^
insert of a new block
Because of an incorrect range first block is never reached, thus ext1 is untouched, resulting to a hole at a wrong offset:
What we got:
block #0 block #1
|ext0 ext1| ext2 ext3 ...|
^
hole at a wrong offset
What we expect:
block #0 block #1
|ext0 ext1|ext2 ext3 ...|
^
hole at a correct offset
--- tests/ext4/023 | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/023.out | 2 + tests/ext4/group | 1 + 3 files changed, 127 insertions(+) create mode 100755 tests/ext4/023 create mode 100644 tests/ext4/023.out
tests/ext4/023 new file +124 -0
@@ -0,0 +1,124 @@ +#! /bin/bash +# FS QA Test 023 +# +# Regression test which reproduces an incorrect right shift +# (insert range) for the first extent in a range. +# +# Test tries to insert many blocks at the same offset to reproduce +# the following layout: +# +# block #0 block #1 +# |ext0 ext1|ext2 ext3 ...| +# ^ +# insert of a new block +# +# Because of an incorrect range first block is never reached, +# thus ext1 is untouched, resulting to a hole at a wrong offset: +# +# What we got: +# +# block #0 block #1 +# |ext0 ext1| ext2 ext3 ...| +# ^ +# hole at a wrong offset +# +# What we expect: +# +# block #0 block #1 +# |ext0 ext1|ext2 ext3 ...| +# ^ +# hole at a correct offset +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Roman Penyaev. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs ext4 +_supported_os Linux +_require_test +_require_dumpe2fs + +pattern=$tmp +testfile=$TEST_DIR/023.file + +blksize=`$DUMPE2FS_PROG -h $TEST_DEV 2>/dev/null | grep "Block size" | \ + awk '{print $3}'` + +# Generate a block with a repeating number represented as 4 bytes decimal. +function generate_pattern() { + blkind=$1 + printf "%04d" $blkind | awk '{ while (c++ < '$(($blksize/4))') \ + printf "%s", $0 }' > $pattern +} + +echo -n > $testfile +$XFS_IO_PROG -c "falloc 0 $(($blksize * 2))" $testfile \ + >> $seqres.full 2>&1 + +# First block, has 0001 as a pattern +generate_pattern 1 +$XFS_IO_PROG -c "pwrite -i $pattern 0 $blksize" $testfile \ + >> $seqres.full 2>&1 + +# Second block, has 0002 as a pattern +generate_pattern 2 +$XFS_IO_PROG -c "pwrite -i $pattern $blksize $blksize" $testfile \ + >> $seqres.full 2>&1 + +# Insert 998 blocks after the first block +for (( block=3; block<=1000; block++ )); do + $XFS_IO_PROG -c "finsert $blksize $blksize" $testfile \ + >> $seqres.full 2>&1 + + generate_pattern $block + $XFS_IO_PROG -c "pwrite -i $pattern $blksize $blksize" $testfile \ + >> $seqres.full 2>&1 +done + +# Avoid offsets because block size can vary. +# Expected blocks content is the following: +# 0001 1000 0999 0998 ... 0002 +hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum + +# success, all done +status=0 +exit
tests/ext4/023.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 023 +d1c3b6f63c5420ca8248ca380a8c00cb -
tests/ext4/group +1 -0
@@ -25,6 +25,7 @@ 020 auto quick ioctl rw 021 auto quick 022 auto quick attr dangerous +023 auto quick 271 auto rw quick 301 aio auto ioctl rw stress 302 aio auto ioctl rw stress
Signature · 1 line
2.10.2
I forgot to specify '_require_xfs_io_command "finsert"', thus test fails on "ext3", "bigalloc" and "bigalloc_1k" configurations.
Will resend a patch.
--
Roman
Quoted 190 lines · Roman Pen
Test tries to insert many blocks at the same offset to reproduce the following layout:
block #0 block #1
|ext0 ext1|ext2 ext3 ...|
^
insert of a new blockBecause of an incorrect range first block is never reached, thus ext1 is untouched, resulting to a hole at a wrong offset:
What we got:
block #0 block #1
|ext0 ext1| ext2 ext3 ...|
^
hole at a wrong offsetWhat we expect:
block #0 block #1
|ext0 ext1|ext2 ext3 ...|
^
hole at a correct offsetSigned-off-by Roman Pen <[email protected]>Cc "Theodore Ts'o <[email protected]>"--- tests/ext4/023 | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/023.out | 2 + tests/ext4/group | 1 + 3 files changed, 127 insertions(+) create mode 100755 tests/ext4/023 create mode 100644 tests/ext4/023.outtests/ext4/023 new file +124
-0@@ -0,0 +1,124 @@ +#! /bin/bash +# FS QA Test 023 +# +# Regression test which reproduces an incorrect right shift +# (insert range) for the first extent in a range. +# +# Test tries to insert many blocks at the same offset to reproduce +# the following layout: +# +# block #0 block #1 +# |ext0 ext1|ext2 ext3 ...| +# ^ +# insert of a new block +# +# Because of an incorrect range first block is never reached, +# thus ext1 is untouched, resulting to a hole at a wrong offset: +# +# What we got: +# +# block #0 block #1 +# |ext0 ext1| ext2 ext3 ...| +# ^ +# hole at a wrong offset +# +# What we expect: +# +# block #0 block #1 +# |ext0 ext1|ext2 ext3 ...| +# ^ +# hole at a correct offset +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Roman Penyaev. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs ext4 +_supported_os Linux +_require_test +_require_dumpe2fs + +pattern=$tmp +testfile=$TEST_DIR/023.file + +blksize=`$DUMPE2FS_PROG -h $TEST_DEV 2>/dev/null | grep "Block size" | \ + awk '{print $3}'` + +# Generate a block with a repeating number represented as 4 bytes decimal. +function generate_pattern() { + blkind=$1 + printf "%04d" $blkind | awk '{ while (c++ < '$(($blksize/4))') \ + printf "%s", $0 }' > $pattern +} + +echo -n > $testfile +$XFS_IO_PROG -c "falloc 0 $(($blksize * 2))" $testfile \ + >> $seqres.full 2>&1 + +# First block, has 0001 as a pattern +generate_pattern 1 +$XFS_IO_PROG -c "pwrite -i $pattern 0 $blksize" $testfile \ + >> $seqres.full 2>&1 + +# Second block, has 0002 as a pattern +generate_pattern 2 +$XFS_IO_PROG -c "pwrite -i $pattern $blksize $blksize" $testfile \ + >> $seqres.full 2>&1 + +# Insert 998 blocks after the first block +for (( block=3; block<=1000; block++ )); do + $XFS_IO_PROG -c "finsert $blksize $blksize" $testfile \ + >> $seqres.full 2>&1 + + generate_pattern $block + $XFS_IO_PROG -c "pwrite -i $pattern $blksize $blksize" $testfile \ + >> $seqres.full 2>&1 +done + +# Avoid offsets because block size can vary. +# Expected blocks content is the following: +# 0001 1000 0999 0998 ... 0002 +hexdump -e '16/1 "%_p" "\n"' $testfile | md5sum + +# success, all done +status=0 +exittests/ext4/023.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 023 +d1c3b6f63c5420ca8248ca380a8c00cb -tests/ext4/group +1
-1@@ -25,6 +25,7 @@ 020 auto quick ioctl rw 021 auto quick 022 auto quick attr dangerous +023 auto quick 271 auto rw quick 301 aio auto ioctl rw stress 302 aio auto ioctl rw stress --2.10.2