xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / btrfs / 029
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 029
6 #
7 # Check if creating a sparse copy ("reflink") of a file on btrfs
8 # expectedly fails when it's done between different filesystems or
9 # different mount points of the same filesystem.
10 #
11 # For both situations, these actions are executed:
12 #    - Copy a file with the reflink=auto option.
13 #      A normal copy should be created.
14 #    - Copy a file with the reflink=always option. Should result in
15 #      error.
16 #
17 seq=`basename $0`
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1    # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28     cd /
29     rm -f $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35 . ./common/reflink
36
37 # real QA test starts here
38 _supported_fs btrfs
39 _supported_os Linux
40
41 _require_test
42 _require_scratch
43 _require_cp_reflink
44
45 reflink_test_dir=$TEST_DIR/test-$seq
46 rm -rf $reflink_test_dir
47 mkdir $reflink_test_dir
48
49 rm -f $seqres.full
50
51 _scratch_mkfs > /dev/null 2>&1
52 _scratch_mount
53 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/original >> $seqres.full
54
55 _create_reflinks()
56 {
57     # auto reflink, should fall back to non-reflink
58     rm -rf $2
59     echo "reflink=auto:"
60     cp --reflink=auto $1 $2
61     md5sum $1 | _filter_testdir_and_scratch
62     md5sum $2 | _filter_testdir_and_scratch
63
64     # always reflink, should fail outright
65     rm -rf $2
66     echo "reflink=always:"
67     cp --reflink=always $1 $2 >> $seqres.full 2>&1 || echo "cp reflink failed"
68
69     # The failed target actually gets created by cp:
70     ls $2 | _filter_testdir_and_scratch
71 }
72
73 echo "test reflinks across different devices"
74 _create_reflinks $SCRATCH_MNT/original $reflink_test_dir/copy
75
76 echo "test reflinks across different mountpoints of same device"
77 rm -rf $reflink_test_dir/*
78 _mount $SCRATCH_DEV $reflink_test_dir
79 _create_reflinks $SCRATCH_MNT/original $reflink_test_dir/copy
80 $UMOUNT_PROG $reflink_test_dir
81
82 # success, all done
83 status=0
84 exit