generic: test for non-zero used blocks while writing into a file
[xfstests-dev.git] / tests / btrfs / 166
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 166
6 #
7 # Test that if a power failure happens on a filesystem with quotas (qgroups)
8 # enabled while the quota rescan kernel thread is running, we will be able
9 # to mount the filesystem after the power failure.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         _cleanup_flakey
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/dmflakey
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_scratch
33 _require_dm_target flakey
34
35 rm -f $seqres.full
36
37 _scratch_mkfs  >>$seqres.full 2>&1
38 _require_metadata_journaling $SCRATCH_DEV
39 _init_flakey
40 _mount_flakey
41
42 # Enable qgroups on the filesystem. This will start the qgroup rescan kernel
43 # thread.
44 _run_btrfs_util_prog quota enable $SCRATCH_MNT
45
46 # Simulate a power failure, while the qgroup rescan kernel thread is running,
47 # and then mount the filesystem to check that mounting the filesystem does not
48 # fail.
49 _flakey_drop_and_remount
50
51 _unmount_flakey
52 _cleanup_flakey
53
54 echo "Silence is golden"
55 status=0
56 exit