From: jbeulich@suse.com
Subject: blktap: also call blkif_disconnect() when frontend switched to closed
Patch-mainline: Never, SUSE-Xen specific
References: bsc#952976

frontends aren't required to set their state to XenbusStateClosing, yet
backends should not hang on to resources when there's no connection. As
frontend_changed() already makes use of blkif_disconnect() being
idempotent, we're fine to utilize this here too. This mirrors the
respective blkback change (c/s 1162:4c2b7dcbfd8b).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/drivers/xen/blktap/xenbus.c
+++ b/drivers/xen/blktap/xenbus.c
@@ -385,13 +385,11 @@ static void tap_frontend_changed(struct
 		break;
 
 	case XenbusStateClosing:
-		blkif_disconnect(be->blkif);
-		xenbus_switch_state(dev, XenbusStateClosing);
-		break;
-
 	case XenbusStateClosed:
-		xenbus_switch_state(dev, XenbusStateClosed);
-		if (xenbus_dev_is_online(dev))
+		blkif_disconnect(be->blkif);
+		xenbus_switch_state(dev, frontend_state);
+		if (frontend_state != XenbusStateClosed ||
+		    xenbus_dev_is_online(dev))
 			break;
 		/* fall through if not online */
 	case XenbusStateUnknown:
