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
34 _require_scratch_reflink
39 # Format filesystem and set up quota limits
40 _scratch_mkfs > $seqres.full
41 _scratch_mount -o wsync >> $seqres.full
43 # Set up initial files
44 $XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
45 $XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full
46 _cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e
47 _cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d
51 # Test that setting the reflink flag on the dest file forces the log
52 echo "test reflink flag not set"
53 $XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/b >> $seqres.full
54 _scratch_cycle_mount wsync
55 md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch
57 # Test forcing the log even if both files are already reflinked
58 echo "test reflink flag already set"
59 $XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/d >> $seqres.full
60 _scratch_cycle_mount wsync
61 md5sum $SCRATCH_MNT/a $SCRATCH_MNT/d | _filter_scratch