Merge tag 'arm-soc-dt-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / drivers / block / xen-blkfront.c
index 91de2e0..188e0b4 100644 (file)
@@ -1866,8 +1866,8 @@ again:
                message = "writing protocol";
                goto abort_transaction;
        }
-       err = xenbus_printf(xbt, dev->nodename,
-                           "feature-persistent", "%u", 1);
+       err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
+                       info->feature_persistent);
        if (err)
                dev_warn(&dev->dev,
                         "writing persistent grants feature to xenbus");
@@ -1941,6 +1941,13 @@ static int negotiate_mq(struct blkfront_info *info)
        }
        return 0;
 }
+
+/* Enable the persistent grants feature. */
+static bool feature_persistent = true;
+module_param(feature_persistent, bool, 0644);
+MODULE_PARM_DESC(feature_persistent,
+               "Enables the persistent grants feature");
+
 /**
  * Entry point to this code when a new device is created.  Allocate the basic
  * structures and the ring buffer for communication with the backend, and
@@ -2007,6 +2014,8 @@ static int blkfront_probe(struct xenbus_device *dev,
        info->vdevice = vdevice;
        info->connected = BLKIF_STATE_DISCONNECTED;
 
+       info->feature_persistent = feature_persistent;
+
        /* Front end dir is a number, which is used as the id. */
        info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0);
        dev_set_drvdata(&dev->dev, info);
@@ -2144,7 +2153,7 @@ static void blkfront_closing(struct blkfront_info *info)
        }
 
        if (info->gd)
-               bdev = bdget_disk(info->gd, 0);
+               bdev = bdgrab(info->gd->part0);
 
        mutex_unlock(&info->mutex);
 
@@ -2316,9 +2325,10 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
        if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0))
                blkfront_setup_discard(info);
 
-       info->feature_persistent =
-               !!xenbus_read_unsigned(info->xbdev->otherend,
-                                      "feature-persistent", 0);
+       if (info->feature_persistent)
+               info->feature_persistent =
+                       !!xenbus_read_unsigned(info->xbdev->otherend,
+                                              "feature-persistent", 0);
 
        indirect_segments = xenbus_read_unsigned(info->xbdev->otherend,
                                        "feature-max-indirect-segments", 0);
@@ -2360,7 +2370,7 @@ static void blkfront_connect(struct blkfront_info *info)
                        return;
                printk(KERN_INFO "Setting capacity to %Lu\n",
                       sectors);
-               set_capacity_revalidate_and_notify(info->gd, sectors, true);
+               set_capacity_and_notify(info->gd, sectors);
 
                return;
        case BLKIF_STATE_SUSPENDED:
@@ -2508,7 +2518,7 @@ static int blkfront_remove(struct xenbus_device *xbdev)
 
        disk = info->gd;
        if (disk)
-               bdev = bdget_disk(disk, 0);
+               bdev = bdgrab(disk->part0);
 
        info->xbdev = NULL;
        mutex_unlock(&info->mutex);
@@ -2585,19 +2595,11 @@ out:
 static void blkif_release(struct gendisk *disk, fmode_t mode)
 {
        struct blkfront_info *info = disk->private_data;
-       struct block_device *bdev;
        struct xenbus_device *xbdev;
 
        mutex_lock(&blkfront_mutex);
-
-       bdev = bdget_disk(disk, 0);
-
-       if (!bdev) {
-               WARN(1, "Block device %s yanked out from us!\n", disk->disk_name);
+       if (disk->part0->bd_openers)
                goto out_mutex;
-       }
-       if (bdev->bd_openers)
-               goto out;
 
        /*
         * Check if we have been instructed to close. We will have
@@ -2609,7 +2611,7 @@ static void blkif_release(struct gendisk *disk, fmode_t mode)
 
        if (xbdev && xbdev->state == XenbusStateClosing) {
                /* pending switch to state closed */
-               dev_info(disk_to_dev(bdev->bd_disk), "releasing disk\n");
+               dev_info(disk_to_dev(disk), "releasing disk\n");
                xlvbd_release_gendisk(info);
                xenbus_frontend_closed(info->xbdev);
        }
@@ -2618,14 +2620,12 @@ static void blkif_release(struct gendisk *disk, fmode_t mode)
 
        if (!xbdev) {
                /* sudden device removal */
-               dev_info(disk_to_dev(bdev->bd_disk), "releasing disk\n");
+               dev_info(disk_to_dev(disk), "releasing disk\n");
                xlvbd_release_gendisk(info);
                disk->private_data = NULL;
                free_info(info);
        }
 
-out:
-       bdput(bdev);
 out_mutex:
        mutex_unlock(&blkfront_mutex);
 }