summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroyger <royger@FreeBSD.org>2018-05-29 07:51:24 +0000
committerroyger <royger@FreeBSD.org>2018-05-29 07:51:24 +0000
commit3beebb1bb76cf7ef14e6d9d0a55aebeb0c038a48 (patch)
treead471c51aab6b3a1909ccb6c5b69ee260d86b74f
parentff7b12ed4b30fd4629bb9fa671e24c7e514f0577 (diff)
downloadFreeBSD-src-3beebb1bb76cf7ef14e6d9d0a55aebeb0c038a48.zip
FreeBSD-src-3beebb1bb76cf7ef14e6d9d0a55aebeb0c038a48.tar.gz
MFC r334027: xen-blkback: do not use state 3
Linux will not connect to a backend that's in state 3 (XenbusStateInitialised), it needs to be in state 2 (XenbusStateInitWait) for Linux to attempt to connect to the backend. Approved by: re (kib)
-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 9c9735e..98d07b5 100644
--- a/sys/dev/xen/blkback/blkback.c
+++ b/sys/dev/xen/blkback/blkback.c
@@ -804,6 +804,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 ----------------------------*/
@@ -3308,10 +3311,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;
@@ -3410,6 +3412,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);
@@ -3690,8 +3693,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);
}
/**
@@ -3755,6 +3761,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;
OpenPOWER on IntegriCloud