Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Sep 2015 07:27:24 +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: r288211 - head/sys/cam/ctl
Message-ID:  <201509250727.t8P7RO3k098255@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Sep 25 07:27:23 2015
New Revision: 288211
URL: https://svnweb.freebsd.org/changeset/base/288211

Log:
  Remove some control_softc references.

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_backend.c
  head/sys/cam/ctl/ctl_frontend.c
  head/sys/cam/ctl/ctl_frontend.h
  head/sys/cam/ctl/ctl_frontend_iscsi.c
  head/sys/cam/ctl/ctl_ha.c

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c	Fri Sep 25 05:15:27 2015	(r288210)
+++ head/sys/cam/ctl/ctl.c	Fri Sep 25 07:27:23 2015	(r288211)
@@ -624,7 +624,7 @@ alloc:
 void
 ctl_isc_announce_port(struct ctl_port *port)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	union ctl_ha_msg *msg;
 	int i;
 
@@ -685,7 +685,7 @@ ctl_isc_announce_port(struct ctl_port *p
 void
 ctl_isc_announce_iid(struct ctl_port *port, int iid)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	union ctl_ha_msg *msg;
 	int i, l;
 
@@ -1126,12 +1126,11 @@ ctl_isc_mode_sync(struct ctl_softc *soft
 static void
 ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_event event, int param)
 {
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	union ctl_io *io;
 	struct ctl_prio *presio;
 	ctl_ha_status isc_status;
 
-	softc = control_softc;
 	CTL_DEBUG_PRINT(("CTL: Isc Msg event %d\n", event));
 	if (event == CTL_HA_EVT_MSG_RECV) {
 		union ctl_ha_msg *msg, msgbuf;
@@ -1582,13 +1581,11 @@ ctl_init(void)
 	int i, error, retval;
 
 	retval = 0;
-	control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
+	softc = control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
 			       M_WAITOK | M_ZERO);
-	softc = control_softc;
 
 	softc->dev = make_dev(&ctl_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600,
 			      "cam/ctl");
-
 	softc->dev->si_drv1 = softc;
 
 	sysctl_ctx_init(&softc->sysctl_ctx);
@@ -1720,11 +1717,9 @@ ctl_init(void)
 void
 ctl_shutdown(void)
 {
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	struct ctl_lun *lun, *next_lun;
 
-	softc = (struct ctl_softc *)control_softc;
-
 	if (softc->is_single == 0) {
 		ctl_ha_msg_shutdown(softc);
 		if (ctl_ha_msg_deregister(CTL_HA_CHAN_CTL)
@@ -1801,7 +1796,7 @@ ctl_close(struct cdev *dev, int flags, i
 int
 ctl_remove_initiator(struct ctl_port *port, int iid)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 
 	mtx_assert(&softc->ctl_lock, MA_NOTOWNED);
 
@@ -1827,7 +1822,7 @@ ctl_remove_initiator(struct ctl_port *po
 int
 ctl_add_initiator(struct ctl_port *port, int iid, uint64_t wwpn, char *name)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	time_t best_time;
 	int i, best;
 
@@ -2002,15 +1997,13 @@ ctl_create_iid(struct ctl_port *port, in
 static int
 ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio)
 {
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	union ctl_ha_msg msg_info;
 	struct ctl_lun *lun;
 	const struct ctl_cmd_entry *entry;
 	int retval = 0;
 	uint32_t targ_lun;
 
-	softc = control_softc;
-
 	targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun;
 	mtx_lock(&softc->ctl_lock);
 	if ((targ_lun < CTL_MAX_LUNS) &&
@@ -2377,12 +2370,10 @@ static int
 ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 	  struct thread *td)
 {
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = dev->si_drv1;
 	struct ctl_lun *lun;
 	int retval;
 
-	softc = control_softc;
-
 	retval = 0;
 
 	switch (cmd) {
@@ -3481,7 +3472,7 @@ ctl_get_initindex(struct ctl_nexus *nexu
 int
 ctl_lun_map_init(struct ctl_port *port)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	struct ctl_lun *lun;
 	uint32_t i;
 
@@ -3505,7 +3496,7 @@ ctl_lun_map_init(struct ctl_port *port)
 int
 ctl_lun_map_deinit(struct ctl_port *port)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	struct ctl_lun *lun;
 
 	if (port->lun_map == NULL)
@@ -4672,14 +4663,11 @@ ctl_free_lun(struct ctl_lun *lun)
 static void
 ctl_create_lun(struct ctl_be_lun *be_lun)
 {
-	struct ctl_softc *softc;
-
-	softc = control_softc;
 
 	/*
 	 * ctl_alloc_lun() should handle all potential failure cases.
 	 */
-	ctl_alloc_lun(softc, NULL, be_lun);
+	ctl_alloc_lun(control_softc, NULL, be_lun);
 }
 
 int
@@ -8724,12 +8712,11 @@ done:
 static void
 ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg)
 {
+	struct ctl_softc *softc = control_softc;
 	struct ctl_lun *lun;
-	struct ctl_softc *softc;
 	int i;
 	uint32_t residx, targ_lun;
 
-	softc = control_softc;
 	targ_lun = msg->hdr.nexus.targ_mapped_lun;
 	mtx_lock(&softc->ctl_lock);
 	if ((targ_lun >= CTL_MAX_LUNS) ||
@@ -9257,7 +9244,7 @@ ctl_verify(struct ctl_scsiio *ctsio)
 int
 ctl_report_luns(struct ctl_scsiio *ctsio)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc;
 	struct scsi_report_luns *cdb;
 	struct scsi_report_luns_data *lun_data;
 	struct ctl_lun *lun, *request_lun;
@@ -9270,6 +9257,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio
 	retval = CTL_RETVAL_COMPLETE;
 	cdb = (struct scsi_report_luns *)ctsio->cdb;
 	port = ctl_io_port(&ctsio->io_hdr);
+	softc = port->ctl_softc;
 
 	CTL_DEBUG_PRINT(("ctl_report_luns\n"));
 
@@ -10346,15 +10334,13 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio
 {
 	struct scsi_inquiry_data *inq_ptr;
 	struct scsi_inquiry *cdb;
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	struct ctl_port *port;
 	struct ctl_lun *lun;
 	char *val;
 	uint32_t alloc_len, data_len;
 	ctl_port_type port_type;
 
-	softc = control_softc;
-
 	/*
 	 * Figure out whether we're talking to a Fibre Channel port or not.
 	 * We treat the ioctl front end, and any SCSI adapters, as packetized
@@ -12188,11 +12174,9 @@ ctl_handle_isc(union ctl_io *io)
 {
 	int free_io;
 	struct ctl_lun *lun;
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	uint32_t targ_lun;
 
-	softc = control_softc;
-
 	targ_lun = io->io_hdr.nexus.targ_mapped_lun;
 	lun = softc->ctl_luns[targ_lun];
 
@@ -12861,13 +12845,11 @@ static int
 ctl_datamove_remote_sgl_setup(union ctl_io *io)
 {
 	struct ctl_sg_entry *local_sglist;
-	struct ctl_softc *softc;
 	uint32_t len_to_go;
 	int retval;
 	int i;
 
 	retval = 0;
-	softc = control_softc;
 	local_sglist = io->io_hdr.local_sglist;
 	len_to_go = io->scsiio.kern_data_len;
 

Modified: head/sys/cam/ctl/ctl_backend.c
==============================================================================
--- head/sys/cam/ctl/ctl_backend.c	Fri Sep 25 05:15:27 2015	(r288210)
+++ head/sys/cam/ctl/ctl_backend.c	Fri Sep 25 07:27:23 2015	(r288211)
@@ -65,11 +65,9 @@ extern struct ctl_softc *control_softc;
 int
 ctl_backend_register(struct ctl_backend_driver *be)
 {
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	struct ctl_backend_driver *be_tmp;
 
-	softc = control_softc;
-
 	mtx_lock(&softc->ctl_lock);
 	/*
 	 * Sanity check, make sure this isn't a duplicate registration.
@@ -120,9 +118,7 @@ ctl_backend_register(struct ctl_backend_
 int
 ctl_backend_deregister(struct ctl_backend_driver *be)
 {
-	struct ctl_softc *softc;
-
-	softc = control_softc;
+	struct ctl_softc *softc = control_softc;
 
 	mtx_lock(&softc->ctl_lock);
 
@@ -153,20 +149,16 @@ ctl_backend_deregister(struct ctl_backen
 struct ctl_backend_driver *
 ctl_backend_find(char *backend_name)
 {
-	struct ctl_softc *softc;
+	struct ctl_softc *softc = control_softc;
 	struct ctl_backend_driver *be_tmp;
 
-	softc = control_softc;
-
 	mtx_lock(&softc->ctl_lock);
-
 	STAILQ_FOREACH(be_tmp, &softc->be_list, links) {
 		if (strcmp(be_tmp->name, backend_name) == 0) {
 			mtx_unlock(&softc->ctl_lock);
 			return (be_tmp);
 		}
 	}
-
 	mtx_unlock(&softc->ctl_lock);
 
 	return (NULL);

Modified: head/sys/cam/ctl/ctl_frontend.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend.c	Fri Sep 25 05:15:27 2015	(r288210)
+++ head/sys/cam/ctl/ctl_frontend.c	Fri Sep 25 07:27:23 2015	(r288211)
@@ -148,6 +148,7 @@ ctl_port_register(struct ctl_port *port)
 	retval = 0;
 
 	KASSERT(softc != NULL, ("CTL is not initialized"));
+	port->ctl_softc = softc;
 
 	mtx_lock(&softc->ctl_lock);
 	if (port->targ_port >= 0)
@@ -218,7 +219,7 @@ error:
 int
 ctl_port_deregister(struct ctl_port *port)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	struct ctl_io_pool *pool;
 	int retval, i;
 
@@ -309,7 +310,7 @@ ctl_port_set_wwns(struct ctl_port *port,
 void
 ctl_port_online(struct ctl_port *port)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	struct ctl_lun *lun;
 	uint32_t l;
 
@@ -344,7 +345,7 @@ ctl_port_online(struct ctl_port *port)
 void
 ctl_port_offline(struct ctl_port *port)
 {
-	struct ctl_softc *softc = control_softc;
+	struct ctl_softc *softc = port->ctl_softc;
 	struct ctl_lun *lun;
 	uint32_t l;
 

Modified: head/sys/cam/ctl/ctl_frontend.h
==============================================================================
--- head/sys/cam/ctl/ctl_frontend.h	Fri Sep 25 05:15:27 2015	(r288210)
+++ head/sys/cam/ctl/ctl_frontend.h	Fri Sep 25 07:27:23 2015	(r288211)
@@ -211,6 +211,7 @@ struct ctl_wwpn_iid {
  *			  shouldn't touch this field.
  */
 struct ctl_port {
+	struct ctl_softc *ctl_softc;
 	struct ctl_frontend *frontend;
 	ctl_port_type	port_type;		/* passed to CTL */
 	int		num_requested_ctl_io;	/* passed to CTL */

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.c	Fri Sep 25 05:15:27 2015	(r288210)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c	Fri Sep 25 07:27:23 2015	(r288211)
@@ -174,7 +174,6 @@ static void	cfiscsi_target_release(struc
 static void	cfiscsi_session_delete(struct cfiscsi_session *cs);
 
 static struct cfiscsi_softc cfiscsi_softc;
-extern struct ctl_softc *control_softc;
 
 static struct ctl_frontend cfiscsi_frontend =
 {

Modified: head/sys/cam/ctl/ctl_ha.c
==============================================================================
--- head/sys/cam/ctl/ctl_ha.c	Fri Sep 25 05:15:27 2015	(r288210)
+++ head/sys/cam/ctl/ctl_ha.c	Fri Sep 25 07:27:23 2015	(r288211)
@@ -160,8 +160,6 @@ struct ha_softc {
 	TAILQ_HEAD(, ctl_ha_dt_req) ha_dts;
 } ha_softc;
 
-extern struct ctl_softc *control_softc;
-
 static void
 ctl_ha_conn_wake(struct ha_softc *softc)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509250727.t8P7RO3k098255>