tests: remove udf/101
[xfstests-dev.git] / tests / generic / 174
1 #! /bin/bash
2 # FS QA Test No. 174
3 #
4 # Reflink a file, use up the rest of the space, then try to observe ENOSPC
5 # while copy-on-writing the file via direct-io.
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/populate
42 . ./common/filter
43 . ./common/attr
44 . ./common/reflink
45
46 # real QA test starts here
47 _supported_os Linux
48 _require_scratch_reflink
49 _require_cp_reflink
50 _require_odirect
51
52 rm -f $seqres.full
53
54 echo "Format and mount"
55 _scratch_mkfs > $seqres.full 2>&1
56 _scratch_mount >> $seqres.full 2>&1
57
58 testdir=$SCRATCH_MNT/test-$seq
59 mkdir $testdir
60
61 echo "Reformat with appropriate size"
62 blksz="$(_get_block_size $testdir)"
63 nr_blks=10240
64 umount $SCRATCH_MNT
65 sz_bytes=$((nr_blks * 8 * blksz))
66 if [ $sz_bytes -lt $((32 * 1048576)) ]; then
67         sz_bytes=$((32 * 1048576))
68 fi
69 _scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1
70 _scratch_mount >> $seqres.full 2>&1
71 rm -rf $testdir
72 mkdir $testdir
73
74 echo "Create a big file and reflink it"
75 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/bigfile >> $seqres.full 2>&1
76 _cp_reflink $testdir/bigfile $testdir/clonefile
77 sync
78
79 echo "Allocate the rest of the space"
80 nr_free=$(stat -f -c '%f' $testdir)
81 _fill_fs $((blksz * nr_free)) $testdir/space $blksz 0 >> $seqres.full 2>&1
82 sync
83
84 echo "CoW the big file"
85 out="$(_pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/bigfile -d 2>&1 | \
86         _filter_xfs_io_error)"
87 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
88 echo ${out} >> $seqres.full 2>&1
89 echo ${out}
90
91 echo "Remount and try CoW again"
92 _scratch_cycle_mount
93
94 out="$(_pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/bigfile -d 2>&1 | \
95         _filter_xfs_io_error)"
96 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
97 echo ${out} >> $seqres.full 2>&1
98 echo ${out}
99
100 # success, all done
101 status=0
102 exit