Date: Tue, 1 Sep 2015 16:28:07 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287372 - head/sys/cam/ctl Message-ID: <201509011628.t81GS7X8086099@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue Sep 1 16:28:06 2015 New Revision: 287372 URL: https://svnweb.freebsd.org/changeset/base/287372 Log: Make most of port methods optional and remove bunch of dummies. Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_frontend.c head/sys/cam/ctl/ctl_frontend_cam_sim.c head/sys/cam/ctl/ctl_frontend_ioctl.c head/sys/cam/ctl/ctl_frontend_iscsi.c head/sys/cam/ctl/ctl_tpc_local.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Tue Sep 1 16:25:12 2015 (r287371) +++ head/sys/cam/ctl/ctl.c Tue Sep 1 16:28:06 2015 (r287372) @@ -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, u } 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, 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_lu 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_lu * 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) { Modified: head/sys/cam/ctl/ctl_frontend.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend.c Tue Sep 1 16:25:12 2015 (r287371) +++ head/sys/cam/ctl/ctl_frontend.c Tue Sep 1 16:28:06 2015 (r287372) @@ -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; Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_cam_sim.c Tue Sep 1 16:25:12 2015 (r287371) +++ head/sys/cam/ctl/ctl_frontend_cam_sim.c Tue Sep 1 16:28:06 2015 (r287372) @@ -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? Modified: head/sys/cam/ctl/ctl_frontend_ioctl.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_ioctl.c Tue Sep 1 16:25:12 2015 (r287371) +++ head/sys/cam/ctl/ctl_frontend_ioctl.c Tue Sep 1 16:28:06 2015 (r287372) @@ -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. */ Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_iscsi.c Tue Sep 1 16:25:12 2015 (r287371) +++ head/sys/cam/ctl/ctl_frontend_iscsi.c Tue Sep 1 16:28:06 2015 (r287372) @@ -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 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 cfi 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) { Modified: head/sys/cam/ctl/ctl_tpc_local.c ============================================================================== --- head/sys/cam/ctl/ctl_tpc_local.c Tue Sep 1 16:25:12 2015 (r287371) +++ head/sys/cam/ctl/ctl_tpc_local.c Tue Sep 1 16:28:06 2015 (r287372) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509011628.t81GS7X8086099>