795f851dc6c8ac7b548e644cb06aeec7406fa7b5
[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 . ./common/preamble
14 _begin_fstest auto quick attr enospc
15
16 _register_cleanup "_cleanup" 25
17
18 # Import common functions.
19 . ./common/attr
20
21 # real QA test starts here
22 _supported_fs generic
23 _require_scratch
24 _require_attrs
25 _require_xfs_io_command "falloc"
26
27 _consume_freesp()
28 {
29         file=$1
30
31         # consume nearly all available space (leave ~512kB)
32         avail=`_get_available_space $SCRATCH_MNT`
33         filesizekb=$((avail / 1024 - 512))
34         $XFS_IO_PROG -fc "falloc 0 ${filesizekb}k" $file
35 }
36
37 _scratch_mkfs >> $seqres.full 2>&1
38 _scratch_mount
39
40 for i in $(seq 0 63); do
41         touch $SCRATCH_MNT/$seq.$i
42 done
43
44 # Generate a large attribute value and consume the rest of the space in the
45 # filesystem.
46 $XFS_IO_PROG -fc "pwrite 0 64k" $SCRATCH_MNT/attrval > /dev/null 2>&1
47 _consume_freesp $SCRATCH_MNT/spc
48
49 # Set attributes on the test files. These should start to hit ENOSPC.
50 for i in $(seq 0 63); do
51         $SETFATTR_PROG -n user.test -v "`cat $SCRATCH_MNT/attrval`" \
52                 $SCRATCH_MNT/$seq.$i >> $seqres.full 2>&1
53 done
54
55 # Remove the files with attributes to test attribute fork teardown. Problems
56 # result in dmesg output.
57 rm -f $SCRATCH_MNT/$seq.*
58
59 echo Silence is golden.
60
61 status=0
62 exit