generic/520: Remove sync in clean_dir
[xfstests-dev.git] / tests / generic / 161
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 161
6 #
7 # Test for race between delete a file while rewriting its reflinked twin
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 7 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.*
22     wait
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_scratch_reflink
33 _require_cp_reflink
34
35 echo "Format and mount"
36 _scratch_mkfs > $seqres.full 2>&1
37 _scratch_mount >> $seqres.full 2>&1
38
39 testdir=$SCRATCH_MNT/test-$seq
40 mkdir $testdir
41
42 loops=4096
43 blksz=65536
44
45 echo "Initialize files"
46 echo >> $seqres.full
47 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
48 _cp_reflink $testdir/file1 $testdir/file2
49 _scratch_cycle_mount
50
51 echo "Delete while rewriting"
52 rm -rf $testdir/file1 &
53 _pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
54 wait
55
56 # success, all done
57 status=0
58 exit