lib/: spdx license conversion
[xfstests-dev.git] / tests / generic / 071
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 071
6 #
7 # Test extent pre-allocation (using fallocate) into a region that already has a
8 # pre-allocated extent that ends beyond the file's size. Verify that if the fs
9 # is unmounted immediately after, the file's size and content are not lost.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18
19 _cleanup()
20 {
21         rm -f $tmp.*
22 }
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs generic
31 _supported_os Linux
32 _require_scratch
33 _require_xfs_io_command "falloc" "-k"
34
35 rm -f $seqres.full
36
37 _scratch_mkfs >> $seqres.full 2>&1
38 _scratch_mount
39
40 # Create our test file with a pre-allocated extent that doesn't increase the
41 # file's size.
42 $XFS_IO_PROG -f -c "falloc -k 0 1M" $SCRATCH_MNT/foo
43
44 # Write some data to our file.
45 $XFS_IO_PROG -c "pwrite -S 0xaa 0 256K" $SCRATCH_MNT/foo | _filter_xfs_io
46
47 # Now call fallocate again, but allowing it to increase the file's size and
48 # cover a range that is entirely covered by the extent that we previously
49 # pre-allocated.
50 $XFS_IO_PROG -c "falloc 0 512K" $SCRATCH_MNT/foo
51
52 # Now ummount and mount again the fs. After this we expect the file's size to
53 # be 512Kb.
54 _scratch_cycle_mount
55
56 # Now check that all data we wrote before are available and the file size is
57 # 512Kb.
58 echo "File content after remount:"
59 od -t x1 $SCRATCH_MNT/foo
60
61 status=0
62 exit