filter: xfs_io output has dropped "64" from error messages
[xfstests-dev.git] / tests / generic / 172
1 #! /bin/bash
2 # FS QA Test No. 172
3 #
4 # Reflink a file that uses more than half of the space, then try to observe
5 # ENOSPC while copy-on-writing the file via the page cache.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #-----------------------------------------------------------------------
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1    # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35     cd /
36     rm -rf $tmp.* $testdir1
37 }
38
39 # get standard environment, filters and checks
40 . ./common/rc
41 . ./common/filter
42 . ./common/attr
43 . ./common/reflink
44
45 # real QA test starts here
46 _supported_os Linux
47 _require_scratch_reflink
48 _require_cp_reflink
49
50 rm -f $seqres.full
51
52 echo "Format and mount"
53 _scratch_mkfs > $seqres.full 2>&1
54 _scratch_mount >> $seqres.full 2>&1
55
56 testdir=$SCRATCH_MNT/test-$seq
57 mkdir $testdir
58
59 echo "Reformat with appropriate size"
60 umount $SCRATCH_MNT
61
62 file_size=$((168 * 1024 * 1024))
63 fs_size=$((256 * 1024 * 1024))
64 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
65 _scratch_mount >> $seqres.full 2>&1
66 rm -rf $testdir
67 mkdir $testdir
68
69 echo "Create a big file and reflink it"
70 _pwrite_byte 0x61 0 $file_size $testdir/bigfile >> $seqres.full 2>&1
71 _cp_reflink $testdir/bigfile $testdir/clonefile
72 sync
73
74 echo "Allocate the rest of the space"
75 touch $testdir/file0 $testdir/file1
76 _pwrite_byte 0x61 0 $fs_size $testdir/eat_my_space >> $seqres.full 2>&1
77 sync
78
79 echo "CoW the big file"
80 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
81         _filter_xfs_io_error)"
82 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
83 echo ${out} >> $seqres.full 2>&1
84 echo ${out}
85
86 echo "Remount and try CoW again"
87 _scratch_cycle_mount
88
89 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
90         _filter_xfs_io_error)"
91 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
92 echo ${out} >> $seqres.full 2>&1
93 echo ${out}
94
95 # success, all done
96 status=0
97 exit