2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Plexistor Ltd. All Rights Reserved.
7 # test for races between write or fpunch operations on reflinked files
8 # to read operations on the target file
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=0 # success is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
35 _require_scratch_reflink
38 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
39 _scratch_mount || _fail "mount failed"
40 _require_fs_space $SCRATCH_MNT $((250 * 1024))
42 echo "Silence is golden"
44 workfile=${SCRATCH_MNT}/workfile
45 light_clone=${SCRATCH_MNT}/light_clone
47 file_size=$((10 * 1024 * 1024))
48 bs=`_get_block_size $SCRATCH_MNT`
49 block_num=$((file_size / bs))
52 $XFS_IO_PROG -f -c "pwrite 0 $file_size" $workfile >> $seqres.full
54 for ((i=1; i<=reflinks_num; i++)); do
55 _cp_reflink $workfile ${light_clone}_$i
58 # for each block simultaneously pwrite (or fpunch) all reflinks
59 # while performing pread from the targted file
60 for ((block_index=0; block_index<block_num; block_index++)); do
61 for ((i=1; i<=reflinks_num; i++)); do
62 $XFS_IO_PROG -c "pread $((block_index * bs)) $bs" \
63 $workfile >> $seqres.full &
64 if [ $((block_index % 2)) -eq 0 ]; then
65 $XFS_IO_PROG -c "pwrite $((block_index * bs)) $bs" \
66 ${light_clone}_$i >> $seqres.full &
68 $XFS_IO_PROG -c "fpunch $((block_index * bs)) $bs" \
69 ${light_clone}_$i >> $seqres.full &
72 # wait for all threads to join before moving to next block