common: kill _supported_os
[xfstests-dev.git] / tests / btrfs / 102
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 102
6 #
7 # Regression test for an ENOSPC issue when attempting to write to a file in
8 # a filesystem without any data block groups allocated.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13 tmp=/tmp/$$
14 status=1        # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
16
17 _cleanup()
18 {
19         rm -f $tmp.*
20 }
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25
26 # real QA test starts here
27 _supported_fs btrfs
28 _require_scratch
29
30 rm -f $seqres.full
31
32 _scratch_mkfs >>$seqres.full 2>&1
33
34 # Mount our filesystem without space caches enabled so that we do not get any
35 # space used from the initial data block group that mkfs creates (space caches
36 # used space from data block groups).
37 _scratch_mount "-o nospace_cache"
38
39 # Need an fs with at least 2Gb to make sure mkfs.btrfs does not create an fs
40 # using mixed block groups (used both for data and metadata). We really need
41 # to have dedicated block groups for data to reproduce the issue and mkfs.btrfs
42 # defaults to mixed block groups only for small filesystems (up to 1Gb).
43 _require_fs_space $SCRATCH_MNT $((2 * 1024 * 1024))
44
45 # Run balance with the purpose of deleting the unused data block group that
46 # mkfs created. We could also wait for the background kthread to automatically
47 # delete the unused block group, but we do not have a way to make it run and
48 # wait for it to complete, so just do a balance instead of some unreliable sleep
49 _run_btrfs_balance_start -dusage=0 $SCRATCH_MNT >> $seqres.full
50
51 # Now unmount the filesystem, mount it again (either with or with space caches
52 # enabled, it does not matter to trigger the problem) and attempt to create a
53 # file with some data - this used to fail with ENOSPC because there were no
54 # data block groups when the filesystem was mounted and the data space info
55 # object was marked as full when initialized (because it had 0 total bytes),
56 # which prevented the file write path from attempting to allocate a data block
57 # group and fail immediately with ENOSPC.
58 _scratch_cycle_mount
59 echo "hello world" > $SCRATCH_MNT/foobar
60
61 echo "Silence is golden"
62 status=0
63 exit