Date: Fri, 3 Jun 2016 11:39:36 +0000 (UTC) From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301269 - head/sys/dev/xen/blkback Message-ID: <201606031139.u53BdakP085407@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: royger Date: Fri Jun 3 11:39:35 2016 New Revision: 301269 URL: https://svnweb.freebsd.org/changeset/base/301269 Log: xen-blkback: fix error path on failed attach The current error path in case of failure during attach/initialization is not correct and leaves blkback in a stuck state. This is due to blkback waiting for blkfront to switch to state XenbusStateClosed, but if blkfront never attached (because the guest is not even started) it cannot possibly make it to that state. Instead just wait for the frontend to be in a state different than XenbusStateConnected in order to proceed with the shutdown. Also, it is wrong to call xbb_detach directly because it destroys the lock which can still be used by xbb_frontend_changed. Sponsored by: Citrix Systems R&D Modified: head/sys/dev/xen/blkback/blkback.c Modified: head/sys/dev/xen/blkback/blkback.c ============================================================================== --- head/sys/dev/xen/blkback/blkback.c Fri Jun 3 11:38:52 2016 (r301268) +++ head/sys/dev/xen/blkback/blkback.c Fri Jun 3 11:39:35 2016 (r301269) @@ -172,7 +172,6 @@ struct xbb_xen_req; static void xbb_attach_failed(struct xbb_softc *xbb, int err, const char *fmt, ...) __attribute__((format(printf, 3, 4))); static int xbb_shutdown(struct xbb_softc *xbb); -static int xbb_detach(device_t dev); /*------------------------------ Data Structures -----------------------------*/ @@ -3419,8 +3418,8 @@ xbb_shutdown(struct xbb_softc *xbb) mtx_lock(&xbb->lock); xbb->flags &= ~XBBF_IN_SHUTDOWN; - /* The front can submit I/O until entering the closed state. */ - if (frontState < XenbusStateClosed) + /* Wait for the frontend to disconnect (if it's connected). */ + if (frontState == XenbusStateConnected) return (EAGAIN); DPRINTF("\n"); @@ -3477,7 +3476,9 @@ xbb_attach_failed(struct xbb_softc *xbb, xs_printf(XST_NIL, xenbus_get_node(xbb->dev), "online", "0"); - xbb_detach(xbb->dev); + mtx_lock(&xbb->lock); + xbb_shutdown(xbb); + mtx_unlock(&xbb->lock); } /*---------------------------- NewBus Entrypoints ----------------------------*/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606031139.u53BdakP085407>