2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved.
7 # Make sure that reflink forces the log out if we mount with wsync. We test
8 # that it actually forced the log by immediately shutting down the fs without
9 # flushing the log and then remounting to check file contents.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # real QA test starts here
33 _require_scratch_reflink
38 # Format filesystem and set up quota limits
39 _scratch_mkfs > $seqres.full
40 _scratch_mount -o wsync >> $seqres.full
42 # Set up initial files
43 $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
44 $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full
45 _cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e
46 _cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d
50 # Test that setting the reflink flag on the dest file forces the log
51 echo "test reflink flag not set"
52 $XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/b >> $seqres.full
53 _scratch_cycle_mount wsync
54 md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch
56 # Test forcing the log even if both files are already reflinked
57 echo "test reflink flag already set"
58 $XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/d >> $seqres.full
59 _scratch_cycle_mount wsync
60 md5sum $SCRATCH_MNT/a $SCRATCH_MNT/d | _filter_scratch