]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/block/xen-blkfront.c
xen-blkfront: don't call talk_to_blkback when already connected to blkback
[karo-tx-linux.git] / drivers / block / xen-blkfront.c
index 6405b65577926876587300e535490badf71f3414..6ba8891e8efe10ca5916fbb7d3aca7fc4dfcfd2a 100644 (file)
@@ -998,7 +998,8 @@ static const char *flush_info(unsigned int feature_flush)
 
 static void xlvbd_flush(struct blkfront_info *info)
 {
-       blk_queue_flush(info->rq, info->feature_flush);
+       blk_queue_write_cache(info->rq, info->feature_flush & REQ_FLUSH,
+                               info->feature_flush & REQ_FUA);
        pr_info("blkfront: %s: %s %s %s %s %s\n",
                info->gd->disk_name, flush_info(info->feature_flush),
                "persistent grants:", info->feature_persistent ?
@@ -2484,10 +2485,23 @@ static void blkback_changed(struct xenbus_device *dev,
                break;
 
        case XenbusStateConnected:
-               if (dev->state != XenbusStateInitialised) {
+               /*
+                * talk_to_blkback sets state to XenbusStateInitialised
+                * and blkfront_connect sets it to XenbusStateConnected
+                * (if connection went OK).
+                *
+                * If the backend (or toolstack) decides to poke at backend
+                * state (and re-trigger the watch by setting the state repeatedly
+                * to XenbusStateConnected (4)) we need to deal with this.
+                * This is allowed as this is used to communicate to the guest
+                * that the size of disk has changed!
+                */
+               if ((dev->state != XenbusStateInitialised) &&
+                   (dev->state != XenbusStateConnected)) {
                        if (talk_to_blkback(dev, info))
                                break;
                }
+
                blkfront_connect(info);
                break;