xfs: no excessive warnings about dprecated mount options on remount
[xfstests-dev.git] / tests / xfs / 130
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 130
6 #
7 # Create and populate an XFS filesystem, corrupt the refcount btree,
8 # then see how the kernel and xfs_repair deal with it.
9 #
10 seq=`basename "$0"`
11 seqres="$RESULT_DIR/$seq"
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     #rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/attr
29 . ./common/reflink
30
31 # real QA test starts here
32 _supported_fs xfs
33 _require_scratch_reflink
34 _require_cp_reflink
35 test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
36
37 rm -f "$seqres.full"
38
39 echo "+ create scratch fs"
40 _scratch_mkfs_xfs > /dev/null
41
42 echo "+ mount fs image"
43 _scratch_mount
44 blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
45 agcount="$(_xfs_mount_agcount $SCRATCH_MNT)"
46
47 echo "+ make some files"
48 _pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full"
49 _pwrite_byte 0x61 0 $((blksz * 64)) "${SCRATCH_MNT}/file1" >> "$seqres.full"
50 _cp_reflink "${SCRATCH_MNT}/file0" "${SCRATCH_MNT}/file2"
51 _cp_reflink "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file3"
52 umount "${SCRATCH_MNT}"
53
54 echo "+ check fs"
55 _scratch_xfs_repair -n >> "$seqres.full" 2>&1 || \
56         _fail "xfs_repair should not fail"
57
58 echo "+ corrupt image"
59 seq 0 $((agcount - 1)) | while read ag; do
60         _scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr refcntroot" \
61                 -c "stack" -c "blocktrash -x 4096 -y 4096 -z -n 8 -3" \
62                 >> "$seqres.full" 2>&1
63 done
64
65 echo "+ mount image"
66 _try_scratch_mount >> $seqres.full 2>&1 && \
67         echo "Should not be able to mount with broken refcountbt."
68 _scratch_unmount >> $seqres.full 2>&1
69
70 echo "+ repair fs"
71 _disable_dmesg_check
72 _repair_scratch_fs >> "$seqres.full" 2>&1
73 _scratch_xfs_repair >> "$seqres.full" 2>&1
74
75 echo "+ mount image (2)"
76 _scratch_mount
77
78 echo "+ chattr -R -i"
79 $CHATTR_PROG -R -f -i "${SCRATCH_MNT}/"
80
81 echo "+ reflink more (2)"
82 _cp_reflink "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file5" || \
83         _fail "modified refcount tree"
84 umount "${SCRATCH_MNT}"
85
86 echo "+ check fs (2)"
87 _scratch_xfs_repair -n >> "$seqres.full" 2>&1 || \
88         _fail "xfs_repair should not fail"
89
90 status=0
91 exit