generic: test file writers racing with FIDEDUPERANGE
[xfstests-dev.git] / tests / generic / 630
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 630
6 #
7 # Make sure that mmap and file writers racing with FIDEDUPERANGE cannot write
8 # to the file after the dedupe prep function has decided that the file contents
9 # are identical and we can therefore go ahead with the remapping.
10
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_fs generic
32 _require_scratch_dedupe
33 _require_test_program "deduperace"
34
35 rm -f $seqres.full
36
37 nr_ops=$((TIME_FACTOR * 10000))
38
39 # Format filesystem
40 _scratch_mkfs > $seqres.full
41 _scratch_mount
42
43 # Test once with mmap writes
44 $here/src/deduperace -c $SCRATCH_MNT -n $nr_ops
45
46 # Test again with pwrites for the lulz
47 $here/src/deduperace -c $SCRATCH_MNT -n $nr_ops -w
48
49 echo Silence is golden.
50 # success, all done
51 status=0
52 exit