4 # See how well reflink handles overflowing reflink counts.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
24 seqres=$RESULT_DIR/$seq
25 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
44 # real QA test starts here
47 _require_scratch_reflink
48 _require_scratch_nocheck
50 _require_test_program "punch-alternating"
54 echo "Format and mount"
55 _scratch_mkfs -d agcount=1 > $seqres.full 2>&1
56 _scratch_mount >> $seqres.full 2>&1
58 testdir=$SCRATCH_MNT/test-$seq
63 echo "Create original files"
64 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
65 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
67 echo "Change reference count"
69 echo "set refcount to -4" >> $seqres.full
70 _scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c 'write recs[1].refcount 4294967292' >> $seqres.full
71 echo "check refcount after setting to -4" >> $seqres.full
72 _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
73 _scratch_mount >> $seqres.full
75 echo "Reflink the overlinked file"
76 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
77 _cp_reflink $testdir/file1 $testdir/file4 >> $seqres.full
78 _cp_reflink $testdir/file1 $testdir/file5 >> $seqres.full
79 _cp_reflink $testdir/file1 $testdir/file6 >> $seqres.full
80 _cp_reflink $testdir/file1 $testdir/file7 >> $seqres.full
82 echo "Check scratch fs"
84 echo "check refcount after reflinking 5 more times" >> $seqres.full
85 _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
86 _scratch_mount >> $seqres.full
88 echo "CoW a couple files"
89 _pwrite_byte 0x62 0 $blksz $testdir/file3 >> $seqres.full
90 _pwrite_byte 0x62 0 $blksz $testdir/file5 >> $seqres.full
91 _pwrite_byte 0x62 0 $blksz $testdir/file7 >> $seqres.full
93 echo "Check scratch fs"
95 echo "check refcount after cowing 3 files" >> $seqres.full
96 _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
97 _scratch_mount >> $seqres.full
99 echo "Remove reflinked files"
100 rm -rf $testdir/file*
102 echo "Check scratch fs"
104 echo "check refcount after removing all files" >> $seqres.full
105 _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
106 _scratch_xfs_repair -o force_geometry -n >> $seqres.full 2>&1
108 if [ $res -eq 0 ]; then
109 # If repair succeeds then format the device so that the post-test
110 # check doesn't fail due to the single AG.
111 _scratch_mkfs >> $seqres.full 2>&1
113 _fail "xfs_repair fails"