Skip to contentSkip to conversation

xen: frontend devices should handle missed backend CLOSING

PATCH In review David Vrabel 3 participants 17 messages Sep 21, 2012 – Oct 9, 2012

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

cover xen: frontend devices should handle missed backend CLOSING

The series makes all the Xen frontend drivers handle the backend transitioning to CLOSED without the frontend having previously seen the backend in the CLOSING state.

Backends shouldn't do this but some do. e.g., if the host is XenServer and the toolstack decides to do a forced shutdown of a VBD, then the blkfront may miss the CLOSING transition and the /dev/xvdX device will not be destroyed which prevents it being reused.

I have seen systems that ended up in this state but it's not clear if this was the actual cause. However, I think in general it's a good thing to thing to improve the handling of unexpected state transitions.

Konrad, I've split this into a patch per frontend in case each patch should go via a different maintainer. But if you'd prefer, I can roll this up into one patch to via your Xen tree.

David

#1 lore raw

PATCH 1/6 xen-netfront: handle backend CLOSED without CLOSING

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

---
 drivers/net/xen-netfront.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/xen-netfront.c +4 -1
index 3089990..843533a 100644
@@ -1719,7 +1719,6 @@ static void netback_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateInitWait:
@@ -1734,6 +1733,10 @@ static void netback_changed(struct xenbus_device *dev,
 		netif_notify_peers(netdev);
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's CLOSING state -- fallthrough */
 	case XenbusStateClosing:
 		xenbus_frontend_closed(dev);
 		break;
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 2/6 xen-blkfront: handle backend CLOSED without CLOSING

In reply to David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

---
 drivers/block/xen-blkfront.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/block/xen-blkfront.c +4 -1
index 2c2d2e5..8da12a9 100644
@@ -1340,13 +1340,16 @@ static void blkback_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateConnected:
 		blkfront_connect(info);
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's Closing state -- fallthrough */
 	case XenbusStateClosing:
 		blkfront_closing(info);
 		break;
Signature · 1 line
1.7.2.5
#3 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 7 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

Didn't handle the frontend block device being mounted. Updated patch here.

8<---------------------------------
xen-blkfront: handle backend CLOSED without CLOSING

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

If the backend is CLOSED then the frontend can't talk to it so go to CLOSED immediately without waiting for the block device to be closed or unmounted.

---
 drivers/block/xen-blkfront.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/block/xen-blkfront.c +9 -4
index 2c2d2e5..c1f5f38 100644
@@ -1143,7 +1143,8 @@ static int blkfront_resume(struct xenbus_device *dev)
 }
 
 static void
-blkfront_closing(struct blkfront_info *info)
+blkfront_closing(struct blkfront_info *info,
+		 enum xenbus_state backend_state)
 {
 	struct xenbus_device *xbdev = info->xbdev;
 	struct block_device *bdev = NULL;
@@ -1167,7 +1168,8 @@ blkfront_closing(struct blkfront_info *info)
 
 	mutex_lock(&bdev->bd_mutex);
 
-	if (bdev->bd_openers) {
+	/* If the backend is already CLOSED, close now. */
+	if (bdev->bd_openers && backend_state != XenbusStateClosed) {
 		xenbus_dev_error(xbdev, -EBUSY,
 				 "Device in use; refusing to close");
 		xenbus_switch_state(xbdev, XenbusStateClosing);
@@ -1340,15 +1342,18 @@ static void blkback_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateConnected:
 		blkfront_connect(info);
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's Closing state -- fallthrough */
 	case XenbusStateClosing:
-		blkfront_closing(info);
+		blkfront_closing(info, backend_state);
 		break;
 	}
 }
Signature · 1 line
1.7.2.5
#4 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 10 lines · David Vrabel
Quoted 7 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

Didn't handle the frontend block device being mounted. Updated patch here.

Konrad, can you ack this updated patch if you're happy with it.

Thanks.

David

Quoted 63 lines

8<---------------------------------
xen-blkfront: handle backend CLOSED without CLOSING

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

If the backend is CLOSED then the frontend can't talk to it so go to CLOSED immediately without waiting for the block device to be closed or unmounted.

---
 drivers/block/xen-blkfront.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/block/xen-blkfront.c +9 -4
index 2c2d2e5..c1f5f38 100644
@@ -1143,7 +1143,8 @@ static int blkfront_resume(struct xenbus_device *dev)
 }
 
 static void
