From: mav Date: Thu, 17 Sep 2015 20:36:34 +0000 (+0000) Subject: Replicate port->init_devid to HA peer. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7d2c7a279026bf4b73440ebe484f74cf4dba50c5;p=people%2Fjulieng%2Ffreebsd.git Replicate port->init_devid to HA peer. --- diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 9ff5504f1cb3..f256ac48373e 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -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) { diff --git a/sys/cam/ctl/ctl_io.h b/sys/cam/ctl/ctl_io.h index c92cf36c0b02..86aebc9dca46 100644 --- a/sys/cam/ctl/ctl_io.h +++ b/sys/cam/ctl/ctl_io.h @@ -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[]; };