From: Darrick J. Wong <djwong@xxxxxxxxxx> Refactor xfs/517 (which races fsstress with fsmap) to use our new control loop functions instead of open-coding everything. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- common/fuzzy | 30 +++++++++++++++++ tests/xfs/517 | 91 ++--------------------------------------------------- tests/xfs/517.out | 4 +- 3 files changed, 34 insertions(+), 91 deletions(-) diff --git a/common/fuzzy b/common/fuzzy index 3512e95e02..58e299d34b 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -362,6 +362,23 @@ __stress_scrub_freeze_loop() { done } +# Run individual xfs_io commands in a tight loop. +__stress_xfs_io_loop() { + local end="$1" + local runningfile="$2" + shift; shift + + local xfs_io_args=() + for arg in "$@"; do + xfs_io_args+=('-c' "$arg") + done + + while __stress_scrub_running "$end" "$runningfile"; do + $XFS_IO_PROG -x "${xfs_io_args[@]}" "$SCRATCH_MNT" \ + > /dev/null 2>> $seqres.full + done +} + # Run individual XFS online fsck commands in a tight loop with xfs_io. __stress_one_scrub_loop() { local end="$1" @@ -540,6 +557,10 @@ __stress_scrub_check_commands() { # # -f Run a freeze/thaw loop while we're doing other things. Defaults to # disabled, unless XFS_SCRUB_STRESS_FREEZE is set. +# -i Pass this command to xfs_io to exercise something that is not scrub +# in a separate loop. If zero -i options are specified, do not run. +# Callers must check each of these commands (via _require_xfs_io_command) +# before calling here. # -s Pass this command to xfs_io to test scrub. If zero -s options are # specified, xfs_io will not be run. # -t Run online scrub against this file; $SCRATCH_MNT is the default. @@ -555,15 +576,17 @@ _scratch_xfs_stress_scrub() { local freeze="${XFS_SCRUB_STRESS_FREEZE}" local scrub_delay="${XFS_SCRUB_STRESS_DELAY:--1}" local exerciser="fsstress" + local io_args=() __SCRUB_STRESS_FREEZE_PID="" rm -f "$runningfile" touch "$runningfile" OPTIND=1 - while getopts "fs:t:w:X:" c; do + while getopts "fi:s:t:w:X:" c; do case "$c" in f) freeze=yes;; + i) io_args+=("$OPTARG");; s) one_scrub_args+=("$OPTARG");; t) scrub_tgt="$OPTARG";; w) scrub_delay="$OPTARG";; @@ -595,6 +618,11 @@ _scratch_xfs_stress_scrub() { __SCRUB_STRESS_FREEZE_PID="$!" fi + if [ "${#io_args[@]}" -gt 0 ]; then + __stress_xfs_io_loop "$end" "$runningfile" \ + "${io_args[@]}" & + fi + if [ "${#one_scrub_args[@]}" -gt 0 ]; then __stress_one_scrub_loop "$end" "$runningfile" "$scrub_tgt" \ "$scrub_startat" "${one_scrub_args[@]}" & diff --git a/tests/xfs/517 b/tests/xfs/517 index 99fc89b05f..4481ba41da 100755 --- a/tests/xfs/517 +++ b/tests/xfs/517 @@ -11,29 +11,11 @@ _begin_fstest auto quick fsmap freeze _register_cleanup "_cleanup" BUS -# First kill and wait the freeze loop so it won't try to freeze fs again -# Then make sure fs is not frozen -# Then kill and wait for the rest of the workers -# Because if fs is frozen a killed writer will never exit -kill_loops() { - local sig=$1 - - [ -n "$freeze_pid" ] && kill $sig $freeze_pid - wait $freeze_pid - unset freeze_pid - $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT - [ -n "$stress_pid" ] && kill $sig $stress_pid - [ -n "$fsmap_pid" ] && kill $sig $fsmap_pid - wait - unset stress_pid - unset fsmap_pid -} - # Override the default cleanup function. _cleanup() { - kill_loops -9 > /dev/null 2>&1 cd / + _scratch_xfs_stress_scrub_cleanup rm -rf $tmp.* } @@ -46,78 +28,13 @@ _cleanup() _supported_fs xfs _require_xfs_scratch_rmapbt _require_xfs_io_command "fsmap" -_require_command "$KILLALL_PROG" killall -_require_freeze +_require_xfs_stress_scrub -echo "Format and populate" _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount - -STRESS_DIR="$SCRATCH_MNT/testdir" -mkdir -p $STRESS_DIR - -for i in $(seq 0 9); do - mkdir -p $STRESS_DIR/$i - for j in $(seq 0 9); do - mkdir -p $STRESS_DIR/$i/$j - for k in $(seq 0 9); do - echo x > $STRESS_DIR/$i/$j/$k - done - done -done - -cpus=$(( $(src/feature -o) * 4 * LOAD_FACTOR)) - -echo "Concurrent fsmap and freeze" -filter_output() { - grep -E -v '(Device or resource busy|Invalid argument)' -} -freeze_loop() { - end="$1" - - while [ "$(date +%s)" -lt $end ]; do - $XFS_IO_PROG -x -c 'freeze' $SCRATCH_MNT 2>&1 | filter_output - $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT 2>&1 | filter_output - done -} -fsmap_loop() { - end="$1" - - while [ "$(date +%s)" -lt $end ]; do - $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > /dev/null - done -} -stress_loop() { - end="$1" - - FSSTRESS_ARGS=$(_scale_fsstress_args -p 4 -d $SCRATCH_MNT -n 2000 $FSSTRESS_AVOID) - while [ "$(date +%s)" -lt $end ]; do - $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full - done -} - -start=$(date +%s) -end=$((start + (30 * TIME_FACTOR) )) - -echo "Loop started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full -stress_loop $end & -stress_pid=$! -freeze_loop $end & -freeze_pid=$! -fsmap_loop $end & -fsmap_pid=$! - -# Wait until 2 seconds after the loops should have finished... -while [ "$(date +%s)" -lt $((end + 2)) ]; do - sleep 1 -done - -# ...and clean up after the loops in case they didn't do it themselves. -kill_loops >> $seqres.full 2>&1 - -echo "Loop finished at $(date)" >> $seqres.full -echo "Test done" +_scratch_xfs_stress_scrub -i 'fsmap -v' # success, all done +echo "Silence is golden" status=0 exit diff --git a/tests/xfs/517.out b/tests/xfs/517.out index da6366e52b..49c53bcaa9 100644 --- a/tests/xfs/517.out +++ b/tests/xfs/517.out @@ -1,4 +1,2 @@ QA output created by 517 -Format and populate -Concurrent fsmap and freeze -Test done +Silence is golden