Skip to content

Commit

Permalink
tests/bcachefs: make check_counters more robust
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Jan 6, 2024
1 parent db79c77 commit ef75fd0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/bcachefs/bcachefs-test-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,32 @@ bcachefs_antagonist()
#antagonist_switch_str_hash &
}

get_slowpath_counters()
{
local dev=$1

bcachefs show-super --field-only counters "$dev"|
grep -E '(fail|restart|blocked|full)'|
grep -vE '(path_relock_fail|mem_realloced)'|
grep -v ' 0$' || true
}

check_counters()
{
local dev=$1
local nr_commits=$(bcachefs show-super -f counters "$dev"|awk '/transaction_commit/ {print $2}')
local ratio=10
local ret=0

[[ -z $nr_commits ]] && return 0

[[ $# -ge 2 ]] && ratio=$2

local max_fail=$((nr_commits / ratio))

local counters=$(bcachefs show-super -f counters "$dev"|grep -E '(fail|restart|blocked)'|grep -v path_relock_fail|grep -v mem_realloced)
local counters=$(set +e; set +o pipefail; get_slowpath_counters $dev)

[[ -z $counters ]] && return 0

while IFS= read -r line; do
linea=($line)
Expand Down

0 comments on commit ef75fd0

Please sign in to comment.