From owner-svn-src-all@freebsd.org Tue May 29 07:51:25 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EFC11EF80A1; Tue, 29 May 2018 07:51:24 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A40A67C102; Tue, 29 May 2018 07:51:24 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8517D19317; Tue, 29 May 2018 07:51:24 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4T7pOGE062887; Tue, 29 May 2018 07:51:24 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4T7pOGJ062886; Tue, 29 May 2018 07:51:24 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201805290751.w4T7pOGJ062886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 29 May 2018 07:51:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334315 - stable/11/sys/dev/xen/blkback X-SVN-Group: stable-11 X-SVN-Commit-Author: royger X-SVN-Commit-Paths: stable/11/sys/dev/xen/blkback X-SVN-Commit-Revision: 334315 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 07:51:25 -0000 Author: royger Date: Tue May 29 07:51:24 2018 New Revision: 334315 URL: https://svnweb.freebsd.org/changeset/base/334315 Log: 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) Modified: stable/11/sys/dev/xen/blkback/blkback.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/xen/blkback/blkback.c ============================================================================== --- stable/11/sys/dev/xen/blkback/blkback.c Tue May 29 07:14:57 2018 (r334314) +++ stable/11/sys/dev/xen/blkback/blkback.c Tue May 29 07:51:24 2018 (r334315) @@ -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,12 +3311,11 @@ xbb_connect(struct xbb_softc *xbb) { int error; - if (xenbus_get_state(xbb->dev) != XenbusStateInitialised) + if (!xbb->hotplug_done || + (xenbus_get_state(xbb->dev) != XenbusStateInitWait) || + (xbb_collect_frontend_info(xbb) != 0)) return; - if (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 **v 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;