overlay/075: fix wrong invocation of t_immutable
[xfstests-dev.git] / tests / overlay / 021
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test 021
6 #
7 # Test concurrent copy up
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 # real QA test starts here
32 _supported_fs overlay
33 _require_scratch
34
35 # Remove all files from previous tests
36 _scratch_mkfs
37
38 # overlay copy_up doesn't deal with sparse file well, holes will be filled by
39 # zeros, so for the worst case of hitting all the copy up bomb files, we need
40 # (64*(16+32+64+128)M) free space on $OVL_BASE_SCRATCH_MNT.
41 # However, triggering more than a total of 16 copy up bombs would require
42 # really fast data copy (clone up doesn't take up space at all), so let's be
43 # conservative and reserve space for 16 data copy ups per directory.
44 _require_fs_space $OVL_BASE_SCRATCH_MNT $((16*(16+32+64+128)*1024))
45
46 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
47 mkdir -p $lowerdir
48
49 testdir=arena
50 d_low=$lowerdir/$testdir
51 mkdir -p $d_low
52
53 # Create 4K empty files in 4 directories
54 echo $FSSTRESS_PROG -d $d_low -p 4 -z -f creat=1 -n 1024 -v >> $seqres.full
55 $FSSTRESS_PROG -d $d_low -p 4 -z -f creat=1 -n 1024 -v >> $seqres.full 2>&1
56 echo "--------------------------------------"       >> $seqres.full
57 echo "Created 1K files in lower directory.  "       >> $seqres.full
58
59 # Plant 64 copy up bombs in each directory
60 for f in $d_low/p0/*0; do $XFS_IO_PROG -c "truncate 128m" $f ;done
61 for f in $d_low/p1/*4; do $XFS_IO_PROG -c "truncate 64m" $f ;done
62 for f in $d_low/p2/*8; do $XFS_IO_PROG -c "truncate 32m" $f ;done
63 for f in $d_low/p3/*b; do $XFS_IO_PROG -c "truncate 16m" $f ;done
64 echo "Created 64*4 copy up bombs.           "       >> $seqres.full
65 echo "--------------------------------------"       >> $seqres.full
66
67 _scratch_mount
68
69 d_top=$SCRATCH_MNT/$testdir
70
71 #
72 # Run 2 process teams - 4 pairs of rival processes
73 # Each process pair competing on copy up of 1K files in 1 directory.
74 # Team 'touch' players touch all files in readdir order.
75 # Team 'truncate' players truncates all files in numeric (name) order.
76 #
77 # If player from team 'touch' reaches a copy up bomb before player
78 # from team 'truncate' does, the copy up of (sparse) data will delay
79 # the end of the process pair match.
80 #
81 # If copy up of bomb is not concurrent with other copy ups, then
82 # 'touch' player p0 with the largest copy up bombs will delay players
83 # of both teams and all matches will take longer.
84 #
85 # If copy up is concurrent with copy ups in different directories,
86 # process pair 3 match will be over first and process pair 0 match
87 # will be over last.
88 #
89 # If copy up of data is concurrent with other copy ups on the same directory,
90 # then all the 'touch' team players will finish far behind their 'truncate'
91 # opponenets.
92 #
93 # This test doesn't verify any of those conditions, it will only fail
94 # on unexpected errors of any of the touch/truncate operations.
95 # The test full output should demonstrate the expected game results,
96 # as described above and depending on concurrent copy up support in kernel.
97 #
98 cd $d_top
99 echo "--------------------------------------"       >> $seqres.full
100 echo "Go team touch!!                       "       >> $seqres.full
101 find p0 -type f -print -exec touch {} \; >> $seqres.full &
102 find p1 -type f -print -exec touch {} \; >> $seqres.full &
103 find p2 -type f -print -exec touch {} \; >> $seqres.full &
104 find p3 -type f -print -exec touch {} \; >> $seqres.full &
105 cd - > /dev/null
106
107 echo "--------------------------------------"       >> $seqres.full
108 echo "Go team truncate!!                    "       >> $seqres.full
109 # Give team 'touch' a 1 second head start.
110 # Team 'truncate' players should catch up after few copy up bombs.
111 sleep 1
112 $FSSTRESS_PROG -d $d_top -p 4 -z -f creat=1 -n 1024 -v >> $seqres.full &
113
114 wait %1 %2 %3 %4 %5
115
116 echo "Silence is golden"
117 status=0
118 exit