Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934523AbbEOLfZ (ORCPT ); Fri, 15 May 2015 07:35:25 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:39451 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934378AbbEOLfW (ORCPT ); Fri, 15 May 2015 07:35:22 -0400 Message-ID: <5555D9EC.9030802@oracle.com> Date: Fri, 15 May 2015 19:35:08 +0800 From: Bob Liu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: =?windows-1252?Q?Roger_Pau_Monn=E9?= CC: xen-devel@lists.xen.org, david.vrabel@citrix.com, justing@spectralogic.com, konrad.wilk@oracle.com, paul.durrant@citrix.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] driver: xen-blkfront: move talk_to_blkback to the correct place References: <1431428504-6623-1-git-send-email-bob.liu@oracle.com> <5555C3DE.7090603@citrix.com> <5555D26B.8040002@oracle.com> <5555D4F8.40701@citrix.com> In-Reply-To: <5555D4F8.40701@citrix.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3065 Lines: 90 On 05/15/2015 07:14 PM, Roger Pau Monn? wrote: > El 15/05/15 a les 13.03, Bob Liu ha escrit: >> >> On 05/15/2015 06:01 PM, Roger Pau Monn? wrote: >>> El 12/05/15 a les 13.01, Bob Liu ha escrit: >>>> The right place for talk_to_blkback() to query backend features and transport >>>> parameters is after backend entered XenbusStateInitWait. There is no problem >>> >>> talk_to_blkback doesn't gather any backend features, it just publishes >>> the features supported by the frontend, which AFAICT can be done at any >> >> 1) But talk_tlkback will also allocate and initialize the request ring which >> should be done after backend entered XenbusStateInitWait. > > Maybe setup_blkring should be moved to a more suitable location instead > of moving the whole function? > Most of other parts in talk_to_blkback() depends on setup_blkring() like write out ring-ref and event-channel. Only notify 'feature-persistent' and 'protocol:XEN_IO_PROTO_ABI_NATIVE' can be left in front probe(). Then the patch would like this: diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2c61cf8..6b918e0 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1318,17 +1318,6 @@ again: message = "writing event-channel"; goto abort_transaction; } - err = xenbus_printf(xbt, dev->nodename, "protocol", "%s", - XEN_IO_PROTO_ABI_NATIVE); - if (err) { - message = "writing protocol"; - goto abort_transaction; - } - err = xenbus_printf(xbt, dev->nodename, - "feature-persistent", "%u", 1); - if (err) - dev_warn(&dev->dev, - "writing persistent grants feature to xenbus"); err = xenbus_transaction_end(xbt, 0); if (err) { @@ -1430,13 +1419,17 @@ static int blkfront_probe(struct xenbus_device *dev, info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0); dev_set_drvdata(&dev->dev, info); - err = talk_to_blkback(dev, info); + err = xenbus_printf(xbt, dev->nodename, "protocol", "%s", + XEN_IO_PROTO_ABI_NATIVE); if (err) { - kfree(info); - dev_set_drvdata(&dev->dev, NULL); - return err; + message = "writing protocol"; + goto abort_transaction; } - + err = xenbus_printf(xbt, dev->nodename, + "feature-persistent", "%u", 1); + if (err) + dev_warn(&dev->dev, + "writing persistent grants feature to xenbus"); return 0; } @@ -1906,8 +1899,13 @@ static void blkback_changed(struct xenbus_device *dev, dev_dbg(&dev->dev, "blkfront:blkback_changed to state %d.\n", backend_state); switch (backend_state) { - case XenbusStateInitialising: case XenbusStateInitWait: + if (talk_to_blkback(dev, info)) { + kfree(info); + dev_set_drvdata(&dev->dev, NULL); + break; + } + case XenbusStateInitialising: case XenbusStateInitialised: case XenbusStateReconfiguring: case XenbusStateReconfigured: -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/