Skip to content

Commit

Permalink
ZFS: fix spurious failures in mv_files
Browse files Browse the repository at this point in the history
The test could fail because of a race condition between the files being
generated in the background and attempting to move the files. Wait for
all file generation to complete before trying to move the files around.

Also, clean up the waiting: the 'wait' command without arguments waits
for all child pids.

Signed-off-by: Chris Dunlop <[email protected]>
  • Loading branch information
chrisrd committed Mar 1, 2018
1 parent e086e71 commit 0732059
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,6 @@ function init_setup

}

function wait_pid
{
for pid in $1
do
ps -e | grep $pid >/dev/null 2>&1
(( $? == 0 )) && wait $pid
done
}


#
# Generate given number files in a
# directory of zfs file system
Expand All @@ -141,18 +131,17 @@ function generate_files
cp /etc/passwd $1/file_$count \
> /dev/null 2>&1 &

PIDS="$PIDS $!"
(( proc_num = proc_num + 1 ))

proc_num=`echo $PIDS | wc -w`
if (( proc_num >= GANGPIDS )); then
wait_pid "$PIDS"
wait
proc_num=0
PIDS=""
fi

(( count = count + 1 ))
done

wait
}

#
Expand Down

0 comments on commit 0732059

Please sign in to comment.