]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Replicate port->init_devid to HA peer.
authormav <mav@FreeBSD.org>
Thu, 17 Sep 2015 20:36:34 +0000 (20:36 +0000)
committermav <mav@FreeBSD.org>
Thu, 17 Sep 2015 20:36:34 +0000 (20:36 +0000)
sys/cam/ctl/ctl.c
sys/cam/ctl/ctl_io.h

index 9ff5504f1cb34c0f2f87057839537d6fd34d2540..f256ac48373ea2c9adb8a82fd67e9f3b2eaa1bf7 100644 (file)
@@ -611,6 +611,8 @@ ctl_isc_announce_port(struct ctl_port *port)
                i += port->port_devid->len;
        if (port->target_devid)
                i += port->target_devid->len;
+       if (port->init_devid)
+               i += port->init_devid->len;
        msg = malloc(i, M_CTL, M_WAITOK);
        bzero(&msg->port, sizeof(msg->port));
        msg->hdr.msg_type = CTL_MSG_PORT_SYNC;
@@ -641,6 +643,12 @@ ctl_isc_announce_port(struct ctl_port *port)
                    msg->port.target_devid_len);
                i += msg->port.target_devid_len;
        }
+       if (port->init_devid) {
+               msg->port.init_devid_len = port->init_devid->len;
+               memcpy(&msg->port.data[i], port->init_devid->data,
+                   msg->port.init_devid_len);
+               i += msg->port.init_devid_len;
+       }
        ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg->port, sizeof(msg->port) + i,
            M_WAITOK);
        free(msg, M_CTL);
@@ -865,8 +873,23 @@ ctl_isc_port_sync(struct ctl_softc *softc, union ctl_ha_msg *msg, int len)
                port->target_devid->len = msg->port.target_devid_len;
                i += msg->port.target_devid_len;
        } else {
-               free(port->port_devid, M_CTL);
-               port->port_devid = NULL;
+               free(port->target_devid, M_CTL);
+               port->target_devid = NULL;
+       }
+       if (msg->port.init_devid_len != 0) {
+               if (port->init_devid == NULL ||
+                   port->init_devid->len != msg->port.init_devid_len) {
+                       free(port->init_devid, M_CTL);
+                       port->init_devid = malloc(sizeof(struct ctl_devid) +
+                           msg->port.init_devid_len, M_CTL, M_WAITOK);
+               }
+               memcpy(port->init_devid->data, &msg->port.data[i],
+                   msg->port.init_devid_len);
+               port->init_devid->len = msg->port.init_devid_len;
+               i += msg->port.init_devid_len;
+       } else {
+               free(port->init_devid, M_CTL);
+               port->init_devid = NULL;
        }
        if (new) {
                if (ctl_port_register(port) != 0) {
index c92cf36c0b02efd991ddf9bfcea7d6b1128334f4..86aebc9dca4691db42369b7654a764edfdf03d57 100644 (file)
@@ -479,6 +479,7 @@ struct ctl_ha_msg_port {
        int                     lun_map_len;
        int                     port_devid_len;
        int                     target_devid_len;
+       int                     init_devid_len;
        uint8_t                 data[];
 };