blob: 068e6e8e4e95668f11bcf8598cb1e766d1c628a5 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test 181
#
# Test if btrfs will commit too many transactions for nothing and cause
# performance regression during balance.
#
# This bug is going to be fixed by a patch for kernel title
# "btrfs: don't end the transaction for delayed refs in throttle"
#
. ./common/preamble
_begin_fstest auto quick balance
. ./common/filter
_supported_fs btrfs
_require_scratch
_require_btrfs_command inspect-internal dump-super
_scratch_mkfs > /dev/null
_scratch_mount
nr_files=1024
get_super_gen()
{
local ret=$($BTRFS_UTIL_PROG inspect dump-super "$SCRATCH_DEV" |\
grep ^generation | $AWK_PROG '{print $2}')
if [ -z $ret ]; then
_fail "failed to get super block generation"
fi
echo "$ret"
}
$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/subvol" > /dev/null
# Create some small files to take up enough metadata reserved space
for ((i = 0; i < $nr_files; i++)) do
_pwrite_byte 0xcd 0 1K "$SCRATCH_MNT/subvol/file_$i" > /dev/null
done
# Commit the fs so we can get a stable super generation
sync
before_gen=$(get_super_gen)
_run_btrfs_balance_start -m $SCRATCH_MNT >> $seqres.full
after_gen=$(get_super_gen)
# Since the fs is pretty small, we should have only 1 small metadata chunk and
# one tiny system chunk.
# Relocating such small chunks only needs 6 commits for each, thus 12 commits for
# 2 chunks.
# Here we use 10x the theoretic value as threshold.
theoretic_gen=$(( 6 * 2 ))
threshold_gen=$(( 10 * $theoretic_gen ))
if [ $(( $after_gen - $before_gen )) -gt 120 ]; then
echo "balance committed too many transactions"
echo "super generation before balance: ${before_gen}"
echo "super generation after balance: ${after_gen}"
echo "super generation difference: $((after_gen - before_gen))"
echo "theoretic generation difference: ${theoretic_gen}"
echo "threshold generation difference: ${threshold_gen}"
fi
echo "super generation before balance: ${before_gen}" >> $seqres.full
echo "super generation after balance: ${after_gen}" >> $seqres.full
echo "super generation difference: $((after_gen - before_gen))" >> $seqres.full
echo "theoretic generation difference: ${theoretic_gen}" >> $seqres.full
echo "threshold generation difference: ${threshold_gen}" >> $seqres.full
# success, all done
echo "Silence is golden"
status=0
exit
|