From: Paul Durrant <pdurrant@amazon.com> To: <xen-devel@lists.xenproject.org>, <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org> Cc: Paul Durrant <pdurrant@amazon.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, Juergen Gross <jgross@suse.com>, "Stefano Stabellini" <sstabellini@kernel.org> Subject: [PATCH v3 2/4] xenbus: limit when state is forced to closed Date: Wed, 11 Dec 2019 15:29:54 +0000 [thread overview] Message-ID: <20191211152956.5168-3-pdurrant@amazon.com> (raw) In-Reply-To: <20191211152956.5168-1-pdurrant@amazon.com> If a driver probe() fails then leave the xenstore state alone. There is no reason to modify it as the failure may be due to transient resource allocation issues and hence a subsequent probe() may succeed. If the driver supports re-binding then only force state to closed during remove() only in the case when the toolstack may need to clean up. This can be detected by checking whether the state in xenstore has been set to closing prior to device removal. NOTE: Re-bind support is indicated by new boolean in struct xenbus_driver, which defaults to false. Subsequent patches will add support to some backend drivers. Signed-off-by: Paul Durrant <pdurrant@amazon.com> --- Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Juergen Gross <jgross@suse.com> Cc: Stefano Stabellini <sstabellini@kernel.org> v2: - Introduce the 'allow_rebind' flag - Expand the commit comment --- drivers/xen/xenbus/xenbus_probe.c | 12 ++++++++++-- include/xen/xenbus.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 5aa29396c9e3..378486b79f96 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -255,7 +255,6 @@ int xenbus_dev_probe(struct device *_dev) module_put(drv->driver.owner); fail: xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); - xenbus_switch_state(dev, XenbusStateClosed); return err; } EXPORT_SYMBOL_GPL(xenbus_dev_probe); @@ -276,7 +275,16 @@ int xenbus_dev_remove(struct device *_dev) free_otherend_details(dev); - xenbus_switch_state(dev, XenbusStateClosed); + /* + * If the toolstack has forced the device state to closing then set + * the state to closed now to allow it to be cleaned up. + * Similarly, if the driver does not support re-bind, set the + * closed. + */ + if (!drv->allow_rebind || + xenbus_read_driver_state(dev->nodename) == XenbusStateClosing) + xenbus_switch_state(dev, XenbusStateClosed); + return 0; } EXPORT_SYMBOL_GPL(xenbus_dev_remove); diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index 869c816d5f8c..24228a102141 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -93,6 +93,7 @@ struct xenbus_device_id struct xenbus_driver { const char *name; /* defaults to ids[0].devicetype */ const struct xenbus_device_id *ids; + bool allow_rebind; /* avoid setting xenstore closed during remove */ int (*probe)(struct xenbus_device *dev, const struct xenbus_device_id *id); void (*otherend_changed)(struct xenbus_device *dev, -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Paul Durrant <pdurrant@amazon.com> To: <xen-devel@lists.xenproject.org>, <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org> Cc: Juergen Gross <jgross@suse.com>, Paul Durrant <pdurrant@amazon.com>, Stefano Stabellini <sstabellini@kernel.org>, Boris Ostrovsky <boris.ostrovsky@oracle.com> Subject: [Xen-devel] [PATCH v3 2/4] xenbus: limit when state is forced to closed Date: Wed, 11 Dec 2019 15:29:54 +0000 [thread overview] Message-ID: <20191211152956.5168-3-pdurrant@amazon.com> (raw) In-Reply-To: <20191211152956.5168-1-pdurrant@amazon.com> If a driver probe() fails then leave the xenstore state alone. There is no reason to modify it as the failure may be due to transient resource allocation issues and hence a subsequent probe() may succeed. If the driver supports re-binding then only force state to closed during remove() only in the case when the toolstack may need to clean up. This can be detected by checking whether the state in xenstore has been set to closing prior to device removal. NOTE: Re-bind support is indicated by new boolean in struct xenbus_driver, which defaults to false. Subsequent patches will add support to some backend drivers. Signed-off-by: Paul Durrant <pdurrant@amazon.com> --- Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Juergen Gross <jgross@suse.com> Cc: Stefano Stabellini <sstabellini@kernel.org> v2: - Introduce the 'allow_rebind' flag - Expand the commit comment --- drivers/xen/xenbus/xenbus_probe.c | 12 ++++++++++-- include/xen/xenbus.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 5aa29396c9e3..378486b79f96 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -255,7 +255,6 @@ int xenbus_dev_probe(struct device *_dev) module_put(drv->driver.owner); fail: xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); - xenbus_switch_state(dev, XenbusStateClosed); return err; } EXPORT_SYMBOL_GPL(xenbus_dev_probe); @@ -276,7 +275,16 @@ int xenbus_dev_remove(struct device *_dev) free_otherend_details(dev); - xenbus_switch_state(dev, XenbusStateClosed); + /* + * If the toolstack has forced the device state to closing then set + * the state to closed now to allow it to be cleaned up. + * Similarly, if the driver does not support re-bind, set the + * closed. + */ + if (!drv->allow_rebind || + xenbus_read_driver_state(dev->nodename) == XenbusStateClosing) + xenbus_switch_state(dev, XenbusStateClosed); + return 0; } EXPORT_SYMBOL_GPL(xenbus_dev_remove); diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index 869c816d5f8c..24228a102141 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -93,6 +93,7 @@ struct xenbus_device_id struct xenbus_driver { const char *name; /* defaults to ids[0].devicetype */ const struct xenbus_device_id *ids; + bool allow_rebind; /* avoid setting xenstore closed during remove */ int (*probe)(struct xenbus_device *dev, const struct xenbus_device_id *id); void (*otherend_changed)(struct xenbus_device *dev, -- 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-12-11 15:30 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-11 15:29 [PATCH v3 0/4] xen-blkback: support live update Paul Durrant 2019-12-11 15:29 ` [Xen-devel] " Paul Durrant 2019-12-11 15:29 ` [PATCH v3 1/4] xenbus: move xenbus_dev_shutdown() into frontend code Paul Durrant 2019-12-11 15:29 ` [Xen-devel] " Paul Durrant 2019-12-11 15:29 ` Paul Durrant [this message] 2019-12-11 15:29 ` [Xen-devel] [PATCH v3 2/4] xenbus: limit when state is forced to closed Paul Durrant 2019-12-12 6:02 ` Jürgen Groß 2019-12-12 6:02 ` [Xen-devel] " Jürgen Groß 2019-12-11 15:29 ` [PATCH v3 3/4] xen/interface: re-define FRONT/BACK_RING_ATTACH() Paul Durrant 2019-12-11 15:29 ` [Xen-devel] " Paul Durrant 2019-12-12 6:04 ` Jürgen Groß 2019-12-12 6:04 ` [Xen-devel] " Jürgen Groß 2019-12-13 8:59 ` Jürgen Groß 2019-12-13 8:59 ` [Xen-devel] " Jürgen Groß 2019-12-13 9:02 ` Durrant, Paul 2019-12-13 9:02 ` [Xen-devel] " Durrant, Paul 2019-12-11 15:29 ` [PATCH v3 4/4] xen-blkback: support dynamic unbind/bind Paul Durrant 2019-12-11 15:29 ` [Xen-devel] " Paul Durrant 2019-12-12 6:07 ` Jürgen Groß 2019-12-12 6:07 ` [Xen-devel] " Jürgen Groß 2019-12-12 11:46 ` Roger Pau Monné 2019-12-12 11:46 ` [Xen-devel] " Roger Pau Monné 2019-12-12 12:04 ` Jürgen Groß 2019-12-12 12:04 ` [Xen-devel] " Jürgen Groß 2019-12-20 12:45 ` [PATCH v3 0/4] xen-blkback: support live update Jürgen Groß 2019-12-20 12:45 ` [Xen-devel] " Jürgen Groß
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191211152956.5168-3-pdurrant@amazon.com \ --to=pdurrant@amazon.com \ --cc=boris.ostrovsky@oracle.com \ --cc=jgross@suse.com \ --cc=linux-block@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=sstabellini@kernel.org \ --cc=xen-devel@lists.xenproject.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.