-blkfront_closing(struct blkfront_info *info)
+blkfront_closing(struct blkfront_info *info,
+		 enum xenbus_state backend_state)
 {
 	struct xenbus_device *xbdev = info->xbdev;
 	struct block_device *bdev = NULL;
@@ -1167,7 +1168,8 @@ blkfront_closing(struct blkfront_info *info)
 
 	mutex_lock(&bdev->bd_mutex);
 
-	if (bdev->bd_openers) {
+	/* If the backend is already CLOSED, close now. */
+	if (bdev->bd_openers && backend_state != XenbusStateClosed) {
 		xenbus_dev_error(xbdev, -EBUSY,
 				 "Device in use; refusing to close");
 		xenbus_switch_state(xbdev, XenbusStateClosing);
@@ -1340,15 +1342,18 @@ static void blkback_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateConnected:
 		blkfront_connect(info);
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's Closing state -- fallthrough */
 	case XenbusStateClosing:
-		blkfront_closing(info);
+		blkfront_closing(info, backend_state);
 		break;
 	}
 }
#5 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 8 lines · David Vrabel
Quoted 7 lines · David Vrabel
Quoted 6 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

So, treat an unexpected backend CLOSED state the same as CLOSING.

Didn't handle the frontend block device being mounted. Updated patch here.

Konrad, can you ack this updated patch if you're happy with it.

Or should I just carry it in my for-jens-3.7 bug-fixes queue and ask Jen to pull it once rc0 is out?

Quoted 68 lines

Thanks.

David

Quoted 63 lines

8<---------------------------------
xen-blkfront: handle backend CLOSED without CLOSING

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

If the backend is CLOSED then the frontend can't talk to it so go to CLOSED immediately without waiting for the block device to be closed or unmounted.

---
 drivers/block/xen-blkfront.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/block/xen-blkfront.c +9 -4
index 2c2d2e5..c1f5f38 100644
@@ -1143,7 +1143,8 @@ static int blkfront_resume(struct xenbus_device *dev)
 }
 
 static void
