summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-10-05 10:58:41 +0000
committermav <mav@FreeBSD.org>2015-10-05 10:58:41 +0000
commit7f0834440e6b047655d5fc24983812b0ae406eea (patch)
tree6d6e961e16f50b246c020af7b44ae5f47ce0fd00
parent44b21c856f762697e8c7929ee65f0f61134b0f28 (diff)
downloadFreeBSD-src-7f0834440e6b047655d5fc24983812b0ae406eea.zip
FreeBSD-src-7f0834440e6b047655d5fc24983812b0ae406eea.tar.gz
MFC r288211: Remove some control_softc references.
-rw-r--r--sys/cam/ctl/ctl.c52
-rw-r--r--sys/cam/ctl/ctl_backend.c14
-rw-r--r--sys/cam/ctl/ctl_frontend.c7
-rw-r--r--sys/cam/ctl/ctl_frontend.h1
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c1
-rw-r--r--sys/cam/ctl/ctl_ha.c2
6 files changed, 25 insertions, 52 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index ca09500..2020014 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -626,7 +626,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;
@@ -687,7 +687,7 @@ ctl_isc_announce_port(struct ctl_port *port)
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;
@@ -1128,12 +1128,11 @@ ctl_isc_mode_sync(struct ctl_softc *softc, union ctl_ha_msg *msg, int len)
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;
@@ -1584,13 +1583,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);
@@ -1722,11 +1719,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)
@@ -1803,7 +1798,7 @@ ctl_close(struct cdev *dev, int flags, int fmt, struct thread *td)
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);
@@ -1829,7 +1824,7 @@ ctl_remove_initiator(struct ctl_port *port, int iid)
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;
@@ -2004,15 +1999,13 @@ ctl_create_iid(struct ctl_port *port, int iid, uint8_t *buf)
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) &&
@@ -2379,12 +2372,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) {
@@ -3483,7 +3474,7 @@ ctl_get_initindex(struct ctl_nexus *nexus)
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;
@@ -3507,7 +3498,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)
@@ -4674,14 +4665,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
@@ -8726,12 +8714,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) ||
@@ -9259,7 +9246,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;
@@ -9272,6 +9259,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"));
@@ -10348,15 +10336,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
@@ -12190,11 +12176,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];
@@ -12863,13 +12847,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;
diff --git a/sys/cam/ctl/ctl_backend.c b/sys/cam/ctl/ctl_backend.c
index f243d0b..91576c4 100644
--- a/sys/cam/ctl/ctl_backend.c
+++ b/sys/cam/ctl/ctl_backend.c
@@ -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_driver *be)
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_backend_driver *be)
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);
diff --git a/sys/cam/ctl/ctl_frontend.c b/sys/cam/ctl/ctl_frontend.c
index 1caab65..06e7f22 100644
--- a/sys/cam/ctl/ctl_frontend.c
+++ b/sys/cam/ctl/ctl_frontend.c
@@ -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, int wwnn_valid, uint64_t wwnn,
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;
diff --git a/sys/cam/ctl/ctl_frontend.h b/sys/cam/ctl/ctl_frontend.h
index a6ca9e1..9a1a4ee 100644
--- a/sys/cam/ctl/ctl_frontend.h
+++ b/sys/cam/ctl/ctl_frontend.h
@@ -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 */
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index e6a99d9..e3b7c2d 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -171,7 +171,6 @@ static void cfiscsi_target_release(struct cfiscsi_target *ct);
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 =
{
diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c
index 03401ae..49eb49e 100644
--- a/sys/cam/ctl/ctl_ha.c
+++ b/sys/cam/ctl/ctl_ha.c
@@ -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)
{
OpenPOWER on IntegriCloud