2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that we don't leak dquots when CoW recovery fails.
9 # Corrupt the refcount btree to ensure that the CoW garbage collection
10 # (and therefore the mount) fail.
12 # On a subsequent mount attempt, we should be able to release the quota
13 # inodes when we're aborting the mount. We also should not leak dquots.
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 15
30 # get standard environment, filters and checks
38 # real QA test starts here
40 _require_loadable_fs_module "xfs"
42 _require_scratch_reflink
48 echo "Format and mount"
49 _scratch_mkfs > "$seqres.full" 2>&1
50 _scratch_mount -o quota >> "$seqres.full" 2>&1
52 testdir="$SCRATCH_MNT/test-$seq"
57 echo "Create a many-block file"
58 _pwrite_byte 0x62 0 $((blksz * blks)) $testdir/file1 >> $seqres.full
59 _pwrite_byte 0x63 0 $blksz $testdir/file2 >> $seqres.full
60 _reflink_range $testdir/file2 0 $testdir/file1 $blksz $blksz >> $seqres.full
62 echo "Remount to check recovery" | tee /dev/ttyprintk
64 _scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c 'fuzz -d recs[1].startblock ones' >> $seqres.full
65 _scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c p >> $seqres.full
66 _try_scratch_mount -o quota >> $seqres.full 2>&1
67 _scratch_unmount 2> /dev/null
68 rm -f ${RESULT_DIR}/require_scratch
71 _reload_fs_module "xfs"