-blkfront_closing(struct blkfront_info *info)
+blkfront_closing(struct blkfront_info *info,
+		 enum xenbus_state backend_state)
 {
 	struct xenbus_device *xbdev = info->xbdev;
 	struct block_device *bdev = NULL;
@@ -1167,7 +1168,8 @@ blkfront_closing(struct blkfront_info *info)
 
 	mutex_lock(&bdev->bd_mutex);
 
-	if (bdev->bd_openers) {
+	/* If the backend is already CLOSED, close now. */
+	if (bdev->bd_openers && backend_state != XenbusStateClosed) {
 		xenbus_dev_error(xbdev, -EBUSY,
 				 "Device in use; refusing to close");
 		xenbus_switch_state(xbdev, XenbusStateClosing);
@@ -1340,15 +1342,18 @@ static void blkback_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateConnected:
 		blkfront_connect(info);
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's Closing state -- fallthrough */
 	case XenbusStateClosing:
-		blkfront_closing(info);
+		blkfront_closing(info, backend_state);
 		break;
 	}
 }
#6 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · David Vrabel
Quoted 9 lines · David Vrabel
Quoted 7 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Didn't handle the frontend block device being mounted. Updated patch here.

Konrad, can you ack this updated patch if you're happy with it.

Or should I just carry it in my for-jens-3.7 bug-fixes queue and ask Jen to pull it once rc0 is out?

This seems easiest, if Jan is happy with the patch.

Thanks.

David

#7 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 15 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 13 lines · Konrad Rzeszutek Wilk
Quoted 12 lines · David Vrabel
Quoted 10 lines · David Vrabel
Quoted 7 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

Didn't handle the frontend block device being mounted. Updated patch here.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Konrad, can you ack this updated patch if you're happy with it.

Or should I just carry it in my for-jens-3.7 bug-fixes queue and ask Jen to pull it once rc0 is out?

This seems easiest, if Jan is happy with the patch.

I see the point of your explanation yesterday, but am still not convinced that the early cleanup in spite of active users of the disk can't cause any problems (like dangling pointers or NULL dereferences).

Jan

#8 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 19 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · David Vrabel
Quoted 7 lines · David Vrabel
Quoted 6 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

So, treat an unexpected backend CLOSED state the same as CLOSING.

Didn't handle the frontend block device being mounted. Updated patch here.

Konrad, can you ack this updated patch if you're happy with it.

Or should I just carry it in my for-jens-3.7 bug-fixes queue and ask Jen to pull it once rc0 is out?

Quoted 6 lines
Quoted 1 line

This seems easiest, if Jan is happy with the patch.

I see the point of your explanation yesterday, but am still not convinced that the early cleanup in spite of active users of the disk can't cause any problems (like dangling pointers or NULL dereferences).

I tested it some more and it is broken. Please apply the first version instead.

blkfront needs to cancel and complete with an error requests that are are still on the ring after the backend has disconnected and it needs to complete with an error all requests submitted while disconnected. Otherwise, if there is outstanding requests or new requests then del_gendisk() blocks waiting for the I/O to complete.

David

#9 lore raw

Re: [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 25 lines · David Vrabel
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · David Vrabel
Quoted 9 lines · David Vrabel
Quoted 7 lines · David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Didn't handle the frontend block device being mounted. Updated patch here.

Konrad, can you ack this updated patch if you're happy with it.

Or should I just carry it in my for-jens-3.7 bug-fixes queue and ask Jen to pull it once rc0 is out?

This seems easiest, if Jan is happy with the patch.

Quoted 7 lines
Quoted 4 lines

I see the point of your explanation yesterday, but am still not convinced that the early cleanup in spite of active users of the disk can't cause any problems (like dangling pointers or NULL dereferences).

I tested it some more and it is broken. Please apply the first version instead.

OK, can we do this once more - can you repost the patches, but CC the invidiual maintainers? The FB and KBD need to go through Florian I think?

Quoted 8 lines

blkfront needs to cancel and complete with an error requests that are are still on the ring after the backend has disconnected and it needs to complete with an error all requests submitted while disconnected. Otherwise, if there is outstanding requests or new requests then del_gendisk() blocks waiting for the I/O to complete.

David

#10 lore raw

Re: [Xen-devel] [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

In reply to David Vrabel

drivers/block/xen-blkfront.c blkfront_closing(struct blkfront_info *info) · line 1175

Quoted 11 lines
Quoted 1 line
Quoted 1 line · David Vrabel
drivers/block/xen-blkfront.c +2 -1
@@ -1167,7 +1168,8 @@ blkfront_closing(struct blkfront_info *info)
 
 	mutex_lock(&bdev->bd_mutex);
 
-	if (bdev->bd_openers) {
+	/* If the backend is already CLOSED, close now. */
+	if (bdev->bd_openers && backend_state != XenbusStateClosed) {
 		xenbus_dev_error(xbdev, -EBUSY,
 				 "Device in use; refusing to close");
 		xenbus_switch_state(xbdev, XenbusStateClosing);

This looks wrong to me on a second glance: As long as there are users of the device, I don't think we want to go into Closed ourselves, irrespective of the backend state.

Jan

#11 lore raw

Re: [Xen-devel] [PATCH 2/6] xen-blkfront: handle backend CLOSED without CLOSING

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · David Vrabel
drivers/block/xen-blkfront.c +0 -0
@@ -1167,7 +1168,8 @@ blkfront_closing(struct blkfront_info *info)
 
 	mutex_lock(&bdev->bd_mutex);
 
Quoted 10 lines

drivers/block/xen-blkfront.c blkfront_closing(struct blkfront_info *info) · line 1175

Quoted 6 lines
drivers/block/xen-blkfront.c +2 -1
-	if (bdev->bd_openers) {
+	/* If the backend is already CLOSED, close now. */
+	if (bdev->bd_openers && backend_state != XenbusStateClosed) {
 		xenbus_dev_error(xbdev, -EBUSY,
 				 "Device in use; refusing to close");
 		xenbus_switch_state(xbdev, XenbusStateClosing);

This looks wrong to me on a second glance: As long as there are users of the device, I don't think we want to go into Closed ourselves, irrespective of the backend state.

Any users of the frontend device are screwed either way, as the backend is gone. It seems sensible to handle this case the same as (e.g.,) a physical unplug of a USB storage device. Removing the device and forcing all outstanding I/O to fail immediately rather than lingering in the rings, going nowhere.

David

#12 lore raw

PATCH 3/6 xen-pcifront: handle backend CLOSED without CLOSING

In reply to David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

---
 drivers/pci/xen-pcifront.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/pci/xen-pcifront.c +4 -1
index d6cc62c..b5692c3 100644
@@ -1069,13 +1069,16 @@ static void __init_refok pcifront_backend_changed(struct xenbus_device *xdev,
 	case XenbusStateInitialising:
 	case XenbusStateInitWait:
 	case XenbusStateInitialised:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateConnected:
 		pcifront_try_connect(pdev);
 		break;
 
+	case XenbusStateClosed:
+		if (xdev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's CLOSING state -- fallthrough */
 	case XenbusStateClosing:
 		dev_warn(&xdev->dev, "backend going away!\n");
 		pcifront_try_disconnect(pdev);
Signature · 1 line
1.7.2.5
#13 lore raw

PATCH 4/6 xen-fbfront: handle backend CLOSED without CLOSING

In reply to David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

---
 drivers/video/xen-fbfront.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/video/xen-fbfront.c +4 -1
index b7f5173..917bb56 100644
@@ -641,7 +641,6 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateInitWait:
@@ -670,6 +669,10 @@ InitWait:
 		info->feature_resize = val;
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state = XenbusStateClosed)
+			break;
+		/* Missed the backend's CLOSING state -- fallthrough */
 	case XenbusStateClosing:
 		xenbus_frontend_closed(dev);
 		break;
Signature · 1 line
1.7.2.5
#14 lore raw

PATCH 5/6 xen-kbdfront: handle backend CLOSED without CLOSING

In reply to David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

---
 drivers/input/misc/xen-kbdfront.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/input/misc/xen-kbdfront.c +4 -1
index 02ca868..6f7d990 100644
@@ -311,7 +311,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
 	case XenbusStateReconfiguring:
 	case XenbusStateReconfigured:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateInitWait:
@@ -350,6 +349,10 @@ InitWait:
 
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's CLOSING state -- fallthrough */
 	case XenbusStateClosing:
 		xenbus_frontend_closed(dev);
 		break;
Signature · 1 line
1.7.2.5
#15 lore raw

PATCH 6/6 xen/hvc: handle backend CLOSED without CLOSING

In reply to David Vrabel

From: David Vrabel <[email protected]>

Backend drivers shouldn't transistion to CLOSED unless the frontend is CLOSED. If a backend does transition to CLOSED too soon then the frontend may not see the CLOSING state and will not properly shutdown.

So, treat an unexpected backend CLOSED state the same as CLOSING.

---
 drivers/tty/hvc/hvc_xen.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/tty/hvc/hvc_xen.c +4 -1
index 1e456dc..82901fb 100644
@@ -476,7 +476,6 @@ static void xencons_backend_changed(struct xenbus_device *dev,
 	case XenbusStateInitialising:
 	case XenbusStateInitialised:
 	case XenbusStateUnknown:
-	case XenbusStateClosed:
 		break;
 
 	case XenbusStateInitWait:
@@ -486,6 +485,10 @@ static void xencons_backend_changed(struct xenbus_device *dev,
 		xenbus_switch_state(dev, XenbusStateConnected);
 		break;
 
+	case XenbusStateClosed:
+		if (dev->state == XenbusStateClosed)
+			break;
+		/* Missed the backend's CLOSING state -- fallthrough */
 	case XenbusStateClosing:
 		xenbus_frontend_closed(dev);
 		break;
Signature · 1 line
1.7.2.5
#16 lore raw
In reply to David Vrabel
Quoted 9 lines · David Vrabel

The series makes all the Xen frontend drivers handle the backend transitioning to CLOSED without the frontend having previously seen the backend in the CLOSING state.

Backends shouldn't do this but some do. e.g., if the host is XenServer and the toolstack decides to do a forced shutdown of a VBD, then the blkfront may miss the CLOSING transition and the /dev/xvdX device will not be destroyed which prevents it being reused.

Quoted 8 lines

I have seen systems that ended up in this state but it's not clear if this was the actual cause. However, I think in general it's a good thing to thing to improve the handling of unexpected state transitions.

Konrad, I've split this into a patch per frontend in case each patch should go via a different maintainer. But if you'd prefer, I can roll this up into one patch to via your Xen tree.

I like the split-up. Can you repost them with the different maintainers CC (scripts/get_maintainers.pl) and with Acked-by from me on them?

Quoted 2 lines

David