2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc. All Rights Reserved.
7 # Make sure that the reference counting mechanism can handle the case
8 # where we share the first 1/4 of an extent with a file, share the
9 # last 1/4 of the extent with a second file, share the first half of
10 # the extent with N files, and share the second half of the extent
11 # with a different set of N files. The key point here is to test that
12 # we handle the case where a refcount extent record doesn't coincide
13 # exactly with the block mapping records.
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 7 15
31 # get standard environment, filters and checks
36 # real QA test starts here
37 _require_scratch_reflink
39 echo "Format and mount"
40 _scratch_mkfs > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
43 testdir=$SCRATCH_MNT/test-$seq
49 halfway=$((blocks / 2 * blksz))
50 quarter=$((blocks / 4 * blksz))
52 echo "Initialize file"
53 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
55 echo "Share the first half of the extent"
56 seq 1 $nr | while read nr; do
57 _reflink_range $testdir/file 0 $testdir/file$nr.0 0 $halfway >> $seqres.full
60 echo "Share the last half of the extent"
61 seq 1 $nr | while read nr; do
62 _reflink_range $testdir/file $halfway $testdir/file$nr.1 0 $halfway >> $seqres.full
65 echo "Share the first quarter of the extent"
66 _reflink_range $testdir/file 0 $testdir/file.2 0 $quarter >> $seqres.full
68 echo "Share the last quarter of the extent"
69 _reflink_range $testdir/file $((quarter * 3)) $testdir/file.3 0 $quarter >> $seqres.full
74 md5sum $testdir/file $testdir/file* | _filter_scratch