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
38 _require_scratch_reflink
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _scratch_mount >> $seqres.full 2>&1
44 testdir=$SCRATCH_MNT/test-$seq
50 halfway=$((blocks / 2 * blksz))
51 quarter=$((blocks / 4 * blksz))
53 echo "Initialize file"
54 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
56 echo "Share the first half of the extent"
57 seq 1 $nr | while read nr; do
58 _reflink_range $testdir/file 0 $testdir/file$nr.0 0 $halfway >> $seqres.full
61 echo "Share the last half of the extent"
62 seq 1 $nr | while read nr; do
63 _reflink_range $testdir/file $halfway $testdir/file$nr.1 0 $halfway >> $seqres.full
66 echo "Share the first quarter of the extent"
67 _reflink_range $testdir/file 0 $testdir/file.2 0 $quarter >> $seqres.full
69 echo "Share the last quarter of the extent"
70 _reflink_range $testdir/file $((quarter * 3)) $testdir/file.3 0 $quarter >> $seqres.full
75 md5sum $testdir/file $testdir/file* | _filter_scratch