#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 642
#
# Run an extended attributes fsstress run with multiple threads to shake out
# bugs in the xattr code.
#
. ./common/preamble
_begin_fstest auto soak attr long_rw stress smoketest

# Modify as appropriate.

_require_scratch

echo "Silence is golden."

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

nr_cpus=$((LOAD_FACTOR * 4))
nr_ops=$((70000 * TIME_FACTOR))

args=('-z' '-S' 'c')

# Do some directory tree modifications, but the bulk of this is geared towards
# exercising the xattr code, especially attr_set which can do up to 10k values.
for verb in unlink rmdir; do
	args+=('-f' "${verb}=1")
done
for verb in creat mkdir; do
	args+=('-f' "${verb}=2")
done
for verb in getfattr listfattr; do
	args+=('-f' "${verb}=3")
done
for verb in attr_remove removefattr; do
	args+=('-f' "${verb}=4")
done
args+=('-f' "setfattr=20")
args+=('-f' "attr_set=60")	# sets larger xattrs
test -n "$SOAK_DURATION" && args+=(--duration="$SOAK_DURATION")

_run_fsstress "${args[@]}" -d $SCRATCH_MNT -n $nr_ops -p $nr_cpus

# success, all done
status=0
exit
