Make most of port methods optional and remove bunch of dummies.
This commit is contained in:
parent
c0e5e17237
commit
1b7849d0f2
@ -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) {
|
||||
|
@ -304,17 +304,21 @@ ctl_port_online(struct ctl_port *port)
|
||||
struct ctl_lun *lun;
|
||||
uint32_t l;
|
||||
|
||||
if (port->lun_map) {
|
||||
for (l = 0; l < CTL_MAX_LUNS; l++) {
|
||||
if (ctl_lun_map_from_port(port, l) >= CTL_MAX_LUNS)
|
||||
continue;
|
||||
port->lun_enable(port->targ_lun_arg, l);
|
||||
if (port->lun_enable != NULL) {
|
||||
if (port->lun_map) {
|
||||
for (l = 0; l < CTL_MAX_LUNS; l++) {
|
||||
if (ctl_lun_map_from_port(port, l) >=
|
||||
CTL_MAX_LUNS)
|
||||
continue;
|
||||
port->lun_enable(port->targ_lun_arg, l);
|
||||
}
|
||||
} else {
|
||||
STAILQ_FOREACH(lun, &softc->lun_list, links)
|
||||
port->lun_enable(port->targ_lun_arg, lun->lun);
|
||||
}
|
||||
} else {
|
||||
STAILQ_FOREACH(lun, &softc->lun_list, links)
|
||||
port->lun_enable(port->targ_lun_arg, lun->lun);
|
||||
}
|
||||
port->port_online(port->onoff_arg);
|
||||
if (port->port_online != NULL)
|
||||
port->port_online(port->onoff_arg);
|
||||
/* XXX KDM need a lock here? */
|
||||
port->status |= CTL_PORT_STATUS_ONLINE;
|
||||
}
|
||||
@ -326,16 +330,20 @@ ctl_port_offline(struct ctl_port *port)
|
||||
struct ctl_lun *lun;
|
||||
uint32_t l;
|
||||
|
||||
port->port_offline(port->onoff_arg);
|
||||
if (port->lun_map) {
|
||||
for (l = 0; l < CTL_MAX_LUNS; l++) {
|
||||
if (ctl_lun_map_from_port(port, l) >= CTL_MAX_LUNS)
|
||||
continue;
|
||||
port->lun_disable(port->targ_lun_arg, l);
|
||||
if (port->port_offline != NULL)
|
||||
port->port_offline(port->onoff_arg);
|
||||
if (port->lun_disable != NULL) {
|
||||
if (port->lun_map) {
|
||||
for (l = 0; l < CTL_MAX_LUNS; l++) {
|
||||
if (ctl_lun_map_from_port(port, l) >=
|
||||
CTL_MAX_LUNS)
|
||||
continue;
|
||||
port->lun_disable(port->targ_lun_arg, l);
|
||||
}
|
||||
} else {
|
||||
STAILQ_FOREACH(lun, &softc->lun_list, links)
|
||||
port->lun_disable(port->targ_lun_arg, lun->lun);
|
||||
}
|
||||
} else {
|
||||
STAILQ_FOREACH(lun, &softc->lun_list, links)
|
||||
port->lun_disable(port->targ_lun_arg, lun->lun);
|
||||
}
|
||||
/* XXX KDM need a lock here? */
|
||||
port->status &= ~CTL_PORT_STATUS_ONLINE;
|
||||
|
@ -98,8 +98,6 @@ int cfcs_init(void);
|
||||
static void cfcs_poll(struct cam_sim *sim);
|
||||
static void cfcs_online(void *arg);
|
||||
static void cfcs_offline(void *arg);
|
||||
static int cfcs_lun_enable(void *arg, int lun_id);
|
||||
static int cfcs_lun_disable(void *arg, int lun_id);
|
||||
static void cfcs_datamove(union ctl_io *io);
|
||||
static void cfcs_done(union ctl_io *io);
|
||||
void cfcs_action(struct cam_sim *sim, union ccb *ccb);
|
||||
@ -152,9 +150,6 @@ cfcs_init(void)
|
||||
port->port_online = cfcs_online;
|
||||
port->port_offline = cfcs_offline;
|
||||
port->onoff_arg = softc;
|
||||
port->lun_enable = cfcs_lun_enable;
|
||||
port->lun_disable = cfcs_lun_disable;
|
||||
port->targ_lun_arg = softc;
|
||||
port->fe_datamove = cfcs_datamove;
|
||||
port->fe_done = cfcs_done;
|
||||
|
||||
@ -301,17 +296,6 @@ cfcs_offline(void *arg)
|
||||
cfcs_onoffline(arg, /*online*/ 0);
|
||||
}
|
||||
|
||||
static int
|
||||
cfcs_lun_enable(void *arg, int lun_id)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
static int
|
||||
cfcs_lun_disable(void *arg, int lun_id)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is very similar to ctl_ioctl_do_datamove(). Is there a
|
||||
* way to combine the functionality?
|
||||
|
@ -65,10 +65,6 @@ static struct cfi_softc cfi_softc;
|
||||
|
||||
static int cfi_init(void);
|
||||
static void cfi_shutdown(void);
|
||||
static void cfi_online(void *arg);
|
||||
static void cfi_offline(void *arg);
|
||||
static int cfi_lun_enable(void *arg, int lun_id);
|
||||
static int cfi_lun_disable(void *arg, int lun_id);
|
||||
static void cfi_datamove(union ctl_io *io);
|
||||
static void cfi_done(union ctl_io *io);
|
||||
|
||||
@ -93,12 +89,6 @@ cfi_init(void)
|
||||
port->port_type = CTL_PORT_IOCTL;
|
||||
port->num_requested_ctl_io = 100;
|
||||
port->port_name = "ioctl";
|
||||
port->port_online = cfi_online;
|
||||
port->port_offline = cfi_offline;
|
||||
port->onoff_arg = &isoftc;
|
||||
port->lun_enable = cfi_lun_enable;
|
||||
port->lun_disable = cfi_lun_disable;
|
||||
port->targ_lun_arg = &isoftc;
|
||||
port->fe_datamove = cfi_datamove;
|
||||
port->fe_done = cfi_done;
|
||||
port->max_targets = 1;
|
||||
@ -125,30 +115,6 @@ cfi_shutdown(void)
|
||||
printf("%s: ctl_frontend_deregister() failed\n", __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
cfi_online(void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
cfi_offline(void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
cfi_lun_enable(void *arg, int lun_id)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cfi_lun_disable(void *arg, int lun_id)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Data movement routine for the CTL ioctl frontend port.
|
||||
*/
|
||||
|
@ -146,8 +146,6 @@ int cfiscsi_init(void);
|
||||
static void cfiscsi_online(void *arg);
|
||||
static void cfiscsi_offline(void *arg);
|
||||
static int cfiscsi_info(void *arg, struct sbuf *sb);
|
||||
static int cfiscsi_lun_enable(void *arg, int lun_id);
|
||||
static int cfiscsi_lun_disable(void *arg, int lun_id);
|
||||
static int cfiscsi_ioctl(struct cdev *dev,
|
||||
u_long cmd, caddr_t addr, int flag, struct thread *td);
|
||||
static void cfiscsi_datamove(union ctl_io *io);
|
||||
@ -2100,9 +2098,6 @@ cfiscsi_ioctl_port_create(struct ctl_req *req)
|
||||
port->port_offline = cfiscsi_offline;
|
||||
port->port_info = cfiscsi_info;
|
||||
port->onoff_arg = ct;
|
||||
port->lun_enable = cfiscsi_lun_enable;
|
||||
port->lun_disable = cfiscsi_lun_disable;
|
||||
port->targ_lun_arg = ct;
|
||||
port->fe_datamove = cfiscsi_datamove;
|
||||
port->fe_done = cfiscsi_done;
|
||||
|
||||
@ -2369,20 +2364,6 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name,
|
||||
return (newct);
|
||||
}
|
||||
|
||||
static int
|
||||
cfiscsi_lun_enable(void *arg, int lun_id)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cfiscsi_lun_disable(void *arg, int lun_id)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
cfiscsi_datamove_in(union ctl_io *io)
|
||||
{
|
||||
|
@ -66,10 +66,6 @@ static struct tpcl_softc tpcl_softc;
|
||||
|
||||
static int tpcl_init(void);
|
||||
static void tpcl_shutdown(void);
|
||||
static void tpcl_online(void *arg);
|
||||
static void tpcl_offline(void *arg);
|
||||
static int tpcl_lun_enable(void *arg, int lun_id);
|
||||
static int tpcl_lun_disable(void *arg, int lun_id);
|
||||
static void tpcl_datamove(union ctl_io *io);
|
||||
static void tpcl_done(union ctl_io *io);
|
||||
|
||||
@ -97,12 +93,6 @@ tpcl_init(void)
|
||||
port->port_type = CTL_PORT_INTERNAL;
|
||||
port->num_requested_ctl_io = 100;
|
||||
port->port_name = "tpc";
|
||||
port->port_online = tpcl_online;
|
||||
port->port_offline = tpcl_offline;
|
||||
port->onoff_arg = tsoftc;
|
||||
port->lun_enable = tpcl_lun_enable;
|
||||
port->lun_disable = tpcl_lun_disable;
|
||||
port->targ_lun_arg = tsoftc;
|
||||
port->fe_datamove = tpcl_datamove;
|
||||
port->fe_done = tpcl_done;
|
||||
port->max_targets = 1;
|
||||
@ -140,30 +130,6 @@ tpcl_shutdown(void)
|
||||
printf("%s: ctl_frontend_deregister() failed\n", __func__);
|
||||
}
|
||||
|
||||
static void
|
||||
tpcl_online(void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
tpcl_offline(void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
tpcl_lun_enable(void *arg, int lun_id)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
tpcl_lun_disable(void *arg, int lun_id)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
tpcl_datamove(union ctl_io *io)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user