aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cam/ctl/ctl.c')
-rw-r--r--sys/cam/ctl/ctl.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 9141fc81e4a2..4e83117ee51e 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -3100,7 +3100,8 @@ ctl_lun_map_init(struct ctl_port *port)
return (ENOMEM);
for (i = 0; i < CTL_MAX_LUNS; i++)
port->lun_map[i] = UINT32_MAX;
- if (port->status & CTL_PORT_STATUS_ONLINE) {
+ if (port->status & CTL_PORT_STATUS_ONLINE &&
+ port->lun_disable != NULL) {
STAILQ_FOREACH(lun, &softc->lun_list, links)
port->lun_disable(port->targ_lun_arg, lun->lun);
}
@@ -3117,7 +3118,8 @@ ctl_lun_map_deinit(struct ctl_port *port)
return (0);
free(port->lun_map, M_CTL);
port->lun_map = NULL;
- if (port->status & CTL_PORT_STATUS_ONLINE) {
+ if (port->status & CTL_PORT_STATUS_ONLINE &&
+ port->lun_enable != NULL) {
STAILQ_FOREACH(lun, &softc->lun_list, links)
port->lun_enable(port->targ_lun_arg, lun->lun);
}
@@ -3137,7 +3139,8 @@ ctl_lun_map_set(struct ctl_port *port, uint32_t plun, uint32_t glun)
}
old = port->lun_map[plun];
port->lun_map[plun] = glun;
- if ((port->status & CTL_PORT_STATUS_ONLINE) && old >= CTL_MAX_LUNS)
+ if ((port->status & CTL_PORT_STATUS_ONLINE) && old >= CTL_MAX_LUNS &&
+ port->lun_enable != NULL)
port->lun_enable(port->targ_lun_arg, plun);
return (0);
}
@@ -3151,7 +3154,8 @@ ctl_lun_map_unset(struct ctl_port *port, uint32_t plun)
return (0);
old = port->lun_map[plun];
port->lun_map[plun] = UINT32_MAX;
- if ((port->status & CTL_PORT_STATUS_ONLINE) && old < CTL_MAX_LUNS)
+ if ((port->status & CTL_PORT_STATUS_ONLINE) && old < CTL_MAX_LUNS &&
+ port->lun_disable != NULL)
port->lun_disable(port->targ_lun_arg, plun);
return (0);
}
@@ -4319,7 +4323,7 @@ ctl_enable_lun(struct ctl_be_lun *be_lun)
for (port = STAILQ_FIRST(&softc->port_list); port != NULL; port = nport) {
nport = STAILQ_NEXT(port, links);
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0 ||
- port->lun_map != NULL)
+ port->lun_map != NULL || port->lun_enable == NULL)
continue;
/*
@@ -4366,9 +4370,9 @@ ctl_disable_lun(struct ctl_be_lun *be_lun)
STAILQ_FOREACH(port, &softc->port_list, links) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0 ||
- port->lun_map != NULL)
+ port->lun_map != NULL || port->lun_disable == NULL)
continue;
- mtx_unlock(&softc->ctl_lock);
+
/*
* Drop the lock before we call the frontend's disable
* routine, to avoid lock order reversals.
@@ -4376,6 +4380,7 @@ ctl_disable_lun(struct ctl_be_lun *be_lun)
* XXX KDM what happens if the frontend list changes while
* we're traversing it? It's unlikely, but should be handled.
*/
+ mtx_unlock(&softc->ctl_lock);
retval = port->lun_disable(port->targ_lun_arg, lun->lun);
mtx_lock(&softc->ctl_lock);
if (retval != 0) {