4 # Ensure that we don't leak dquots when CoW recovery fails.
6 # Corrupt the refcount btree to ensure that the CoW garbage collection
7 # (and therefore the mount) fail.
9 # On a subsequent mount attempt, we should be able to release the quota
10 # inodes when we're aborting the mount. We also should not leak dquots.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
30 seqres="$RESULT_DIR/$seq"
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
52 # real QA test starts here
55 _require_loadable_fs_module "xfs"
57 _require_scratch_reflink
62 echo "Format and mount"
63 _scratch_mkfs > "$seqres.full" 2>&1
64 _scratch_mount -o quota >> "$seqres.full" 2>&1
66 testdir="$SCRATCH_MNT/test-$seq"
71 echo "Create a many-block file"
72 _pwrite_byte 0x62 0 $((blksz * blks)) $testdir/file1 >> $seqres.full
73 _pwrite_byte 0x63 0 $blksz $testdir/file2 >> $seqres.full
74 _reflink_range $testdir/file2 0 $testdir/file1 $blksz $blksz >> $seqres.full
76 echo "Remount to check recovery" | tee /dev/ttyprintk
78 _scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c 'fuzz -d recs[1].startblock ones' >> $seqres.full
79 _scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c p >> $seqres.full
80 _scratch_mount -o quota >> $seqres.full 2>&1
81 _scratch_unmount 2> /dev/null
82 rm -f ${RESULT_DIR}/require_scratch
85 _reload_fs_module "xfs"