|
| 1 | +#! /bin/bash |
| 2 | +# SPDX-License-Identifier: GPL-2.0 |
| 3 | +# Copyright (c) 2019 YANDEX LLC. All Rights Reserved. |
| 4 | +# |
| 5 | +# FS QA Test 585 |
| 6 | +# |
| 7 | +# Check livelock during quota-sync while other tasks dirty quotas in parallel. |
| 8 | +# Run fchown(2) in a loop is the fastest way to produce dirty quotas |
| 9 | +# |
| 10 | +seq=`basename $0` |
| 11 | +seqres=$RESULT_DIR/$seq |
| 12 | +echo "QA output created by $seq" |
| 13 | + |
| 14 | +here=`pwd` |
| 15 | +tmp=/tmp/$$ |
| 16 | +status=1 # failure is the default! |
| 17 | +trap "_cleanup; exit \$status" 0 1 2 3 15 |
| 18 | + |
| 19 | +_cleanup() |
| 20 | +{ |
| 21 | + cd / |
| 22 | + rm -f $tmp.* |
| 23 | +} |
| 24 | +# get standard environment, filters and checks |
| 25 | +. ./common/rc |
| 26 | +. ./common/filter |
| 27 | +. ./common/quota |
| 28 | + |
| 29 | + |
| 30 | +begin=2000 |
| 31 | +end=10000 |
| 32 | +nr_proc=$((16 * LOAD_FACTOR)) |
| 33 | +deadline=$((100 * TIME_FACTOR)) |
| 34 | + |
| 35 | +_workout() |
| 36 | +{ |
| 37 | + for ((i=0; i < nr_proc; i++)) |
| 38 | + do |
| 39 | + # Spread files to isolated dirs to minimize locking contention |
| 40 | + mkdir -p $SCRATCH_MNT/chowner/$i |
| 41 | + $here/src/chowner $SCRATCH_MNT/chowner/$i/test -b $begin -e $end \ |
| 42 | + -t $((deadline + 10)) & |
| 43 | + pids="$pids $!" |
| 44 | + done |
| 45 | + # Let chowners warm up ... |
| 46 | + sleep 5 |
| 47 | + start=$(date +%s) |
| 48 | + for ((i=0;i<3;i++)) |
| 49 | + do |
| 50 | + s=$(date +%s) |
| 51 | + # In normal situation command should finish in ~1sec, |
| 52 | + # but in case of livelock it will spin until chowners exits |
| 53 | + $* |
| 54 | + e=$(date +%s) |
| 55 | + echo "loop $i: $* runtime: $((e-s))" >> $seqres.full |
| 56 | + sleep 2 |
| 57 | + done |
| 58 | + end=$(date +%s) |
| 59 | + runtime=$((end-start)) |
| 60 | + echo "DONE: $* total runtime: $runtime" >> $seqres.full |
| 61 | + kill -TERM $pids 2> /dev/null |
| 62 | + wait $pids |
| 63 | + |
| 64 | + [ $runtime -le $deadline ] || \ |
| 65 | + _fail "Live lock detected, $* runtime: $runtime, deadline: $deadline" |
| 66 | +} |
| 67 | + |
| 68 | +# real QA test starts here |
| 69 | +_supported_fs generic |
| 70 | +_supported_os Linux |
| 71 | +_require_quota |
| 72 | +#_require_user |
| 73 | +_require_scratch |
| 74 | +_require_command "$KILLALL_PROG" killall |
| 75 | + |
| 76 | +rm -f $seqres.full |
| 77 | +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1 |
| 78 | +_scratch_mount "-o quota,user" |
| 79 | +chmod 777 $SCRATCH_MNT |
| 80 | +quotacheck -u $SCRATCH_MNT 2>/dev/null |
| 81 | +quotaon -v -u $SCRATCH_MNT >> $seqres.full 2>&1 |
| 82 | + |
| 83 | +# Preparation step: Create all files with uid in range |
| 84 | +# to cache quota in kernel memory |
| 85 | +mkdir -p $SCRATCH_MNT/q |
| 86 | +$here/src/chowner $SCRATCH_MNT/q -b $begin -e $end -P |
| 87 | + |
| 88 | +_workout quotasync $SCRATCH_MNT |
| 89 | +_workout sync |
| 90 | + |
| 91 | +echo "Silence is golden" |
| 92 | +# success, all done |
| 93 | +status=0 |
| 94 | +exit |
0 commit comments