mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
5652a4880c
Test that if we clone part of an extent from a file to itself at a different offset, fsync it, rewrite (COW) part of the extent from the former offset, fsync it again, power fail and then mount the filesystem, we are able to read the whole file and it has the correct data. This is motivated by a bug found in btrfs which is fixed by a kernel patch that has the following subject: "Btrfs: fix missing data checksums after replaying a log tree" Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
78 lines
2.2 KiB
Bash
Executable File
78 lines
2.2 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
|
|
#
|
|
# FSQA Test No. 588
|
|
#
|
|
# Test that if we clone part of an extent from a file to itself at different
|
|
# offset, fsync it, rewrite (COW) part of the extent from the former offset,
|
|
# fsync it again, power fail and then mount the filesystem, we are able to
|
|
# read the whole file and it has the correct data.
|
|
#
|
|
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/reflink
|
|
. ./common/dmflakey
|
|
|
|
# real QA test starts here
|
|
_supported_fs generic
|
|
_supported_os Linux
|
|
_require_scratch_reflink
|
|
_require_dm_target flakey
|
|
|
|
rm -f $seqres.full
|
|
|
|
_scratch_mkfs >>$seqres.full 2>&1
|
|
_require_metadata_journaling $SCRATCH_DEV
|
|
_init_flakey
|
|
_mount_flakey
|
|
|
|
# Create our test file with two 256Kb extents, one at file offset 0 and the
|
|
# other at file offset 256Kb.
|
|
$XFS_IO_PROG -f -c "pwrite -S 0xa3 0 256K" \
|
|
-c "fsync" \
|
|
-c "pwrite -S 0xc7 256K 256K" \
|
|
$SCRATCH_MNT/foobar | _filter_xfs_io
|
|
|
|
# Now clone the second 64Kb of data from the second extent into file offset 0.
|
|
# After this we get that extent partially shared. Also fsync the file.
|
|
$XFS_IO_PROG -c "reflink $SCRATCH_MNT/foobar 320K 0K 64K" \
|
|
-c "fsync" \
|
|
$SCRATCH_MNT/foobar | _filter_xfs_io
|
|
|
|
# Now COW the first 64Kb of data for that second extent. After this we no longer
|
|
# have the extent fully referenced - its second 64Kb of data are referenced at
|
|
# file offset 0 and its last 192Kb of data are referenced at file offset 320Kb.
|
|
# Fsync the file to make sure everything is durably persisted.
|
|
$XFS_IO_PROG -c "pwrite -S 0xe5 256K 64K" \
|
|
-c "fsync" \
|
|
$SCRATCH_MNT/foobar | _filter_xfs_io
|
|
|
|
echo "File digest before power failure:"
|
|
_md5_checksum $SCRATCH_MNT/foobar
|
|
|
|
# Simulate a power failure and then check no data loss or corruption happened.
|
|
_flakey_drop_and_remount
|
|
|
|
echo "File digest after mount:"
|
|
_md5_checksum $SCRATCH_MNT/foobar
|
|
|
|
_unmount_flakey
|
|
status=0
|
|
exit
|