From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: [PATCH] drivers: xen-blkfront: only talk_to_blkback() when in XenbusStateInitialising Date: Mon, 22 Jun 2015 09:56:00 -0400 Message-ID: <1434981360-29794-1-git-send-email-konrad.wilk__41122.2998438918$1434981504$gmane$org@oracle.com> References: <558762C4.2000002@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z72DC-0004aU-4s for xen-devel@lists.xenproject.org; Mon, 22 Jun 2015 13:56:34 +0000 In-Reply-To: <558762C4.2000002@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, roger.pau@citrix.com Cc: Rafal.Mielniczuk@citrix.com, Konrad Rzeszutek Wilk , marcus.granado@citrix.com, julien.grall@citrix.com, justing@spectralogic.com, Paul.Durrant@citrix.com, david.vrabel@citrix.com List-Id: xen-devel@lists.xenproject.org From: Bob Liu Patch 69b91ede5cab843dcf345c28bd1f4b5a99dacd9b "drivers: xen-blkback: delay pending_req allocation to connect_ring" exposed an problem that Xen blkfront has. There is a race with XenStored and the drivers such that we can see two: vbd vbd-268440320: blkfront:blkback_changed to state 2. vbd vbd-268440320: blkfront:blkback_changed to state 2. vbd vbd-268440320: blkfront:blkback_changed to state 4. state changes to XenbusStateInitWait ('2'). The end result is that blkback_changed() receives two notify and calls twice setup_blkring(). While the backend driver may only get the first setup_blkring() which is wrong and reads out-dated (or reads them as they are being updated with new ring-ref values). The end result is that the ring ends up being incorrectly set. Reported-and-Tested-by: Robert Butera Signed-off-by: Bob Liu Signed-off-by: Konrad Rzeszutek Wilk --- drivers/block/xen-blkfront.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index d3c1a95..fc770b7 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1951,6 +1951,8 @@ static void blkback_changed(struct xenbus_device *dev, switch (backend_state) { case XenbusStateInitWait: + if (dev->state != XenbusStateInitialising) + break; if (talk_to_blkback(dev, info)) { kfree(info); dev_set_drvdata(&dev->dev, NULL); -- 2.1.0