xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 518
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 518
6 #
7 # Test that we can not clone a range from a file A into the middle of a file B
8 # when the range includes the last block of file A and file A's size is not
9 # aligned with the filesystem's block size. Allowing such case would lead to
10 # data corruption since the data between EOF and the end of its block is
11 # undefined.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
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 generic
33 _supported_os Linux
34 _require_scratch_reflink
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >>$seqres.full 2>&1
39 _scratch_mount
40
41 foo_size=$((256 * 1024 + 100)) # 256Kb + 100 bytes
42 bar_size="1M"
43
44 $XFS_IO_PROG -f -c "pwrite -S 0x3c 0 $foo_size" $SCRATCH_MNT/foo | _filter_xfs_io
45 $XFS_IO_PROG -f -c "pwrite -S 0xb5 0 $bar_size" $SCRATCH_MNT/bar | _filter_xfs_io
46
47 # Cloning the EOF block of a file into the middle of another file should fail
48 # with an invalid argument error.
49 $XFS_IO_PROG -c "reflink $SCRATCH_MNT/foo 0 512K $foo_size" $SCRATCH_MNT/bar
50
51 # Unmount the filesystem and mount it again. This guarantees any file data in
52 # the page cache is dropped.
53 _scratch_cycle_mount
54
55 # Verify no changes were made to the file.
56 echo "File content after failed reflink:"
57 od -A d -t x1 $SCRATCH_MNT/bar
58
59 status=0
60 exit