common: kill _supported_os
[xfstests-dev.git] / tests / btrfs / 117
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/117
6 #
7 # Test that an incremental send operation which issues clone operations works
8 # for files that have a full path containing more than one parent directory
9 # component.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 tmp=`mktemp -d`
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 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_scratch
33 _require_cp_reflink
34
35 rm -f $seqres.full
36
37 _scratch_mkfs >>$seqres.full 2>&1
38 _scratch_mount
39
40 mkdir -p $SCRATCH_MNT/a/b/c
41 $XFS_IO_PROG -f -c "pwrite -S 0xfd 0 128K" $SCRATCH_MNT/a/b/c/x | _filter_xfs_io
42
43 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
44
45 # Create a bunch of small and empty files, this is just to make sure our
46 # subvolume's btree gets more than 1 leaf, a condition necessary to trigger a
47 # past bug (1000 files is enough even for a leaf/node size of 64K, the largest
48 # possible size).
49 for ((i = 1; i <= 1000; i++)); do
50         echo -n > $SCRATCH_MNT/a/b/c/z_$i
51 done
52
53 # Create a clone of file x's extent and write some data to the middle of this
54 # new file, this is to guarantee the incremental send operation below issues
55 # a clone operation.
56 cp --reflink=always $SCRATCH_MNT/a/b/c/x $SCRATCH_MNT/a/b/c/y
57 $XFS_IO_PROG -c "pwrite -S 0xab 32K 16K" $SCRATCH_MNT/a/b/c/y | _filter_xfs_io
58
59 # Will be used as an extra source root for clone operations for the incremental
60 # send operation below.
61 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/clones_snap
62
63 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap2
64
65 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/snap1
66 _run_btrfs_util_prog send -f $tmp/clones.snap $SCRATCH_MNT/clones_snap
67 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 \
68         -c $SCRATCH_MNT/clones_snap -f $tmp/2.snap $SCRATCH_MNT/snap2
69
70 echo "File digests in the original filesystem:"
71 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
72 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
73 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch
74
75 _scratch_unmount
76 _scratch_mkfs >>$seqres.full 2>&1
77 _scratch_mount
78
79 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
80 _run_btrfs_util_prog receive -f $tmp/clones.snap $SCRATCH_MNT
81 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
82
83 echo "File digests in the new filesystem:"
84 # Should match the digests we had in the original filesystem.
85 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
86 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
87 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch
88
89 status=0
90 exit