overlay/029: fix test failure with nfs_export feature enabled
[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 _supported_os Linux
34 _require_scratch
35
36 # Remove all files from previous tests
37 _scratch_mkfs
38
39 # overlay copy_up doesn't deal with sparse file well, holes will be filled by
40 # zeros, so for the worst case of hitting all the copy up bomb files, we need
41 # (64*(16+32+64+128)M) free space on $OVL_BASE_SCRATCH_MNT.
42 # However, triggering more than a total of 16 copy up bombs would require
43 # really fast data copy (clone up doesn't take up space at all), so let's be
44 # conservative and reserve space for 16 data copy ups per directory.
45 _require_fs_space $OVL_BASE_SCRATCH_MNT $((16*(16+32+64+128)*1024))
46
47 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
48 mkdir -p $lowerdir
49
50 testdir=arena
51 d_low=$lowerdir/$testdir
52 mkdir -p $d_low
53
54 # Create 4K empty files in 4 directories
55 echo $FSSTRESS_PROG -d $d_low -p 4 -z -f creat=1 -n 1024 -v >> $seqres.full
56 $FSSTRESS_PROG -d $d_low -p 4 -z -f creat=1 -n 1024 -v >> $seqres.full 2>&1
57 echo "--------------------------------------"       >> $seqres.full
58 echo "Created 1K files in lower directory.  "       >> $seqres.full
59
60 # Plant 64 copy up bombs in each directory
61 for f in $d_low/p0/*0; do $XFS_IO_PROG -c "truncate 128m" $f ;done
62 for f in $d_low/p1/*4; do $XFS_IO_PROG -c "truncate 64m" $f ;done
63 for f in $d_low/p2/*8; do $XFS_IO_PROG -c "truncate 32m" $f ;done
64 for f in $d_low/p3/*b; do $XFS_IO_PROG -c "truncate 16m" $f ;done
65 echo "Created 64*4 copy up bombs.           "       >> $seqres.full
66 echo "--------------------------------------"       >> $seqres.full
67
68 _scratch_mount
69
70 d_top=$SCRATCH_MNT/$testdir
71
72 #
73 # Run 2 process teams - 4 pairs of rival processes
74 # Each process pair competing on copy up of 1K files in 1 directory.
75 # Team 'touch' players touch all files in readdir order.
76 # Team 'truncate' players truncates all files in numeric (name) order.
77 #
78 # If player from team 'touch' reaches a copy up bomb before player
79 # from team 'truncate' does, the copy up of (sparse) data will delay
80 # the end of the process pair match.
81 #
82 # If copy up of bomb is not concurrent with other copy ups, then
83 # 'touch' player p0 with the largest copy up bombs will delay players
84 # of both teams and all matches will take longer.
85 #
86 # If copy up is concurrent with copy ups in different directories,
87 # process pair 3 match will be over first and process pair 0 match
88 # will be over last.
89 #
90 # If copy up of data is concurrent with other copy ups on the same directory,
91 # then all the 'touch' team players will finish far behind their 'truncate'
92 # opponenets.
93 #
94 # This test doesn't verify any of those conditions, it will only fail
95 # on unexpected errors of any of the touch/truncate operations.
96 # The test full output should demonstrate the expected game results,
97 # as described above and depending on concurrent copy up support in kernel.
98 #
99 cd $d_top
100 echo "--------------------------------------"       >> $seqres.full
101 echo "Go team touch!!                       "       >> $seqres.full
102 find p0 -type f -print -exec touch {} \; >> $seqres.full &
103 find p1 -type f -print -exec touch {} \; >> $seqres.full &
104 find p2 -type f -print -exec touch {} \; >> $seqres.full &
105 find p3 -type f -print -exec touch {} \; >> $seqres.full &
106 cd - > /dev/null
107
108 echo "--------------------------------------"       >> $seqres.full
109 echo "Go team truncate!!                    "       >> $seqres.full
110 # Give team 'touch' a 1 second head start.
111 # Team 'truncate' players should catch up after few copy up bombs.
112 sleep 1
113 $FSSTRESS_PROG -d $d_top -p 4 -z -f creat=1 -n 1024 -v >> $seqres.full &
114
115 wait %1 %2 %3 %4 %5
116
117 echo "Silence is golden"
118 status=0
119 exit