blob: 24e6f68dc8932b4e67d91ac780895fe5eadf7aed [file] [log] [blame]
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
#
# FS QA Test No. 201
#
# See what happens if we dirty a lot of pages via CoW and immediately
# unlink the file.
#
. ./common/preamble
_begin_fstest auto quick clone prealloc
# Override the default cleanup function.
_cleanup()
{
cd /
rm -rf $tmp.* $testdir
}
# Import common functions.
. ./common/filter
. ./common/reflink
_require_scratch_reflink
_require_xfs_io_command "falloc"
echo "Format and mount"
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
echo "Create the original files"
blksz=65536
_require_congruent_file_oplen $SCRATCH_MNT $blksz
nr=64
filesize=$((blksz * nr))
_pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
_pwrite_byte 0x62 0 $filesize $testdir/file3 >> $seqres.full
_pwrite_byte 0x62 0 $filesize $testdir/file3.chk >> $seqres.full
seq 0 2 $((nr-1)) | while read f; do
_reflink_range $testdir/file1 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full
_pwrite_byte 0x61 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full
done
_scratch_cycle_mount
echo "Compare files"
md5sum $testdir/file1 | _filter_scratch
md5sum $testdir/file3 | _filter_scratch
md5sum $testdir/file3.chk | _filter_scratch
echo "CoW and unlink"
cowoff=$((filesize / 4))
cowsz=$((filesize / 2))
$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
rm $testdir/file3
# success, all done
status=0
exit