generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 193
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test btrfs/193
6 #
7 # Test if btrfs is going to leak qgroup reserved data space when
8 # falloc on multiple holes fails.
9 # The fix is titled:
10 # "btrfs: qgroup: Fix the wrong target io_tree when freeing reserved data space"
11 #
12 . ./common/preamble
13 _begin_fstest auto quick qgroup enospc limit prealloc
14
15 # Import common functions.
16 . ./common/filter
17
18 # real QA test starts here
19
20 # Modify as appropriate.
21 _supported_fs btrfs
22 _require_scratch
23 _require_xfs_io_command falloc
24
25 _scratch_mkfs > /dev/null
26 _scratch_mount
27
28 $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
29 _qgroup_rescan "$SCRATCH_MNT" > /dev/null
30 $BTRFS_UTIL_PROG qgroup limit -e 256M "$SCRATCH_MNT"
31
32 # Create a file with the following layout:
33 # 0         128M      256M      384M
34 # |  Hole   |4K| Hole |4K| Hole |
35 # The total hole size will be 384M - 8k
36 truncate -s 384m "$SCRATCH_MNT/file"
37 $XFS_IO_PROG -c "pwrite 128m 4k" -c "pwrite 256m 4k" \
38         "$SCRATCH_MNT/file" | _filter_xfs_io
39
40 # Falloc 0~384M range, it's going to fail due to the qgroup limit
41 $XFS_IO_PROG -c "falloc 0 384m" "$SCRATCH_MNT/file" | _filter_xfs_io_error
42 rm -f "$SCRATCH_MNT/file"
43
44 # Ensure above delete reaches disk and free some space
45 sync
46
47 # We should be able to write at least 3/4 of the limit
48 $XFS_IO_PROG -f -c "pwrite 0 192m" "$SCRATCH_MNT/file" | _filter_xfs_io
49
50 # success, all done
51 status=0
52 exit