mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
reflink: test the various fallocate modes
Check that the variants of fallocate (allocate, punch, zero range, collapse range, insert range) do the right thing when they're run against a range of reflinked blocks. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
committed by
Dave Chinner
parent
6a4e8b81d9
commit
c84e01bac3
Executable
+142
@@ -0,0 +1,142 @@
|
||||
#! /bin/bash
|
||||
# FS QA Test No. 144
|
||||
#
|
||||
# Ensure that fallocate steps around reflinked ranges:
|
||||
# - Reflink parts of two files together
|
||||
# - Fallocate all the other sparse space.
|
||||
# - Check that the reflinked areas are still there.
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright (c) 2015, Oracle and/or its affiliates. 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 -rf "$tmp".* "$TESTDIR"
|
||||
}
|
||||
|
||||
# get standard environment, filters and checks
|
||||
. ./common/rc
|
||||
. ./common/filter
|
||||
. ./common/reflink
|
||||
|
||||
# real QA test starts here
|
||||
_supported_os Linux
|
||||
_require_test_reflink
|
||||
_require_cp_reflink
|
||||
_require_xfs_io_command "falloc"
|
||||
_require_xfs_io_command "truncate"
|
||||
|
||||
rm -f "$seqres.full"
|
||||
|
||||
TESTDIR="$TEST_DIR/test-$seq"
|
||||
rm -rf "$TESTDIR"
|
||||
mkdir "$TESTDIR"
|
||||
|
||||
echo "Create the original files"
|
||||
BLKSZ=65536
|
||||
_pwrite_byte 0x61 0 $((BLKSZ * 5 + 37)) "$TESTDIR/file1" >> "$seqres.full"
|
||||
|
||||
_reflink_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $BLKSZ \
|
||||
$((BLKSZ * 4 + 37)) >> "$seqres.full"
|
||||
|
||||
"$XFS_IO_PROG" -f -c "truncate $((BLKSZ * 5 + 37))" "$TESTDIR/file3" >> "$seqres.full"
|
||||
_reflink_range "$TESTDIR/file1" 0 "$TESTDIR/file3" 0 $BLKSZ >> "$seqres.full"
|
||||
|
||||
"$XFS_IO_PROG" -f -c "truncate $((BLKSZ * 5 + 37))" "$TESTDIR/file4" >> "$seqres.full"
|
||||
_reflink_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file4" $BLKSZ $BLKSZ >> "$seqres.full"
|
||||
_reflink_range "$TESTDIR/file1" $((BLKSZ * 3)) "$TESTDIR/file4" $((BLKSZ * 3)) \
|
||||
$BLKSZ >> "$seqres.full"
|
||||
|
||||
_cp_reflink "$TESTDIR/file1" "$TESTDIR/file5"
|
||||
_test_remount
|
||||
|
||||
echo "Compare sections"
|
||||
md5sum "$TESTDIR/file1" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file2" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file3" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file4" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file5" | _filter_test_dir
|
||||
|
||||
_compare_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $BLKSZ \
|
||||
$((BLKSZ * 4 + 37)) \
|
||||
|| echo "shared parts of files 1-2 changed"
|
||||
|
||||
_compare_range "$TESTDIR/file1" 0 "$TESTDIR/file3" 0 $BLKSZ \
|
||||
|| echo "shared parts of files 1-3 changed"
|
||||
|
||||
_compare_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file4" $BLKSZ $BLKSZ \
|
||||
|| echo "shared parts of files 1-4 changed"
|
||||
|
||||
_compare_range "$TESTDIR/file1" 0 "$TESTDIR/file5" 0 $((BLKSZ * 5 + 37)) \
|
||||
|| echo "shared parts of files 1-5 changed"
|
||||
|
||||
echo "Compare files"
|
||||
C1="$(_md5_checksum "$TESTDIR/file1")"
|
||||
C2="$(_md5_checksum "$TESTDIR/file2")"
|
||||
C3="$(_md5_checksum "$TESTDIR/file3")"
|
||||
C4="$(_md5_checksum "$TESTDIR/file4")"
|
||||
C5="$(_md5_checksum "$TESTDIR/file5")"
|
||||
|
||||
test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
|
||||
test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
|
||||
test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
|
||||
test "${C1}" = "${C5}" || echo "file1 and file5 should match"
|
||||
test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
|
||||
test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
|
||||
test "${C2}" != "${C5}" || echo "file2 and file5 should not match"
|
||||
test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
|
||||
test "${C3}" != "${C5}" || echo "file3 and file5 should not match"
|
||||
test "${C4}" != "${C5}" || echo "file4 and file5 should not match"
|
||||
|
||||
echo "falloc everything"
|
||||
"$XFS_IO_PROG" -f -c "falloc 0 $((BLKSZ * 5))" "$TESTDIR/file2" >> "$seqres.full"
|
||||
"$XFS_IO_PROG" -f -c "falloc 0 $((BLKSZ * 5))" "$TESTDIR/file3" >> "$seqres.full"
|
||||
"$XFS_IO_PROG" -f -c "falloc 0 $((BLKSZ * 5))" "$TESTDIR/file4" >> "$seqres.full"
|
||||
_test_remount
|
||||
|
||||
echo "Compare files"
|
||||
md5sum "$TESTDIR/file1" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file2" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file3" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file4" | _filter_test_dir
|
||||
md5sum "$TESTDIR/file5" | _filter_test_dir
|
||||
|
||||
D1="$(_md5_checksum "$TESTDIR/file1")"
|
||||
D2="$(_md5_checksum "$TESTDIR/file2")"
|
||||
D3="$(_md5_checksum "$TESTDIR/file3")"
|
||||
D4="$(_md5_checksum "$TESTDIR/file4")"
|
||||
D5="$(_md5_checksum "$TESTDIR/file5")"
|
||||
|
||||
test "${C1}" = "${D1}" || echo "file1 should not change"
|
||||
test "${C2}" = "${D2}" || echo "file2 should not change"
|
||||
test "${C3}" = "${D3}" || echo "file3 should not change"
|
||||
test "${C4}" = "${D4}" || echo "file4 should not change"
|
||||
test "${C5}" = "${D5}" || echo "file2 should not change"
|
||||
|
||||
# success, all done
|
||||
status=0
|
||||
exit
|
||||
Reference in New Issue
Block a user