xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / btrfs / 035
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/035
6 #
7 # Regression test for overwriting clones
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16
17 _cleanup()
18 {
19     rm -f $tmp.*
20 }
21
22 trap "_cleanup ; exit \$status" 0 1 2 3 15
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/filter.btrfs
28
29 # real QA test starts here
30 _supported_fs btrfs
31 _supported_os Linux
32 _require_scratch
33 _require_cloner
34
35 _scratch_mkfs > /dev/null 2>&1
36 _scratch_mount
37
38 src_str="aaaaaaaaaa"
39
40 echo -n "$src_str" > $SCRATCH_MNT/src
41
42 $CLONER_PROG $SCRATCH_MNT/src  $SCRATCH_MNT/src.clone1
43
44 src_str="bbbbbbbbbbcccccccccc"
45
46 echo -n "$src_str" > $SCRATCH_MNT/src
47
48 $CLONER_PROG $SCRATCH_MNT/src $SCRATCH_MNT/src.clone2
49
50 snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone1 | awk '{print $5}'`
51 echo "attempting ioctl (src.clone1 src)"
52 $CLONER_PROG -s 0 -d 0 -l ${snap_src_sz} \
53         $SCRATCH_MNT/src.clone1 $SCRATCH_MNT/src | _filter_btrfs_cloner_error
54
55 # The clone operation should have failed. If it did not it meant we had data
56 # loss, because file "src.clone1" has an inline extent which is 10 bytes long
57 # while file "src" has an inline extent which is 20 bytes long. The clone
58 # operation would remove the inline extent of "src" and then copy the inline
59 # extent from "src.clone1" into "src", which means we would lose the last 10
60 # bytes of data from "src" (on read we would get 0x00 as the value for any
61 # of those 10 bytes, because the file's size remains as 20 bytes).
62 echo "File src data after attempt to clone from src.clone1 into src:"
63 od -t x1 $SCRATCH_MNT/src
64
65 snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone2 | awk '{print $5}'`
66 echo "attempting ioctl (src.clone2 src)"
67 $CLONER_PROG -s 0 -d 0 -l ${snap_src_sz} \
68         $SCRATCH_MNT/src.clone2 $SCRATCH_MNT/src
69
70 # The clone operation should have succeeded.
71 echo "File src data after attempt to clone from src.clone2 into src:"
72 od -t x1 $SCRATCH_MNT/src
73
74 status=0 ; exit