Fstests: ext4: test block reservation leak with bigalloc
PATCH 1/1 Fstests: ext4: test block reservation leak with bigalloc
This is to reproduce a leak case of block reservation when bigalloc and delalloc are enabled.
--- tests/ext4/033 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/033.out | 14 +++++++++ tests/ext4/group | 1 + 3 files changed, 104 insertions(+) create mode 100755 tests/ext4/033 create mode 100644 tests/ext4/033.out
tests/ext4/033 new file +89 -0
@@ -0,0 +1,89 @@ +#! /bin/bash +# FS QA Test 033 +# +# Reproduce ext4 block reservation leak when mkfs.ext4 -Obigalloc and +# mount -odelalloc . +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Alibaba Group. 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_scratch +_require_scratch_ext4_feature "bigalloc" + +_scratch_mkfs -Obigalloc + +# explicitly mount with -odelalloc since -onodelalloc won't trigger the +# mentioned bug. +_scratch_mount -odelalloc + +# case 1: two delayed extents result in leak. +$XFS_IO_PROG -f -c "pwrite 0 1" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file1 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file1 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file1 | $AWK_PROG '{print $1}' | tee -a $seqres.full + +# case 2: (one allocated extent + one delayed extent) result in leak. +$XFS_IO_PROG -f -c "pwrite 0 1" -c "fsync" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file2 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file2 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file2 | $AWK_PROG '{print $1}' | tee -a $seqres.full + +# case 3: (one unwritten extent + one delayed extent) result in leak. +$XFS_IO_PROG -f -c "falloc 0 1" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file3 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file3 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file3 | $AWK_PROG '{print $1}' | tee -a $seqres.full + + +# success, all done +status=0 +exit
tests/ext4/033.out new file +14 -0
@@ -0,0 +1,14 @@ +QA output created by 033 +wrote 1/1 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 +wrote 1/1 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64
tests/ext4/group +1 -0
@@ -35,6 +35,7 @@ 030 auto quick dax 031 auto quick dax 032 auto quick ioctl resize +033 quick auto 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defrag
Signature · 1 line
2.14.2
Quoted 2 lines · Liu Bo
This is to reproduce a leak case of block reservation when bigalloc and delalloc are enabled.
Would you please provide more details about the leak? That helps to understand what the test wants to execrise, and people still could know the test purpose years later :)
Quoted 60 lines
Signed-off-by Liu Bo <[email protected]>--- tests/ext4/033 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/033.out | 14 +++++++++ tests/ext4/group | 1 + 3 files changed, 104 insertions(+) create mode 100755 tests/ext4/033 create mode 100644 tests/ext4/033.outtests/ext4/033 new file +44
-0@@ -0,0 +1,89 @@ +#! /bin/bash +# FS QA Test 033 +# +# Reproduce ext4 block reservation leak when mkfs.ext4 -Obigalloc and +# mount -odelalloc . +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Alibaba Group. 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
tests/ext4/033 line 54
Quoted 10 lines
tests/ext4/033 new file +10
-0+rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs ext4 +_supported_os Linux + +_require_scratch +_require_scratch_ext4_feature "bigalloc"
Need "_require_xfs_io_command falloc"
tests/ext4/033 line 56
Quoted 2 lines
tests/ext4/033 new file +2
-0+ +_scratch_mkfs -Obigalloc
Need to drop the mkfs output or redirect them to $seqres.full, test fails currently because of the mkfs output.
Also, I think you need to specify the cluster size explicitly, i.e. "-C 64k", otherwise test passes unexpectedly on 2k block size ext4, as the default cluster size is not always 64k, but "16 times the block size" (mke2fs(8)).
Quoted 8 lines
tests/ext4/033 new file +8
-0+ +# explicitly mount with -odelalloc since -onodelalloc won't trigger the +# mentioned bug. +_scratch_mount -odelalloc + +# case 1: two delayed extents result in leak. +$XFS_IO_PROG -f -c "pwrite 0 1" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file1 | _filter_xfs_io +
tests/ext4/033 line 74
Quoted 10 lines
tests/ext4/033 new file +10
-0+# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file1 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file1 | $AWK_PROG '{print $1}' | tee -a $seqres.full + +# case 2: (one allocated extent + one delayed extent) result in leak. +$XFS_IO_PROG -f -c "pwrite 0 1" -c "fsync" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file2 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K.
No need to repeat the same comments again and again :)
tests/ext4/033 line 76
Quoted 2 lines
tests/ext4/033 new file +2
-0+echo "du $SCRATCH_MNT/file2 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file2 | $AWK_PROG '{print $1}' | tee -a $seqres.full
Make this a local helper function?
Thanks,
Eryu
Quoted 52 lines
tests/ext4/033 new file +13
-0+ +# case 3: (one unwritten extent + one delayed extent) result in leak. +$XFS_IO_PROG -f -c "falloc 0 1" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file3 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file3 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file3 | $AWK_PROG '{print $1}' | tee -a $seqres.full + + +# success, all done +status=0 +exittests/ext4/033.out new file +14
-0@@ -0,0 +1,14 @@ +QA output created by 033 +wrote 1/1 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 +wrote 1/1 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64tests/ext4/group +1
-0@@ -35,6 +35,7 @@ 030 auto quick dax 031 auto quick dax 032 auto quick ioctl resize +033 quick auto 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defragSignature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Eryu Guan
Quoted 2 lines · Liu Bo
This is to reproduce a leak case of block reservation when bigalloc and delalloc are enabled.
Would you please provide more details about the leak? That helps to understand what the test wants to execrise, and people still could know the test purpose years later :)
Sure.
Quoted 73 lines
Quoted 60 lines
Signed-off-by Liu Bo <[email protected]>--- tests/ext4/033 | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/033.out | 14 +++++++++ tests/ext4/group | 1 + 3 files changed, 104 insertions(+) create mode 100755 tests/ext4/033 create mode 100644 tests/ext4/033.outtests/ext4/033 new file +44
-0@@ -0,0 +1,89 @@ +#! /bin/bash +# FS QA Test 033 +# +# Reproduce ext4 block reservation leak when mkfs.ext4 -Obigalloc and +# mount -odelalloc . +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Alibaba Group. 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 testtests/ext4/033 line 54
Quoted 10 lines
tests/ext4/033 new file +10
-0+rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs ext4 +_supported_os Linux + +_require_scratch +_require_scratch_ext4_feature "bigalloc"Need "
_require_xfs_io_commandfalloc"
Quoted 6 lines
tests/ext4/033 line 56
Quoted 2 lines
tests/ext4/033 new file +2
-0+ +_scratch_mkfs -ObigallocNeed to drop the mkfs output or redirect them to $seqres.full, test fails currently because of the mkfs output.
OK, it did pass in my test though.
Quoted 5 lines
Also, I think you need to specify the cluster size explicitly, i.e. "-C 64k", otherwise test passes unexpectedly on 2k block size ext4, as the default cluster size is not always 64k, but "16 times the block size" (mke2fs(8)).
Yes, make sense.
Quoted 21 lines
Quoted 8 lines
tests/ext4/033 new file +8
-0+ +# explicitly mount with -odelalloc since -onodelalloc won't trigger the +# mentioned bug. +_scratch_mount -odelalloc + +# case 1: two delayed extents result in leak. +$XFS_IO_PROG -f -c "pwrite 0 1" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file1 | _filter_xfs_io +tests/ext4/033 line 74
Quoted 10 lines
tests/ext4/033 new file +10
-0+# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file1 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file1 | $AWK_PROG '{print $1}' | tee -a $seqres.full + +# case 2: (one allocated extent + one delayed extent) result in leak. +$XFS_IO_PROG -f -c "pwrite 0 1" -c "fsync" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file2 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K.No need to repeat the same comments again and again :)
Quoted 5 lines
tests/ext4/033 line 76
Quoted 2 lines
tests/ext4/033 new file +2
-0+echo "du $SCRATCH_MNT/file2 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file2 | $AWK_PROG '{print $1}' | tee -a $seqres.fullMake this a local helper function?
Sure, will update.
Thanks a lot for the comments.
thanks,
liubo
Quoted 55 lines
Thanks,
EryuQuoted 52 lines
tests/ext4/033 new file +13
-0+ +# case 3: (one unwritten extent + one delayed extent) result in leak. +$XFS_IO_PROG -f -c "falloc 0 1" -c "pwrite 16k 1" -c "fsync" $SCRATCH_MNT/file3 | _filter_xfs_io + +# Since the default cluster size is 64K, and all the writes we've made are in +# one cluster, thus du is supposed to report 64K. +echo "du $SCRATCH_MNT/file3 | $AWK_PROG '{print \$1}'" >> $seqres.full +du $SCRATCH_MNT/file3 | $AWK_PROG '{print $1}' | tee -a $seqres.full + + +# success, all done +status=0 +exittests/ext4/033.out new file +14
-0@@ -0,0 +1,14 @@ +QA output created by 033 +wrote 1/1 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 +wrote 1/1 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 +wrote 1/1 bytes at offset 16384 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64tests/ext4/group +1
-1@@ -35,6 +35,7 @@ 030 auto quick dax 031 auto quick dax 032 auto quick ioctl resize +033 quick auto 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defrag --2.14.2
--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html