6e89fe35b2de1b9309e2cc9e625db8fc3506f547
[xfstests-dev.git] / tests / xfs / 140
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 140
6 #
7 # Try to ENOSPC while expanding the refcntbt by CoWing every other block
8 # of a file that eats the whole AG.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
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 -rf $tmp.* $testdir
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_os Linux
32 _require_scratch_reflink
33 _require_cp_reflink
34
35 rm -f $seqres.full
36
37 echo "Format and mount"
38 _scratch_mkfs -d agsize=$((32 * 1048576)) > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
40
41 testdir=$SCRATCH_MNT/test-$seq
42 mkdir $testdir
43 blksz=$(_get_block_size $testdir)
44
45 echo "Create the original files"
46 sz=$((48 * 1048576))
47 nr=$((sz / blksz))
48 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
49 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
50 _pwrite_byte 0x61 0 $sz $testdir/file2.chk >> $seqres.full
51 _scratch_cycle_mount
52
53 echo "Compare files"
54 cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 do not match"
55 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
56
57 echo "CoW every other block"
58 seq 1 2 $((nr - 1)) | while read f; do
59         _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2 >> $seqres.full
60         _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2.chk >> $seqres.full
61 done
62 _scratch_cycle_mount
63
64 echo "Compare files"
65 ! cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 must not match"
66 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
67
68 # success, all done
69 status=0
70 exit