1444444db98a77599a6d039e05a4b16ebddb7e67
[xfstests-dev.git] / tests / xfs / 139
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. 139
6 #
7 # Try to ENOSPC while expanding the refcntbt by CoWing every 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 # Below agsize (16384 * $blksz) is too small for a large fs, and it's not
32 # necessary to test on large fs
33 _require_no_large_scratch_dev
34 _require_scratch_reflink
35 _require_cp_reflink
36
37 rm -f $seqres.full
38
39 _scratch_mkfs >/dev/null 2>&1
40 _scratch_mount
41 blksz=$(_get_file_block_size $SCRATCH_MNT)
42 _scratch_unmount
43
44 echo "Format and mount"
45 _scratch_mkfs -d agsize=$((16384 * $blksz)) > $seqres.full 2>&1
46 _scratch_mount >> $seqres.full 2>&1
47
48 testdir=$SCRATCH_MNT/test-$seq
49 mkdir $testdir
50
51 echo "Create the original files"
52 sz=$((20480 * $blksz))
53 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
54 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
55 _scratch_cycle_mount
56
57 echo "CoW every other block"
58 _pwrite_byte 0x62 0 $sz $testdir/file1 >> $seqres.full
59 _scratch_cycle_mount
60
61 echo "Compare files"
62 od -t x1 $testdir/file1 | _filter_od
63 od -t x1 $testdir/file2 | _filter_od
64 #filefrag -v $testdir/file1 $testdir/file2
65
66 # success, all done
67 status=0
68 exit