aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/xen
diff options
context:
space:
mode:
authorRoger Pau Monné <royger@FreeBSD.org>2018-05-22 08:51:16 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2018-05-22 08:51:16 +0000
commitffe4446b337f051d11eb3448b9648f62516481d9 (patch)
tree5ca27cb480d8ce2ca7393d04540d91f41ab67a12 /sys/dev/xen
parent99ece3a9cd73908e464603df160ab9b22e525e80 (diff)
Notes
Diffstat (limited to 'sys/dev/xen')
-rw-r--r--sys/dev/xen/blkback/blkback.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c
index 9744c8da73cb..51fcb708387b 100644
--- a/sys/dev/xen/blkback/blkback.c
+++ b/sys/dev/xen/blkback/blkback.c
@@ -806,6 +806,9 @@ struct xbb_softc {
/** Watch to wait for hotplug script execution */
struct xs_watch hotplug_watch;
+
+ /** Got the needed data from hotplug scripts? */
+ bool hotplug_done;
};
/*---------------------------- Request Processing ----------------------------*/
@@ -3310,10 +3313,9 @@ xbb_connect(struct xbb_softc *xbb)
{
int error;
- if (xenbus_get_state(xbb->dev) != XenbusStateInitialised)
- return;
-
- if (xbb_collect_frontend_info(xbb) != 0)
+ if (!xbb->hotplug_done ||
+ (xenbus_get_state(xbb->dev) != XenbusStateInitWait) ||
+ (xbb_collect_frontend_info(xbb) != 0))
return;
xbb->flags &= ~XBBF_SHUTDOWN;
@@ -3412,6 +3414,7 @@ xbb_shutdown(struct xbb_softc *xbb)
free(xbb->hotplug_watch.node, M_XENBLOCKBACK);
xbb->hotplug_watch.node = NULL;
}
+ xbb->hotplug_done = false;
if (xenbus_get_state(xbb->dev) < XenbusStateClosing)
xenbus_set_state(xbb->dev, XenbusStateClosing);
@@ -3692,8 +3695,11 @@ xbb_attach_disk(struct xs_watch *watch, const char **vec, unsigned int len)
return;
}
- /* Tell the front end that we are ready to connect. */
- xenbus_set_state(dev, XenbusStateInitialised);
+ xbb->hotplug_done = true;
+
+ /* The front end might be waiting for the backend, attach if so. */
+ if (xenbus_get_otherend_state(xbb->dev) == XenbusStateInitialised)
+ xbb_connect(xbb);
}
/**
@@ -3757,6 +3763,7 @@ xbb_attach(device_t dev)
* We need to wait for hotplug script execution before
* moving forward.
*/
+ KASSERT(!xbb->hotplug_done, ("Hotplug scripts already executed"));
watch_path = xs_join(xenbus_get_node(xbb->dev), "physical-device-path");
xbb->hotplug_watch.callback_data = (uintptr_t)dev;
xbb->hotplug_watch.callback = xbb_attach_disk;