]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen-blkback: emit active physical device to xenstore
authorAnkur Arora <ankur.a.arora@oracle.com>
Thu, 30 Aug 2018 02:27:34 +0000 (19:27 -0700)
committerBrian Maly <brian.maly@oracle.com>
Mon, 8 Oct 2018 15:43:24 +0000 (11:43 -0400)
The vbd physical-device is set by user-space writing to device's xenbus
path:
/local/domain/0/backend/vbd/1/51712/physical-device = "<major>:<minor>"

However, there is no way for the blkback driver to specify the current
state of the physical-device. Accordingly we add two new backend paths:

.../vbd/<domain>/51712/oracle/active-physical-device = "<major>:<minor>"
.../vbd/<domain>/51712/oracle/physical-device-change-status = "<error>"

which specify the active physical device and any error incurred in
trying to instantiate a new physical device.

Orabug: 28651655

Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/block/xen-blkback/xenbus.c
include/xen/interface/io/blkif.h

index 34f0f9f4ff5bf139fd64b55596789e01733c37a2..61de4777e2725785b29458ccb9ec0e765bd91bf9 100644 (file)
@@ -591,6 +591,35 @@ int xen_blkbk_barrier(struct xenbus_transaction xbt,
        return err;
 }
 
+static int xen_emit_oracle_phys_device(struct xenbus_device *dev,
+                                       u32 major, u32 minor, int status)
+{
+       struct xenbus_transaction xbt;
+       int err;
+
+       err = xenbus_transaction_start(&xbt);
+       if (err)
+               return err;
+
+       err = xenbus_printf(xbt, dev->nodename, "oracle/active-physical-device",
+                               "%x:%x", major, minor);
+       if (err)
+               goto abort;
+
+       err = xenbus_printf(xbt, dev->nodename,
+                               "oracle/physical-device-change-status",
+                               "%d", status);
+       if (err)
+               goto abort;
+       xenbus_transaction_end(xbt, 0);
+
+       return 0;
+
+abort:
+       xenbus_transaction_end(xbt, 1);
+       return err;
+}
+
 /*
  * Entry point to this code when a new device is created.  Allocate the basic
  * structures, and watch the store waiting for the hotplug scripts to tell us
@@ -639,6 +668,11 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
        /* setup back pointer */
        be->blkif->be = be;
 
+       err = xen_emit_oracle_phys_device(dev, 0, 0, 0);
+
+       if (err)
+               pr_warn("Failed writing oracle/active-physical-device\n");
+
        err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed,
                                   "%s/%s", dev->nodename, "physical-device");
        if (err)
@@ -765,7 +799,20 @@ sysfs_out:
        if (err)
                memset(&be->params, 0, sizeof(be->params));
 out:
-       return;
+       /*
+        * err  = 0: emit new vbd, err = 0 to the xenbus
+        * err != 0: emit unchanged vbd, err to the xenbus
+        */
+       err = xen_emit_oracle_phys_device(dev, be->params.major,
+                                               be->params.minor, err);
+       if (err) {
+               /*
+                * Fatal failure because user-space might be waiting
+                * on this xenbus entry.
+                */
+               xenbus_dev_fatal(dev, err,
+                       "Failed in writing oracle/active-physical-device");
+       }
 }
 
 /*
index 8b8cfadf7833b6f2f29f4c290711d36726b107f9..c2139acb39243156895b57c51e15f99f466ac144 100644 (file)
@@ -75,6 +75,33 @@ typedef uint64_t blkif_sector_t;
  *
  */
 
+/*
+ * Vendor Extensions
+ * =================
+ *
+ * Volume Swapping:
+ *
+ * blkback plugs in the backing volume based on changes to the "physical-device"
+ * xenstore key.
+ *
+ * Once the backing volume is plugged in, blkback writes to the
+ * "oracle/active-physical-device" with the now active volume, and
+ * "oracle/physical-device-status" with the error code. The error
+ * code follows backend OS convention. On Linux, defined in
+ * /usr/include/asm/errno*h.
+ *
+ * For instance, the toolstack plugging in a guest disk would write:
+ *
+ * /local/domain/0/backend/vbd/<domid>/51712/physical-device  = "1a:2"
+ *
+ * And backend would validate and plug in the new physical device and its
+ * status (e.g. in case of errors):
+ *
+ * /local/domain/0/backend/vbd/<domid>/51712/oracle/active-physical-device = "1a:2"
+ * /local/domain/0/backend/vbd/<domid>/51712/oracle/physical-device-status = "0"
+ *
+ */
+
 /*
  * REQUEST CODES.
  */