ZTS: Remove procfs use from zpool_import_status

procfs might be not mounted on FreeBSD.  Plus checking for specific
PID might be not exactly reliable.  Check for empty list of jobs
instead.

Premature loop exit can result in failed test and failed cleanup,
failing also some following tests.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Signed-off-by:Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #11141
This commit is contained in:
Alexander Motin 2024-12-25 14:00:38 -05:00 committed by Brian Behlendorf
parent 8bf1e83eef
commit b66d910113

View File

@ -103,21 +103,16 @@ log_must zpool export $TESTPOOL1
log_must set_tunable64 METASLAB_DEBUG_LOAD 1
log_note "Starting zpool import in background at" $(date +'%H:%M:%S')
zpool import -d $DEVICE_DIR -f $guid &
pid=$!
#
# capture progress until import is finished
#
log_note waiting for pid $pid to exit
kstat import_progress
while [[ -d /proc/"$pid" ]]; do
while [[ -n $(jobs) ]]; do
line=$(kstat import_progress | grep -v pool_guid)
if [[ -n $line ]]; then
echo $line
fi
if [[ -f /$TESTPOOL1/fs/00 ]]; then
break;
fi
sleep 0.0001
done
log_note "zpool import completed at" $(date +'%H:%M:%S')