mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Ian Campbell <ian.campbell@citrix.com>,
	"David S. Miller" <davem@davemloft.net>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.16.y-ckt 40/71] xen: netback: read hotplug script once at start of day.
Date: Thu, 25 Jun 2015 11:02:19 +0100	[thread overview]
Message-ID: <1435226570-3669-41-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1435226570-3669-1-git-send-email-luis.henriques@canonical.com>

3.16.7-ckt14 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ian Campbell <Ian.Campbell@citrix.com>

commit 31a418986a5852034d520a5bab546821ff1ccf3d upstream.

When we come to tear things down in netback_remove() and generate the
uevent it is possible that the xenstore directory has already been
removed (details below).

In such cases netback_uevent() won't be able to read the hotplug
script and will write a xenstore error node.

A recent change to the hypervisor exposed this race such that we now
sometimes lose it (where apparently we didn't ever before).

Instead read the hotplug script configuration during setup and use it
for the lifetime of the backend device.

The apparently more obvious fix of moving the transition to
state=Closed in netback_remove() to after the uevent does not work
because it is possible that we are already in state=Closed (in
reaction to the guest having disconnected as it shutdown). Being
already in Closed means the toolstack is at liberty to start tearing
down the xenstore directories. In principal it might be possible to
arrange to unregister the device sooner (e.g on transition to Closing)
such that xenstore would still be there but this state machine is
fragile and prone to anger...

A modern Xen system only relies on the hotplug uevent for driver
domains, when the backend is in the same domain as the toolstack it
will run the necessary setup/teardown directly in the correct sequence
wrt xenstore changes.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/net/xen-netback/xenbus.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index e54e96851cb7..61417acc9d86 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -34,6 +34,8 @@ struct backend_info {
 	enum xenbus_state frontend_state;
 	struct xenbus_watch hotplug_status_watch;
 	u8 have_hotplug_status_watch:1;
+
+	const char *hotplug_script;
 };
 
 static int connect_rings(struct backend_info *be, struct xenvif_queue *queue);
@@ -57,6 +59,7 @@ static int netback_remove(struct xenbus_device *dev)
 		xenvif_free(be->vif);
 		be->vif = NULL;
 	}
+	kfree(be->hotplug_script);
 	kfree(be);
 	dev_set_drvdata(&dev->dev, NULL);
 	return 0;
@@ -74,6 +77,7 @@ static int netback_probe(struct xenbus_device *dev,
 	struct xenbus_transaction xbt;
 	int err;
 	int sg;
+	const char *script;
 	struct backend_info *be = kzalloc(sizeof(struct backend_info),
 					  GFP_KERNEL);
 	if (!be) {
@@ -166,6 +170,15 @@ static int netback_probe(struct xenbus_device *dev,
 	if (err)
 		pr_debug("Error writing multi-queue-max-queues\n");
 
+	script = xenbus_read(XBT_NIL, dev->nodename, "script", NULL);
+	if (IS_ERR(script)) {
+		err = PTR_ERR(script);
+		xenbus_dev_fatal(dev, err, "reading script");
+		goto fail;
+	}
+
+	be->hotplug_script = script;
+
 	err = xenbus_switch_state(dev, XenbusStateInitWait);
 	if (err)
 		goto fail;
@@ -196,22 +209,14 @@ static int netback_uevent(struct xenbus_device *xdev,
 			  struct kobj_uevent_env *env)
 {
 	struct backend_info *be = dev_get_drvdata(&xdev->dev);
-	char *val;
 
-	val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
-	if (IS_ERR(val)) {
-		int err = PTR_ERR(val);
-		xenbus_dev_fatal(xdev, err, "reading script");
-		return err;
-	} else {
-		if (add_uevent_var(env, "script=%s", val)) {
-			kfree(val);
-			return -ENOMEM;
-		}
-		kfree(val);
-	}
+	if (!be)
+		return 0;
+
+	if (add_uevent_var(env, "script=%s", be->hotplug_script))
+		return -ENOMEM;
 
-	if (!be || !be->vif)
+	if (!be->vif)
 		return 0;
 
 	return add_uevent_var(env, "vif=%s", be->vif->dev->name);

  parent reply	other threads:[~2015-06-25 10:14 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 10:01 [3.16.y-ckt stable] Linux 3.16.7-ckt14 stable review Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 01/71] iio: adis16400: Report pressure channel scale Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 02/71] iio: adis16400: Use != channel indices for the two voltage channels Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 03/71] iio: adis16400: Compute the scan mask from channel indices Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 04/71] iio: adis16400: Remove unused variable Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 05/71] iio: adis16400: Fix burst mode Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 06/71] iio: adis16400: Fix burst transfer for adis16448 Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 07/71] USB: serial: ftdi_sio: Add support for a Motion Tracker Development Board Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 08/71] iio: adc: twl6030-gpadc: Fix modalias Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 09/71] serial: imx: Fix DMA handling for IDLE condition aborts Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 10/71] usb: dwc3: gadget: Fix incorrect DEPCMD and DGCMD status macros Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 11/71] ALSA: usb-audio: Add mic volume fix quirk for Logitech Quickcam Fusion Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 12/71] ozwpan: Use proper check to prevent heap overflow Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 13/71] ozwpan: Use unsigned ints " Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 14/71] ozwpan: divide-by-zero leading to panic Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 15/71] ozwpan: unchecked signed subtraction leads to DoS Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 16/71] n_tty: Fix auditing support for cannonical mode Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 17/71] drm/i915/hsw: Fix workaround for server AUX channel clock divisor Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 18/71] x86/asm/irq: Stop relying on magic JMP behavior for early_idt_handlers Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 19/71] lib: Fix strnlen_user() to not touch memory after specified maximum Luis Henriques
