diff options
author | mav <mav@FreeBSD.org> | 2015-10-05 08:47:45 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-05 08:47:45 +0000 |
commit | efb416ffd85275e8fdfe63e3c63c83e3e40661e4 (patch) | |
tree | f124afa1a75f976a7dec560606ebe21bc0726f59 | |
parent | a2a611a1d815e3414f9681956a2fe90aa656400c (diff) | |
download | FreeBSD-src-efb416ffd85275e8fdfe63e3c63c83e3e40661e4.zip FreeBSD-src-efb416ffd85275e8fdfe63e3c63c83e3e40661e4.tar.gz |
MFC r287372:
Make most of port methods optional and remove bunch of dummies.
-rw-r--r-- | sys/cam/ctl/ctl.c | 19 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_frontend.c | 44 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_frontend_cam_sim.c | 16 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_frontend_ioctl.c | 34 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_frontend_iscsi.c | 19 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_tpc_local.c | 34 |
6 files changed, 38 insertions, 128 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 0e10586..8be9514 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -3102,7 +3102,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); } @@ -3119,7 +3120,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); } @@ -3139,7 +3141,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); } @@ -3153,7 +3156,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); } @@ -4321,7 +4325,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; /* @@ -4368,9 +4372,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. @@ -4378,6 +4382,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) { diff --git a/sys/cam/ctl/ctl_frontend.c b/sys/cam/ctl/ctl_frontend.c index 34baf44..5554951 100644 --- a/sys/cam/ctl/ctl_frontend.c +++ b/sys/cam/ctl/ctl_frontend.c @@ -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; diff --git a/sys/cam/ctl/ctl_frontend_cam_sim.c b/sys/cam/ctl/ctl_frontend_cam_sim.c index 97b361a..88dcb29 100644 --- a/sys/cam/ctl/ctl_frontend_cam_sim.c +++ b/sys/cam/ctl/ctl_frontend_cam_sim.c @@ -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? diff --git a/sys/cam/ctl/ctl_frontend_ioctl.c b/sys/cam/ctl/ctl_frontend_ioctl.c index 7d57314..51e8508 100644 --- a/sys/cam/ctl/ctl_frontend_ioctl.c +++ b/sys/cam/ctl/ctl_frontend_ioctl.c @@ -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. */ diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 00ca833..12a42f1 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -149,8 +149,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); @@ -2031,9 +2029,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; @@ -2297,20 +2292,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) { diff --git a/sys/cam/ctl/ctl_tpc_local.c b/sys/cam/ctl/ctl_tpc_local.c index fb1f2ac..7e66340 100644 --- a/sys/cam/ctl/ctl_tpc_local.c +++ b/sys/cam/ctl/ctl_tpc_local.c @@ -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; @@ -141,30 +131,6 @@ 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) -{ - - return (0); -} - -static int -tpcl_lun_disable(void *arg, int lun_id) -{ - - return (0); -} - -static void tpcl_datamove(union ctl_io *io) { struct ctl_sg_entry *ext_sglist, *kern_sglist; |