generic: test adding filesystem-level fscrypt key via key_id
[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 _supported_os Linux
35 _require_scratch
36 _require_attrs
37 _require_xfs_io_command "falloc"
38
39 rm -f $seqres.full
40
41 _consume_freesp()
42 {
43         file=$1
44
45         # consume nearly all available space (leave ~512kB)
46         avail=`_get_available_space $SCRATCH_MNT`
47         filesizekb=$((avail / 1024 - 512))
48         $XFS_IO_PROG -fc "falloc 0 ${filesizekb}k" $file
49 }
50
51 _scratch_mkfs >> $seqres.full 2>&1
52 _scratch_mount
53
54 for i in $(seq 0 63); do
55         touch $SCRATCH_MNT/$seq.$i
56 done
57
58 # Generate a large attribute value and consume the rest of the space in the
59 # filesystem.
60 $XFS_IO_PROG -fc "pwrite 0 64k" $SCRATCH_MNT/attrval > /dev/null 2>&1
61 _consume_freesp $SCRATCH_MNT/spc
62
63 # Set attributes on the test files. These should start to hit ENOSPC.
64 for i in $(seq 0 63); do
65         $SETFATTR_PROG -n user.test -v "`cat $SCRATCH_MNT/attrval`" \
66                 $SCRATCH_MNT/$seq.$i >> $seqres.full 2>&1
67 done
68
69 # Remove the files with attributes to test attribute fork teardown. Problems
70 # result in dmesg output.
71 rm -f $SCRATCH_MNT/$seq.*
72
73 echo Silence is golden.
74
75 status=0
76 exit