xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 025
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/025
6 #
7 # Test for an issue in btrfs send where it sent clone operations to user
8 # space with a range (offset + length) that was not aligned with the block
9 # size. This caused the btrfs receive command to send such clone operations
10 # to the ioctl clone API, which would return -EINVAL errors to btrfs receive,
11 # causing the receive command to abort immediately.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 tmp=`mktemp -d`
18
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     rm -fr $tmp
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs btrfs
33 _require_scratch
34
35 rm -f $seqres.full
36
37 _scratch_mkfs >/dev/null 2>&1
38 _scratch_mount
39
40 run_check $XFS_IO_PROG -f -c "truncate 819200" $SCRATCH_MNT/foo
41 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
42
43 run_check $XFS_IO_PROG -c "falloc -k 819200 667648" $SCRATCH_MNT/foo
44 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
45
46 run_check $XFS_IO_PROG -c "pwrite 1482752 2978" $SCRATCH_MNT/foo
47 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
48
49 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
50     $SCRATCH_MNT/mysnap1
51
52 run_check $XFS_IO_PROG -c "truncate 883305" $SCRATCH_MNT/foo
53 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
54
55 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
56     $SCRATCH_MNT/mysnap2
57
58 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
59 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
60     $SCRATCH_MNT/mysnap2 2>&1
61
62 md5sum $SCRATCH_MNT/foo | _filter_scratch
63 md5sum $SCRATCH_MNT/mysnap1/foo | _filter_scratch
64 md5sum $SCRATCH_MNT/mysnap2/foo | _filter_scratch
65
66 _scratch_unmount
67 _check_btrfs_filesystem $SCRATCH_DEV
68 _scratch_mkfs >/dev/null 2>&1
69 _scratch_mount
70
71 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
72 md5sum $SCRATCH_MNT/mysnap1/foo | _filter_scratch
73
74 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
75 md5sum $SCRATCH_MNT/mysnap2/foo | _filter_scratch
76
77 _scratch_unmount
78 _check_btrfs_filesystem $SCRATCH_DEV
79
80 status=0
81 exit