2015-06-25 10:01 ` [PATCH 3.16.y-ckt 20/71] Input: elantech - fix detection of touchpads where the revision matches a known rate Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 21/71] ALSA: hda/realtek - Add a fixup for another Acer Aspire 9420 Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 22/71] ALSA: usb-audio: add MAYA44 USB+ mixer control names Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 23/71] ALSA: usb-audio: fix missing input volume controls in MAYA44 USB(+) Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 24/71] USB: cp210x: add ID for HubZ dual ZigBee and Z-Wave dongle Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 25/71] Input: elantech - add new icbody type Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 26/71] MIPS: Fix enabling of DEBUG_STACKOVERFLOW Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 27/71] xfrm: fix a race in xfrm_state_lookup_byspi Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 28/71] kconfig: Fix warning "‘jump’ may be used uninitialized" Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 29/71] scripts/sortextable: suppress warning: `relocs_size' may be used uninitialized Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 30/71] thermal: step_wise: Revert optimization Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 31/71] MIPS: KVM: Do not sign extend on unsigned MMIO load Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 32/71] arch/x86/kvm/mmu.c: work around gcc-4.4.4 bug Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 33/71] net: core: Correct an over-stringent device loop detection Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 34/71] net: phy: Allow EEE for all RGMII variants Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 35/71] net: dp83640: fix broken calibration routine Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 36/71] net: dp83640: reinforce locking rules Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 37/71] unix/caif: sk_socket can disappear when state is unlocked Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 38/71] xen/netback: Properly initialize credit_bytes Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 39/71] udp: fix behavior of wrong checksums Luis Henriques
2015-06-25 10:02 ` Luis Henriques [this message]
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 41/71] ipv4/udp: Verify multicast group is ours in upd_v4_early_demux() Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 42/71] bridge: disable softirqs around br_fdb_update to avoid lockup Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 43/71] drm/i915: Assume dual channel LVDS if pixel clock necessitates it Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 44/71] Btrfs: send, add missing check for dead clone root Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 45/71] Btrfs: send, don't leave without decrementing clone root's send_progress Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 46/71] btrfs: incorrect handling for fiemap_fill_next_extent return Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 47/71] btrfs: cleanup orphans while looking up default subvolume Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 48/71] Drivers: hv: vmbus: Add support for VMBus panic notifier handler Luis Henriques
2015-06-30 16:19   ` Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 49/71] Drivers: hv: vmbus: Correcting truncation error for constant HV_CRASH_CTL_CRASH_NOTIFY Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 50/71] iommu/vt-d: Allow RMRR on graphics devices too Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 51/71] iommu/vt-d: Fix passthrough mode with translation-disabled devices Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 52/71] ata: ahci_mvebu: Fix wrongly set base address for the MBus window setting Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 53/71] virtio_pci: Clear stale cpumask when setting irq affinity Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 54/71] irqchip: sunxi-nmi: Fix off-by-one error in irq iterator Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 55/71] pata_octeon_cf: fix broken build Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 56/71] Input: synaptics - add min/max quirk for Lenovo S540 Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 57/71] drm/i915: Fix DDC probe for passive adapters Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 58/71] cfg80211: wext: clear sinfo struct before calling driver Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 59/71] mm/memory_hotplug.c: set zone->wait_table to null after freeing it Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 60/71] ring-buffer-benchmark: Fix the wrong sched_priority of producer Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 61/71] block: fix ext_dev_lock lockdep report Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 62/71] iser-target: Fix variable-length response error completion Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 63/71] iser-target: release stale iser connections Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 64/71] ALSA: hda - adding a DAC/pin preference map for a HP Envy TS machine Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 65/71] drm/mgag200: Reject non-character-cell-aligned mode widths Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 66/71] crypto: caam - fix uninitialized state->buf_dma field Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 67/71] crypto: caam - improve initalization for context state saves Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 68/71] crypto: caam - fix RNG buffer cache alignment Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 69/71] tracing: Have filter check for balanced ops Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 70/71] drm/radeon: fix freeze for laptop with Turks/Thames GPU Luis Henriques
2015-06-25 10:02 ` [PATCH 3.16.y-ckt 71/71] Revert "tools/vm: fix page-flags build" Luis Henriques

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=1435226570-3669-41-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=davem@davemloft.net \
    --cc=ian.campbell@citrix.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®