fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / generic / 103
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 103
6 #
7 # Test attribute fork teardown. This test is inspired by a regression in XFS
8 # that resulted in problematic removal of inodes with remote attribute forks
9 # without attribute extents. The attribute fork condition is created by
10 # attempting to set larger attribute values on a filesystem that is at or near
11 # ENOSPC.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 _cleanup()
18 {
19         cd /
20         rm -f $tmp.*
21 }
22
23 here=`pwd`
24 tmp=/tmp/$$
25 status=1        # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15 25
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/attr
31
32 # real QA test starts here
33 _supported_fs generic
34 _require_scratch
35 _require_attrs
36 _require_xfs_io_command "falloc"
37
38 rm -f $seqres.full
39
40 _consume_freesp()
41 {
42         file=$1
43
44         # consume nearly all available space (leave ~512kB)
45         avail=`_get_available_space $SCRATCH_MNT`
46         filesizekb=$((avail / 1024 - 512))
47         $XFS_IO_PROG -fc "falloc 0 ${filesizekb}k" $file
48 }
49
50 _scratch_mkfs >> $seqres.full 2>&1
51 _scratch_mount
52
53 for i in $(seq 0 63); do
54         touch $SCRATCH_MNT/$seq.$i
55 done
56
57 # Generate a large attribute value and consume the rest of the space in the
58 # filesystem.
59 $XFS_IO_PROG -fc "pwrite 0 64k" $SCRATCH_MNT/attrval > /dev/null 2>&1
60 _consume_freesp $SCRATCH_MNT/spc
61
62 # Set attributes on the test files. These should start to hit ENOSPC.
63 for i in $(seq 0 63); do
64         $SETFATTR_PROG -n user.test -v "`cat $SCRATCH_MNT/attrval`" \
65                 $SCRATCH_MNT/$seq.$i >> $seqres.full 2>&1
66 done
67
68 # Remove the files with attributes to test attribute fork teardown. Problems
69 # result in dmesg output.
70 rm -f $SCRATCH_MNT/$seq.*
71
72 echo Silence is golden.
73
74 status=0
75 exit