xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 435
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 435
6 #
7 # Ensure that we don't leak dquots when CoW recovery fails.
8 #
9 # Corrupt the refcount btree to ensure that the CoW garbage collection
10 # (and therefore the mount) fail.
11 #
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.
14 #
15 seq=`basename "$0"`
16 seqres="$RESULT_DIR/$seq"
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1    # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         rm -rf "$tmp".*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33 . ./common/attr
34 . ./common/reflink
35 . ./common/quota
36 . ./common/module
37
38 # real QA test starts here
39 _supported_os Linux
40 _supported_fs xfs
41 _require_loadable_fs_module "xfs"
42 _require_quota
43 _require_scratch_reflink
44 _require_cp_reflink
45
46 rm -f "$seqres.full"
47
48 echo "Format and mount"
49 _scratch_mkfs > "$seqres.full" 2>&1
50 _scratch_mount -o quota >> "$seqres.full" 2>&1
51
52 testdir="$SCRATCH_MNT/test-$seq"
53 blksz=65536
54 blks=3
55 mkdir "$testdir"
56
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
61
62 echo "Remount to check recovery" | tee /dev/ttyprintk
63 _scratch_unmount
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
69
70 echo "See if we leak"
71 _reload_fs_module "xfs"
72
73 # success, all done
74 status=0
75 exit