-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9425 allow channel programs to be stopped via signals
Reviewed by: Sebastien Roy <[email protected]> Reviewed by: Serapheim Dimitropoulos <[email protected]> Reviewed by: Matt Ahrens <[email protected]> Approved by: Robert Mustacchi <[email protected]>
- Loading branch information
Don Brady
authored and
Prakash Surya
committed
Feb 20, 2019
1 parent
9d1587b
commit d0cb1fb
Showing
9 changed files
with
289 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...test/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright (c) 2017 by Delphix. All rights reserved. | ||
# | ||
. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib | ||
|
||
# | ||
# DESCRIPTION: Execute a long-running zfs channel program and attempt to | ||
# cancel it by sending a signal. | ||
# | ||
|
||
verify_runnable "global" | ||
|
||
rootfs=$TESTPOOL/$TESTFS | ||
snapname=snap | ||
limit=50000000 | ||
|
||
function cleanup | ||
{ | ||
datasetexists $rootfs && log_must zfs destroy -R $rootfs | ||
} | ||
|
||
log_onexit cleanup | ||
|
||
# | ||
# Create a working set of 100 file systems | ||
# | ||
for i in {1..100}; do | ||
log_must zfs create "$rootfs/child$i" | ||
done | ||
|
||
# | ||
# Attempt to create 100 snapshots with zfs.sync.snapshot() along with some | ||
# time consuming efforts. We use loops of zfs.check.* (dry run operations) | ||
# to consume instructions before the next zfs.sync.snapshot() occurs. | ||
# | ||
# Without a signal interruption this ZCP would take several minutes and | ||
# generate over 30 million Lua instructions. | ||
# | ||
function chan_prog | ||
{ | ||
zfs program -t $limit $TESTPOOL - $rootfs $snapname <<-EOF | ||
arg = ... | ||
fs = arg["argv"][1] | ||
snap = arg["argv"][2] | ||
for child in zfs.list.children(fs) do | ||
local snapname = child .. "@" .. snap | ||
zfs.check.snapshot(snapname) | ||
zfs.sync.snapshot(snapname) | ||
for i=1,20000,1 do | ||
zfs.check.snapshot(snapname) | ||
zfs.check.destroy(snapname) | ||
zfs.check.destroy(fs) | ||
end | ||
end | ||
return "should not have reached here" | ||
EOF | ||
} | ||
|
||
log_note "Executing a long-running zfs program in the background" | ||
chan_prog & | ||
CHILD=$! | ||
|
||
# | ||
# After waiting, send a kill signal to the channel program process. | ||
# This should stop the ZCP near a million instructions but still have | ||
# created some of the snapshots. Note that since the above zfs program | ||
# command might get wrapped, we also issue a kill to the group. | ||
# | ||
sleep 10 | ||
log_pos pkill -P $CHILD | ||
log_pos kill $CHILD | ||
|
||
# | ||
# Make sure the channel program did not fully complete by enforcing | ||
# that not all of the snapshots were created. | ||
# | ||
snap_count=$(zfs list -t snapshot | grep $TESTPOOL | wc -l) | ||
log_note "$snap_count snapshots created by ZCP" | ||
|
||
if [ "$snap_count" -eq 0 ]; then | ||
log_fail "Channel progam failed to run." | ||
elif [ "$snap_count" -gt 50 ]; then | ||
log_fail "Too many snapshots after a cancel ($snap_count)." | ||
else | ||
log_pass "Canceling a long-running channel program works." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.