Re: [PATCH] xen-blkback: Switch to closed state after releasing the backing device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 07, 2018 at 09:54:55AM +0200, Roger Pau Monné wrote:
> Then I'm afraid you will have to look into the vbd_free/create fix.

Yes, here is a first draft for that idea, let me know if you see some
problems there:

--- xenbus.c.orig       2018-09-07 12:11:57.798071485 +0200
+++ xenbus.c    2018-09-07 12:14:23.536077992 +0200
@@ -758,6 +759,7 @@
                             enum xenbus_state frontend_state)
 {
        struct backend_info *be = dev_get_drvdata(&dev->dev);
+       struct block_device *bdev;
        int err;
 
        pr_debug("%s %p %s\n", __func__, dev, xenbus_strstate(frontend_state));
@@ -772,6 +774,22 @@
 
        case XenbusStateInitialised:
        case XenbusStateConnected:
+               if (!be->blkif->vbd.bdev) {
+                       printk("blkdev_get");
+                       bdev = blkdev_get_by_dev(be->blkif->vbd.pdevice,
+                                                be->blkif->vbd.readonly ?
+                                                FMODE_READ : FMODE_WRITE, NULL);
+
+                       if (IS_ERR(bdev)) {
+                               pr_warn("frontend_changed: device %08x could not be opened\n",
+                                       be->blkif->vbd.pdevice);
+                               break;
+                       }
+
+                       printk("blkdev_get good");
+                       be->blkif->vbd.bdev = bdev;
+               }
+
                /*
                 * Ensure we connect even when two watches fire in
                 * close succession and we miss the intermediate value
@@ -808,6 +826,7 @@
 
        case XenbusStateClosed:
                xen_blkif_disconnect(be->blkif);
+               xen_vbd_free(&be->blkif->vbd);
                xenbus_switch_state(dev, XenbusStateClosed);
                if (xenbus_dev_is_online(dev))
                        break;

-- 
Valentin



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux