Merge branch 'for-3.8/drivers' of git://git.kernel.dk/linux-block
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / block / xen-blkback / xenbus.c
index f58434c2617cab4185b8c049804f1031f4226a6e..63980722db41af223941be7e83b33001c89bd9c7 100644 (file)
@@ -117,6 +117,7 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
        atomic_set(&blkif->drain, 0);
        blkif->st_print = jiffies;
        init_waitqueue_head(&blkif->waiting_to_free);
+       blkif->persistent_gnts.rb_node = NULL;
 
        return blkif;
 }
@@ -672,6 +673,13 @@ again:
 
        xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
 
+       err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", 1);
+       if (err) {
+               xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
+                                dev->nodename);
+               goto abort;
+       }
+
        err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
                            (unsigned long long)vbd_sz(&be->blkif->vbd));
        if (err) {
@@ -720,6 +728,7 @@ static int connect_ring(struct backend_info *be)
        struct xenbus_device *dev = be->dev;
        unsigned long ring_ref;
        unsigned int evtchn;
+       unsigned int pers_grants;
        char protocol[64] = "";
        int err;
 
@@ -749,8 +758,18 @@ static int connect_ring(struct backend_info *be)
                xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
                return -1;
        }
-       pr_info(DRV_PFX "ring-ref %ld, event-channel %d, protocol %d (%s)\n",
-               ring_ref, evtchn, be->blkif->blk_protocol, protocol);
+       err = xenbus_gather(XBT_NIL, dev->otherend,
+                           "feature-persistent", "%u",
+                           &pers_grants, NULL);
+       if (err)
+               pers_grants = 0;
+
+       be->blkif->vbd.feature_gnt_persistent = pers_grants;
+       be->blkif->vbd.overflow_max_grants = 0;
+
+       pr_info(DRV_PFX "ring-ref %ld, event-channel %d, protocol %d (%s) %s\n",
+               ring_ref, evtchn, be->blkif->blk_protocol, protocol,
+               pers_grants ? "persistent grants" : "");
 
        /* Map the shared frame, irq etc. */
        err = xen_blkif_map(be->blkif, ring_ref, evtchn);