reflink: ensure that we can handle reflinking a lot of extents
[xfstests-dev.git] / tests / generic / 071
1 #! /bin/bash
2 # FS QA Test No. 071
3 #
4 # Test extent pre-allocation (using fallocate) into a region that already has a
5 # pre-allocated extent that ends beyond the file's size. Verify that if the fs
6 # is unmounted immediately after, the file's size and content are not lost.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
10 # Author: Filipe Manana <fdmanana@suse.com>
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37         rm -f $tmp.*
38 }
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os Linux
48 _need_to_be_root
49 _require_scratch
50 _require_xfs_io_command "falloc"
51
52 rm -f $seqres.full
53
54 _scratch_mkfs >> $seqres.full 2>&1
55 _scratch_mount
56
57 # Create our test file with a pre-allocated extent that doesn't increase the
58 # file's size.
59 $XFS_IO_PROG -f -c "falloc -k 0 1M" $SCRATCH_MNT/foo
60
61 # Write some data to our file.
62 $XFS_IO_PROG -c "pwrite -S 0xaa 0 256K" $SCRATCH_MNT/foo | _filter_xfs_io
63
64 # Now call fallocate again, but allowing it to increase the file's size and
65 # cover a range that is entirely covered by the extent that we previously
66 # pre-allocated.
67 $XFS_IO_PROG -c "falloc 0 512K" $SCRATCH_MNT/foo
68
69 # Now ummount and mount again the fs. After this we expect the file's size to
70 # be 512Kb.
71 _scratch_remount
72
73 # Now check that all data we wrote before are available and the file size is
74 # 512Kb.
75 echo "File content after remount:"
76 od -t x1 $SCRATCH_MNT/foo
77
78 status=0
79 exit