ZTS: Fix removal_resume_export

This change simplify the test case removing part of the logic which was
introducing a race condition and thus causing spurious failures: we use
attempt_during_removal() from removal.kshlib instead which has been
observed to be more stable.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #7894 
Closes #7913
This commit is contained in:
LOLi 2018-09-24 21:58:16 +02:00 committed by Brian Behlendorf
parent b8fd4310c5
commit 36e369ecb8
2 changed files with 4 additions and 48 deletions

View File

@ -256,7 +256,6 @@ maybe = {
'no_space/enospc_002_pos': ['FAIL', enospc_reason], 'no_space/enospc_002_pos': ['FAIL', enospc_reason],
'projectquota/setup': ['SKIP', exec_reason], 'projectquota/setup': ['SKIP', exec_reason],
'redundancy/redundancy_004_neg': ['FAIL', '7290'], 'redundancy/redundancy_004_neg': ['FAIL', '7290'],
'removal/removal_resume_export': ['FAIL', '7894'],
'reservation/reservation_008_pos': ['FAIL', '7741'], 'reservation/reservation_008_pos': ['FAIL', '7741'],
'reservation/reservation_018_pos': ['FAIL', '5642'], 'reservation/reservation_018_pos': ['FAIL', '5642'],
'rsend/rsend_019_pos': ['FAIL', '6086'], 'rsend/rsend_019_pos': ['FAIL', '6086'],

View File

@ -37,8 +37,7 @@
# 3. Inject a fault in the pool and attempt to export (it # 3. Inject a fault in the pool and attempt to export (it
# should fail). # should fail).
# 4. After the export fails ensure that the removal thread # 4. After the export fails ensure that the removal thread
# was restarted (i.e. the svr_thread field in the spa # was restarted and the process complete successfully.
# should be non-zero).
# #
@ -48,34 +47,9 @@ function cleanup
default_cleanup_noexit default_cleanup_noexit
} }
function ensure_thread_running # spa_address function callback
{ {
if is_linux; then log_mustnot zpool export $TESTPOOL
typeset TRIES=0
typeset THREAD_PID
while [[ $TRIES -lt 50 ]]; do
THREAD_PID=$(pgrep spa_vdev_remove)
[[ "$THREAD_PID" ]] && break
sleep 0.1
(( TRIES = TRIES + 1 ))
done
[[ "$THREAD_PID" ]] || \
log_fail "removal thread is not running TRIES=$TRIES THREAD_PID=$THREAD_PID"
else
#
# Try to get the address of the removal thread.
#
typeset THREAD_ADDR=$(mdb -ke "$1::print \
spa_t spa_vdev_removal->svr_thread" | awk "{print \$3}")
#
# if address is NULL it means that the thread is
# not running.
#
[[ "$THREAD_ADDR" = 0 ]] && \
log_fail "removal thread is not running"
fi
return 0 return 0
} }
@ -86,12 +60,6 @@ log_onexit cleanup
# #
log_must default_setup_noexit "$REMOVEDISK" log_must default_setup_noexit "$REMOVEDISK"
#
# Save address of SPA in memory so you can check with mdb
# if the removal thread is running.
#
is_linux || typeset SPA_ADDR=$(mdb -ke "::spa" | awk "/$TESTPOOL/ {print \$1}")
# #
# Turn off compression to raise capacity as much as possible # Turn off compression to raise capacity as much as possible
# for the little time that this test runs. # for the little time that this test runs.
@ -109,26 +77,15 @@ log_must dd if=/dev/urandom of=$TESTDIR/$TESTFILE0 bs=64M count=32
# #
log_must zpool add -f $TESTPOOL $NOTREMOVEDISK log_must zpool add -f $TESTPOOL $NOTREMOVEDISK
#
# Start removal.
#
log_must zpool remove $TESTPOOL $REMOVEDISK
# #
# Inject an error so export fails after having just suspended # Inject an error so export fails after having just suspended
# the removal thread. [spa_inject_ref gets incremented] # the removal thread. [spa_inject_ref gets incremented]
# #
log_must zinject -d $REMOVEDISK -D 10:1 $TESTPOOL log_must zinject -d $REMOVEDISK -D 10:1 $TESTPOOL
log_must ensure_thread_running $SPA_ADDR
# #
# Because of the above error export should fail. # Because of the above error export should fail.
# #
log_mustnot zpool export $TESTPOOL log_must attempt_during_removal $TESTPOOL $REMOVEDISK callback
log_must ensure_thread_running $SPA_ADDR
wait_for_removal $TESTPOOL
log_pass "Device removal thread resumes after failed export" log_pass "Device removal thread resumes after failed export"