mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fstests: generic test for fsync after hole punching
Test that a file fsync works after punching a hole for the same file range multiple times, and that after log/journal replay the file's content and layout are correct. This test is motivated by a bug found in btrfs, which is fixed by the following linux kernel patch: "Btrfs: fix hole punching when using the no-holes feature" Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
committed by
Dave Chinner
parent
727d47730d
commit
71f68b47e1
Executable
+108
@@ -0,0 +1,108 @@
|
||||
#! /bin/bash
|
||||
# FSQA Test No. 177
|
||||
#
|
||||
# Test that a file fsync works after punching a hole for the same file range
|
||||
# multiple times and that after log/journal replay the file's content is
|
||||
# correct.
|
||||
#
|
||||
# This test is motivated by a bug found in btrfs.
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
|
||||
# Author: Filipe Manana <fdmanana@suse.com>
|
||||
#
|
||||
# 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"
|
||||
tmp=/tmp/$$
|
||||
status=1 # failure is the default!
|
||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
_cleanup()
|
||||
{
|
||||
_cleanup_flakey
|
||||
cd /
|
||||
rm -f $tmp.*
|
||||
}
|
||||
|
||||
# get standard environment, filters and checks
|
||||
. ./common/rc
|
||||
. ./common/filter
|
||||
. ./common/punch
|
||||
. ./common/dmflakey
|
||||
|
||||
# real QA test starts here
|
||||
_need_to_be_root
|
||||
_supported_fs generic
|
||||
_supported_os Linux
|
||||
_require_scratch
|
||||
_require_xfs_io_command "fpunch"
|
||||
_require_xfs_io_command "fiemap"
|
||||
_require_dm_target flakey
|
||||
_require_metadata_journaling $SCRATCH_DEV
|
||||
|
||||
rm -f $seqres.full
|
||||
|
||||
_scratch_mkfs >>$seqres.full 2>&1
|
||||
_init_flakey
|
||||
_mount_flakey
|
||||
|
||||
# Create out test file with some data and then fsync it.
|
||||
# We do the fsync only to make sure the last fsync we do in this test triggers
|
||||
# the fast code path of btrfs' fsync implementation, a condition necessary to
|
||||
# trigger the bug btrfs had.
|
||||
$XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 128K" \
|
||||
-c "fsync" \
|
||||
$SCRATCH_MNT/foobar | _filter_xfs_io
|
||||
|
||||
# Now punch a hole against the range [96K, 128K[.
|
||||
$XFS_IO_PROG -c "fpunch 96K 32K" $SCRATCH_MNT/foobar
|
||||
|
||||
# Punch another hole against a range that overlaps the previous range and ends
|
||||
# beyond eof.
|
||||
$XFS_IO_PROG -c "fpunch 64K 128K" $SCRATCH_MNT/foobar
|
||||
|
||||
# Punch another hole against a range that overlaps the first range ([96K, 128K[)
|
||||
# and ends at eof.
|
||||
$XFS_IO_PROG -c "fpunch 32K 96K" $SCRATCH_MNT/foobar
|
||||
|
||||
# Fsync our file. We want to verify that, after a power failure and mounting the
|
||||
# filesystem again, the file content reflects all the hole punch operations.
|
||||
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar
|
||||
|
||||
echo "File digest before power failure:"
|
||||
md5sum $SCRATCH_MNT/foobar | _filter_scratch
|
||||
|
||||
echo "Fiemap before power failure:"
|
||||
$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar | _filter_fiemap
|
||||
|
||||
_flakey_drop_and_remount
|
||||
|
||||
echo "File digest after log replay:"
|
||||
# Must match the same digest we got before the power failure.
|
||||
md5sum $SCRATCH_MNT/foobar | _filter_scratch
|
||||
|
||||
echo "Fiemap after log replay:"
|
||||
# Must match the same extent listing we got before the power failure.
|
||||
$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foobar | _filter_fiemap
|
||||
|
||||
_unmount_flakey
|
||||
|
||||
status=0
|
||||
exit
|
||||
@@ -0,0 +1,13 @@
|
||||
QA output created by 177
|
||||
wrote 131072/131072 bytes at offset 0
|
||||
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
File digest before power failure:
|
||||
d26bbb9a8396a9c0dd76423471b72b15 SCRATCH_MNT/foobar
|
||||
Fiemap before power failure:
|
||||
0: [0..63]: data
|
||||
1: [64..255]: hole
|
||||
File digest after log replay:
|
||||
d26bbb9a8396a9c0dd76423471b72b15 SCRATCH_MNT/foobar
|
||||
Fiemap after log replay:
|
||||
0: [0..63]: data
|
||||
1: [64..255]: hole
|
||||
@@ -179,6 +179,7 @@
|
||||
174 auto quick clone
|
||||
175 clone_stress
|
||||
176 clone_stress
|
||||
177 auto quick prealloc metadata
|
||||
184 metadata auto quick
|
||||
192 atime auto
|
||||
193 metadata auto quick
|
||||
|
||||
Reference in New Issue
Block a user