generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 172
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. 172
6 #
7 # Reflink a file that uses more than half of the space, then try to observe
8 # ENOSPC while copy-on-writing the file via the page cache.
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.* $testdir1
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/populate
28 . ./common/filter
29 . ./common/attr
30 . ./common/reflink
31
32 # real QA test starts here
33 _supported_os Linux
34 _require_scratch_reflink
35 _require_cp_reflink
36
37 rm -f $seqres.full
38
39 echo "Format and mount"
40 _scratch_mkfs > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
42
43 testdir=$SCRATCH_MNT/test-$seq
44 mkdir $testdir
45
46 echo "Reformat with appropriate size"
47 blksz="$(_get_block_size $testdir)"
48 umount $SCRATCH_MNT
49
50 file_size=$((768 * 1024 * 1024))
51 fs_size=$((1024 * 1024 * 1024))
52 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
53 _scratch_mount >> $seqres.full 2>&1
54 rm -rf $testdir
55 mkdir $testdir
56
57 echo "Create a big file and reflink it"
58 _pwrite_byte 0x61 0 $file_size $testdir/bigfile >> $seqres.full 2>&1
59 _cp_reflink $testdir/bigfile $testdir/clonefile
60 sync
61
62 echo "Allocate the rest of the space"
63 _fill_fs $fs_size  $testdir/space $blksz 0 >> $seqres.full 2>&1
64 sync
65
66 echo "CoW the big file"
67 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
68         _filter_xfs_io_error)"
69 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
70 echo ${out} >> $seqres.full 2>&1
71 echo ${out}
72
73 echo "Remount and try CoW again"
74 _scratch_cycle_mount
75
76 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
77         _filter_xfs_io_error)"
78 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
79 echo ${out} >> $seqres.full 2>&1
80 echo ${out}
81
82 # success, all done
83 status=0
84 exit