xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 186
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 186
6 #
7 # Test that if we have a subvolume/snapshot that is writable, has a file with
8 # unflushed delalloc (buffered writes not yet flushed), turn the subvolume to
9 # readonly mode and then use it for send a operation, the send stream will
10 # contain the delalloc data - that is, no data loss happens.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23         rm -fr $send_files_dir
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_test
33 _require_scratch
34 _require_btrfs_command "property"
35
36 send_files_dir=$TEST_DIR/btrfs-test-$seq
37
38 rm -f $seqres.full
39 rm -fr $send_files_dir
40 mkdir $send_files_dir
41
42 _scratch_mkfs >>$seqres.full 2>&1
43 _scratch_mount
44
45 # Create our test subvolume.
46 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/sv | _filter_scratch
47
48 # Create our test file with some delalloc data.
49 $XFS_IO_PROG -f -c "pwrite -S 0xea 0 108K" $SCRATCH_MNT/sv/foo | _filter_xfs_io
50
51 # Turn our subvolume to RO so that it can be used for a send operation.
52 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv ro true
53
54 # Create the send stream.
55 $BTRFS_UTIL_PROG send -f $send_files_dir/sv.send $SCRATCH_MNT/sv 2>&1 \
56     | _filter_scratch
57
58 echo "File content in the original filesystem:"
59 od -t x1 -A d $SCRATCH_MNT/sv/foo
60
61 # Recreate the filesystem and apply the send stream and verify no data was lost.
62 _scratch_unmount
63 _scratch_mkfs >>$seqres.full 2>&1
64 _scratch_mount
65
66 $BTRFS_UTIL_PROG receive -f $send_files_dir/sv.send $SCRATCH_MNT
67
68 echo "File content in the new filesystem:"
69 od -t x1 -A d $SCRATCH_MNT/sv/foo
70
71 status=0
72 exit