Created
May 21, 2018 17:07
-
-
Save danmcd/77cbcfff9e8a53d4b3c0c31a019862e9 to your computer and use it in GitHub Desktop.
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
diff --git a/overlay/generic/usr/lib/brand/jcommon/statechange b/overlay/generic/usr/lib/brand/jcommon/statechange | |
index 4f61a02..0d08300 100644 | |
--- a/overlay/generic/usr/lib/brand/jcommon/statechange | |
+++ b/overlay/generic/usr/lib/brand/jcommon/statechange | |
@@ -264,9 +264,34 @@ setup_net() | |
# it already exist? | |
# | |
if [[ -n "$isoverlay" ]]; then | |
- if ! dladm show-overlay $global_nic 2>/dev/null; then | |
- dladm create-overlay $rule -v $num $global_nic | |
+ ntries=0 | |
+ while [[ -d /var/run/ovcreate || | |
+ ! dladm show-overlay $global_nic 2>/dev/null ]]; do | |
+ ln -s /proc/$$ /var/run/ovcreate | |
if [[ $? -ne 0 ]]; then | |
+ # Someone beat us to creating | |
+ # the lock file. Pause, and try | |
+ # again, but not too many times. | |
+ ntries = $(($ntries + 1)) | |
+ if [[ $ntries -gt 5 ]]; then | |
+ logerr -p daemon.err \ | |
+ "zone $ZONENAME cannot " \ | |
+ "acquire ovcreate due to " \ | |
+ "this: " \ | |
+ `ls -l /var/run/ovcreate` | |
+ exit 1 | |
+ fi | |
+ # Continue through the while loop | |
+ # after a pause. | |
+ sleep 1 | |
+ continue | |
+ fi | |
+ dladm create-overlay $rule -v $num $global_nic | |
+ # Save the dladm return code so we can remove | |
+ # the lock immediately. | |
+ rc = $? | |
+ /bin/rm -f /var/run/ovcreate | |
+ if [[ $rc -ne 0 ]]; then | |
logger -p daemon.err "zone $ZONENAME " \ | |
"failed to create overlay device " \ | |
"$global_nic with command " \ | |
@@ -274,7 +299,7 @@ setup_net() | |
"$num $global_nic" | |
exit 1 | |
fi | |
- fi | |
+ done | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay... final answer (edited for locking fix):