2016-01-22 16:55:30 -08:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
|
|
|
|
|
#
|
2016-01-22 16:55:30 -08:00
|
|
|
# FS QA Test No. 212
|
|
|
|
|
#
|
|
|
|
|
# Test recovery of "lost" CoW blocks after a crash:
|
|
|
|
|
# - Create two reflinked files. Set extsz hint on second file.
|
|
|
|
|
# - Dirty one byte on the second file and fsync.
|
|
|
|
|
# - Crash the FS to test recovery.
|
|
|
|
|
#
|
|
|
|
|
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.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/reflink
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
_require_scratch_reflink
|
|
|
|
|
_require_cp_reflink
|
2017-05-17 09:42:32 +08:00
|
|
|
_require_xfs_io_command "fiemap"
|
2016-01-22 16:55:30 -08:00
|
|
|
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
|
|
|
|
echo "Format and mount"
|
|
|
|
|
_scratch_mkfs > $seqres.full 2>&1
|
|
|
|
|
_scratch_mount >> $seqres.full 2>&1
|
|
|
|
|
|
|
|
|
|
testdir=$SCRATCH_MNT/test-$seq
|
|
|
|
|
mkdir $testdir
|
|
|
|
|
|
|
|
|
|
blksz=65536
|
|
|
|
|
nr=16
|
|
|
|
|
filesize=$((blksz * nr))
|
|
|
|
|
bufnr=2
|
|
|
|
|
bufsize=$((blksz * bufnr))
|
|
|
|
|
|
|
|
|
|
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
|
|
|
|
|
|
|
|
|
|
echo "Create the original files"
|
|
|
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
|
|
|
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
|
|
|
|
|
$XFS_IO_PROG -f -c "extsize $bufsize" $testdir/file2
|
|
|
|
|
_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
|
2016-02-19 10:44:53 +11:00
|
|
|
_scratch_cycle_mount
|
2016-01-22 16:55:30 -08:00
|
|
|
|
|
|
|
|
echo "Compare files"
|
|
|
|
|
md5sum $testdir/file1 | _filter_scratch
|
|
|
|
|
md5sum $testdir/file2 | _filter_scratch
|
|
|
|
|
md5sum $testdir/file2.chk | _filter_scratch
|
|
|
|
|
|
|
|
|
|
echo "CoW and leave leftovers"
|
|
|
|
|
$XFS_IO_PROG -f -c "extsize" $testdir/file2 >> $seqres.full
|
|
|
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x63 $((filesize - 1)) 1" -c "fsync" $testdir/file2 >> $seqres.full
|
|
|
|
|
$XFS_IO_PROG -f -c "pwrite -S 0x63 $((filesize - 1)) 1" -c "fsync" $testdir/file2.chk >> $seqres.full
|
|
|
|
|
sync
|
|
|
|
|
|
|
|
|
|
echo "Crash and recover"
|
|
|
|
|
$XFS_IO_PROG -x -c "shutdown" $testdir/file2 >> $seqres.full
|
2016-02-19 10:44:53 +11:00
|
|
|
_scratch_cycle_mount
|
2016-01-22 16:55:30 -08:00
|
|
|
|
|
|
|
|
echo "Compare files"
|
|
|
|
|
md5sum $testdir/file1 | _filter_scratch
|
|
|
|
|
md5sum $testdir/file2 | _filter_scratch
|
|
|
|
|
md5sum $testdir/file2.chk | _filter_scratch
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|