xfs: test running growfs on the realtime volume
[xfstests-dev.git] / tests / xfs / 521
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 521
6 #
7 # Tests xfs_growfs on the realtime volume to make sure none of it blows up.
8 # This is a regression test for the following patches:
9 #
10 # xfs: Set xfs_buf type flag when growing summary/bitmap files
11 # xfs: Set xfs_buf's b_ops member when zeroing bitmap/summary files
12 # xfs: fix realtime bitmap/summary file truncation when growing rt volume
13 # xfs: make xfs_growfs_rt update secondary superblocks
14 # xfs: annotate grabbing the realtime bitmap/summary locks in growfs
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1    # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         _scratch_unmount >> $seqres.full 2>&1
29         test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1
30         rm -f $tmp.* $TEST_DIR/$seq.rtvol
31 }
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36
37 # real QA test starts here
38 _supported_fs xfs
39 # Note that we don't _require_realtime because we synthesize a rt volume
40 # below.
41 _require_scratch_nocheck
42 _require_no_large_scratch_dev
43
44 echo "Create fake rt volume"
45 truncate -s 400m $TEST_DIR/$seq.rtvol
46 rtdev=$(_create_loop_device $TEST_DIR/$seq.rtvol)
47
48 echo "Format and mount 100m rt volume"
49 export USE_EXTERNAL=yes
50 export SCRATCH_RTDEV=$rtdev
51 _scratch_mkfs -r size=100m > $seqres.full
52 _scratch_mount || _notrun "Could not mount scratch with synthetic rt volume"
53
54 testdir=$SCRATCH_MNT/test-$seq
55 mkdir $testdir
56
57 echo "Check rt volume stats"
58 $XFS_IO_PROG -c 'chattr +t' $testdir
59 $XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full
60 before=$(stat -f -c '%b' $testdir)
61
62 echo "Create some files"
63 _pwrite_byte 0x61 0 1m $testdir/original >> $seqres.full
64
65 echo "Grow fs"
66 $XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 |  _filter_growfs >> $seqres.full
67 _scratch_cycle_mount
68
69 echo "Recheck 400m rt volume stats"
70 $XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full
71 after=$(stat -f -c '%b' $testdir)
72 _within_tolerance "rt volume size" $after $((before * 4)) 5% -v
73
74 echo "Create more copies to make sure the bitmap really works"
75 cp -p $testdir/original $testdir/copy3
76
77 echo "Check filesystem"
78 _check_xfs_filesystem $SCRATCH_DEV none $rtdev
79
80 # success, all done
81 status=0
82 exit