b835394a19b34e7539e4604db3895393075effa9
[xfstests-dev.git] / tests / xfs / 914
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 914
6 #
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.
10
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30
31 # real QA test starts here
32 _supported_fs xfs
33 _supported_os Linux
34 _require_scratch_reflink
35 _require_cp_reflink
36
37 rm -f $seqres.full
38
39 # Format filesystem and set up quota limits
40 _scratch_mkfs > $seqres.full
41 _scratch_mount -o wsync >> $seqres.full
42
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
48 touch $SCRATCH_MNT/b
49 sync
50
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
56
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
62
63 # success, all done
64 status=0
65 exit