Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
block: test fallocate for block devices
Now that we're wiring up fallocate's PUNCH_HOLE and ZERO_RANGE features for block devices, add some tests to make sure they work correctly. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
- Loading branch information
Showing
8 changed files
with
290 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#! /bin/bash | ||
# FS QA Test No. 705 | ||
# | ||
# Test fallocate(ZERO_RANGE) on a block device, which should be able to | ||
# WRITE SAME (or equivalent) the range. | ||
# | ||
#----------------------------------------------------------------------- | ||
# Copyright (c) 2016 Oracle, Inc. 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 7 15 | ||
|
||
_cleanup() | ||
{ | ||
cd / | ||
rm -rf $tmp.* | ||
} | ||
|
||
# get standard environment, filters and checks | ||
. ./common/rc | ||
. ./common/filter | ||
. ./common/scsi_debug | ||
|
||
# real QA test starts here | ||
_supported_os Linux | ||
_require_scsi_debug | ||
_require_xfs_io_command "fzero" | ||
|
||
echo "Create and format" | ||
dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=1 lbpws10=1") | ||
_pwrite_byte 0x62 0 4m $dev >> $seqres.full | ||
|
||
echo "Zero range" | ||
$XFS_IO_PROG -c "fzero -k 512k 1m" $dev | ||
|
||
echo "Check contents" | ||
md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g" | ||
|
||
echo "Destroy device" | ||
_put_scsi_debug_dev | ||
|
||
# success, all done | ||
status=0 | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
QA output created by 705 | ||
Create and format | ||
Zero range | ||
Check contents | ||
caa26edd6c70ce862eb7ec6f10b138a8 SCSI_DEBUG_DEV | ||
Destroy device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#! /bin/bash | ||
# FS QA Test No. 706 | ||
# | ||
# Test fallocate(PUNCH_HOLE) on a block device, which should be able to | ||
# zero-TRIM (or equivalent) the range. | ||
# | ||
#----------------------------------------------------------------------- | ||
# Copyright (c) 2016 Oracle, Inc. 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 7 15 | ||
|
||
_cleanup() | ||
{ | ||
cd / | ||
rm -rf $tmp.* | ||
} | ||
|
||
# get standard environment, filters and checks | ||
. ./common/rc | ||
. ./common/filter | ||
. ./common/scsi_debug | ||
|
||
# real QA test starts here | ||
_supported_os Linux | ||
_require_scsi_debug | ||
_require_xfs_io_command "fpunch" | ||
|
||
echo "Create and format" | ||
dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=1 lbpws10=1") | ||
_pwrite_byte 0x62 0 4m $dev >> $seqres.full | ||
|
||
echo "Zero punch" | ||
$XFS_IO_PROG -c "fpunch 512k 1m" $dev | ||
|
||
echo "Check contents" | ||
md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g" | ||
|
||
echo "Destroy device" | ||
_put_scsi_debug_dev | ||
|
||
# success, all done | ||
status=0 | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
QA output created by 706 | ||
Create and format | ||
Zero punch | ||
Check contents | ||
caa26edd6c70ce862eb7ec6f10b138a8 SCSI_DEBUG_DEV | ||
Destroy device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#! /bin/bash | ||
# FS QA Test No. 707 | ||
# | ||
# Test the unsupported fallocate flags on a block device. No collapse | ||
# or insert range, no regular fallocate, no forgetting keep-space on | ||
# zero range, no punching past EOD, no requests that aren't aligned | ||
# with the logicalsector size, and make sure the fallbacks work for | ||
# devices that don't support write_same or discard. | ||
# | ||
#----------------------------------------------------------------------- | ||
# Copyright (c) 2016 Oracle, Inc. 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 7 15 | ||
|
||
_cleanup() | ||
{ | ||
cd / | ||
rm -rf $tmp.* | ||
} | ||
|
||
# get standard environment, filters and checks | ||
. ./common/rc | ||
. ./common/filter | ||
. ./common/scsi_debug | ||
|
||
# real QA test starts here | ||
_supported_os Linux | ||
_require_scsi_debug | ||
_require_xfs_io_command "falloc" | ||
_require_xfs_io_command "finsert" | ||
_require_xfs_io_command "fcollapse" | ||
_require_xfs_io_command "fzero" | ||
_require_xfs_io_command "fpunch" | ||
|
||
|
||
echo "Create and format" | ||
dev=$(_get_scsi_debug_dev 4096 4096 0 4 "lbpws=1 lbpws10=1") | ||
_pwrite_byte 0x62 0 4m $dev >> $seqres.full | ||
$XFS_IO_PROG -c "fsync" $dev | ||
|
||
echo "Regular fallocate" | ||
$XFS_IO_PROG -c "falloc 64k 64k" $dev | ||
|
||
echo "Insert range" | ||
$XFS_IO_PROG -c "finsert 128k 64k" $dev | ||
|
||
echo "Collapse range" | ||
$XFS_IO_PROG -c "fcollapse 256k 64k" $dev | ||
|
||
echo "Zero range without keep_size" | ||
$XFS_IO_PROG -c "fzero 384k 64k" $dev | ||
|
||
echo "Zero range past EOD" | ||
$XFS_IO_PROG -c "fzero -k 3m 4m" $dev | ||
|
||
echo "Punch range past EOD" | ||
$XFS_IO_PROG -c "fpunch 3m 4m" $dev | ||
|
||
echo "Unaligned zero range" | ||
$XFS_IO_PROG -c "fzero -k 512 512" $dev | ||
|
||
echo "Unaligned punch" | ||
$XFS_IO_PROG -c "fpunch 512 512" $dev | ||
|
||
echo "Check contents" | ||
md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g" | ||
|
||
echo "Destroy device" | ||
_put_scsi_debug_dev | ||
|
||
echo "Create w/o unmap or writesame and format" | ||
dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=0 lbpws10=0 lbpu=0 write_same_length=0 unmap_max_blocks=0") | ||
_pwrite_byte 0x62 0 4m $dev >> $seqres.full | ||
$XFS_IO_PROG -c "fsync" $dev | ||
|
||
echo "Zero punch, no fallback available" | ||
$XFS_IO_PROG -c "fpunch 512k 512k" $dev | ||
|
||
echo "Zero range, write fallback" | ||
$XFS_IO_PROG -c "fzero -k 1536k 512k" $dev | ||
|
||
echo "Check contents" | ||
md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g" | ||
|
||
echo "Destroy device" | ||
_put_scsi_debug_dev | ||
|
||
# success, all done | ||
status=0 | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
QA output created by 707 | ||
Create and format | ||
Regular fallocate | ||
fallocate: Operation not supported | ||
Insert range | ||
fallocate: Operation not supported | ||
Collapse range | ||
fallocate: Operation not supported | ||
Zero range without keep_size | ||
fallocate: Operation not supported | ||
Zero range past EOD | ||
fallocate: Invalid argument | ||
Punch range past EOD | ||
fallocate: Invalid argument | ||
Unaligned zero range | ||
fallocate: Invalid argument | ||
Unaligned punch | ||
fallocate: Invalid argument | ||
Check contents | ||
b83f9394092e15bdcda585cd8e776dc6 SCSI_DEBUG_DEV | ||
Destroy device | ||
Create w/o unmap or writesame and format | ||
Zero punch, no fallback available | ||
fallocate: Operation not supported | ||
Zero range, write fallback | ||
Check contents | ||
0fc6bc93cd0cd97e3cde5ea39ea1185d SCSI_DEBUG_DEV | ||
Destroy device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters