svn commit: r301269 - head/sys/dev/xen/blkback

Roger Pau Monné royger at FreeBSD.org
Fri Jun 3 11:39:37 UTC 2016


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 ----------------------------*/


More information about the svn-src-all mailing list