Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2015 08:47:45 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r288724 - stable/10/sys/cam/ctl
Message-ID:  <201510050847.t958ljcB014337@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Oct  5 08:47:45 2015
New Revision: 288724
URL: https://svnweb.freebsd.org/changeset/base/288724

Log:
  MFC r287372:
  Make most of port methods optional and remove bunch of dummies.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_frontend.c
  stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c
  stable/10/sys/cam/ctl/ctl_frontend_ioctl.c
  stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
  stable/10/sys/cam/ctl/ctl_tpc_local.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c	Mon Oct  5 08:46:48 2015	(r288723)
+++ stable/10/sys/cam/ctl/ctl.c	Mon Oct  5 08:47:45 2015	(r288724)
@@ -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, 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);
 }
@@ -3153,7 +3156,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);
 }
@@ -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_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.
@@ -4378,6 +4382,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: stable/10/sys/cam/ctl/ctl_frontend.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend.c	Mon Oct  5 08:46:48 2015	(r288723)
+++ stable/10/sys/cam/ctl/ctl_frontend.c	Mon Oct  5 08:47:45 2015	(r288724)
@@ -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: stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c	Mon Oct  5 08:46:48 2015	(r288723)
+++ stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c	Mon Oct  5 08:47:45 2015	(r288724)
@@ -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: stable/10/sys/cam/ctl/ctl_frontend_ioctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_ioctl.c	Mon Oct  5 08:46:48 2015	(r288723)
+++ stable/10/sys/cam/ctl/ctl_frontend_ioctl.c	Mon Oct  5 08:47:45 2015	(r288724)
@@ -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: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c	Mon Oct  5 08:46:48 2015	(r288723)
+++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c	Mon Oct  5 08:47:45 2015	(r288724)
@@ -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
 	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 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: stable/10/sys/cam/ctl/ctl_tpc_local.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_tpc_local.c	Mon Oct  5 08:46:48 2015	(r288723)
+++ stable/10/sys/cam/ctl/ctl_tpc_local.c	Mon Oct  5 08:47:45 2015	(r288724)
@@ -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?201510050847.t958ljcB014337>