summaryrefslogtreecommitdiff
path: root/tests/btrfs/255
blob: ee52873fe9cfbe44b6dfa216cb19494e9208142c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2022 Western Digital Corporation or its affiliates.
#
# FS QA Test No. btrfs/255
#
# Confirm that disabling quota during balance does not hang.
#
# The deadlock is fixed by kernel patch titled:
# btrfs: fix deadlock between quota disable and qgroup rescan worker
#
. ./common/preamble
_begin_fstest auto qgroup balance

_supported_fs btrfs
_require_scratch

_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount

# Fill 40% of the device or 2GB
fill_percent=40
max_fillsize=$((2 * 1024 * 1024 * 1024))

devsize=$(($(_get_device_size $SCRATCH_DEV) * 512))
fillsize=$((devsize * fill_percent / 100))
((fillsize > max_fillsize)) && fillsize=$max_fillsize

fs=$((4096 * 1024))
for ((i = 0; i * fs < fillsize; i++)); do
	dd if=/dev/zero of=$SCRATCH_MNT/file.$i bs=$fs count=1 \
	   >> $seqres.full 2>&1
done

# Run btrfs balance and quota enable/disable in parallel
_btrfs_stress_balance $SCRATCH_MNT >> $seqres.full &
balance_pid=$!
echo $balance_pid >> $seqres.full
for ((i = 0; i < 20; i++)); do
	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
done

_btrfs_kill_stress_balance_pid $balance_pid

echo "Silence is golden"
status=0
exit