#! /bin/bash # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved. # # FS QA Test No. 179 # # See how well reflink handles overflowing reflink counts. # seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { cd / rm -rf $tmp.* } # get standard environment, filters and checks . ./common/rc . ./common/filter . ./common/attr . ./common/reflink # real QA test starts here _supported_fs xfs _require_scratch_reflink _require_scratch_nocheck _require_cp_reflink _require_test_program "punch-alternating" rm -f $seqres.full echo "Format and mount" _scratch_mkfs -d agcount=1 > $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 echo "Create original files" _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full echo "Change reference count" _scratch_unmount echo "set refcount to -4" >> $seqres.full _scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c 'write recs[1].refcount 4294967292' >> $seqres.full echo "check refcount after setting to -4" >> $seqres.full _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full _scratch_mount >> $seqres.full echo "Reflink the overlinked file" _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full _cp_reflink $testdir/file1 $testdir/file4 >> $seqres.full _cp_reflink $testdir/file1 $testdir/file5 >> $seqres.full _cp_reflink $testdir/file1 $testdir/file6 >> $seqres.full _cp_reflink $testdir/file1 $testdir/file7 >> $seqres.full echo "Check scratch fs" _scratch_unmount echo "check refcount after reflinking 5 more times" >> $seqres.full _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full _scratch_mount >> $seqres.full echo "CoW a couple files" _pwrite_byte 0x62 0 $blksz $testdir/file3 >> $seqres.full _pwrite_byte 0x62 0 $blksz $testdir/file5 >> $seqres.full _pwrite_byte 0x62 0 $blksz $testdir/file7 >> $seqres.full echo "Check scratch fs" _scratch_unmount echo "check refcount after cowing 3 files" >> $seqres.full _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full _scratch_mount >> $seqres.full echo "Remove reflinked files" rm -rf $testdir/file* echo "Check scratch fs" _scratch_unmount echo "check refcount after removing all files" >> $seqres.full _scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full _scratch_xfs_repair -o force_geometry -n >> $seqres.full 2>&1 res=$? if [ $res -eq 0 ]; then # If repair succeeds then format the device so that the post-test # check doesn't fail due to the single AG. _scratch_mkfs >> $seqres.full 2>&1 else _fail "xfs_repair fails" fi # success, all done status=0 exit