svn commit: r276614 - stable/10/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Sat Jan 3 13:09:34 UTC 2015
Author: mav
Date: Sat Jan 3 13:09:32 2015
New Revision: 276614
URL: https://svnweb.freebsd.org/changeset/base/276614
Log:
MFC r275942: Reduce number of places where global control_softc is used.
At some point we may want to have several CTL instances, and that is not
really impossible.
Modified:
stable/10/sys/cam/ctl/ctl.c
stable/10/sys/cam/ctl/ctl_backend.c
stable/10/sys/cam/ctl/ctl_frontend.c
stable/10/sys/cam/ctl/ctl_tpc.c
stable/10/sys/cam/ctl/ctl_tpc.h
stable/10/sys/cam/ctl/ctl_tpc_local.c
stable/10/sys/cam/ctl/scsi_ctl.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c Sat Jan 3 13:08:08 2015 (r276613)
+++ stable/10/sys/cam/ctl/ctl.c Sat Jan 3 13:09:32 2015 (r276614)
@@ -400,8 +400,8 @@ static int ctl_ioctl_fill_ooa(struct ctl
struct ctl_ooa_entry *kern_entries);
static int ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td);
-static uint32_t ctl_map_lun(int port_num, uint32_t lun);
-static uint32_t ctl_map_lun_back(int port_num, uint32_t lun);
+static uint32_t ctl_map_lun(struct ctl_softc *softc, int port_num, uint32_t lun);
+static uint32_t ctl_map_lun_back(struct ctl_softc *softc, int port_num, uint32_t lun);
static int ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *lun,
struct ctl_be_lun *be_lun, struct ctl_id target_id);
static int ctl_free_lun(struct ctl_lun *lun);
@@ -443,8 +443,7 @@ static ctl_action ctl_check_for_blockage
static ctl_action ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io,
union ctl_io *starting_io);
static int ctl_check_blocked(struct ctl_lun *lun);
-static int ctl_scsiio_lun_check(struct ctl_softc *ctl_softc,
- struct ctl_lun *lun,
+static int ctl_scsiio_lun_check(struct ctl_lun *lun,
const struct ctl_cmd_entry *entry,
struct ctl_scsiio *ctsio);
//static int ctl_check_rtr(union ctl_io *pending_io, struct ctl_softc *softc);
@@ -611,12 +610,12 @@ ctl_isc_handler_finish_ser_only(struct c
static void
ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_event event, int param)
{
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
union ctl_io *io;
struct ctl_prio *presio;
ctl_ha_status isc_status;
- ctl_softc = control_softc;
+ softc = control_softc;
io = NULL;
@@ -642,7 +641,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
#if 0
printf("Serialize\n");
#endif
- io = ctl_alloc_io_nowait(ctl_softc->othersc_pool);
+ io = ctl_alloc_io_nowait(softc->othersc_pool);
if (io == NULL) {
printf("ctl_isc_event_handler: can't allocate "
"ctl_io!\n");
@@ -674,7 +673,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
*
* XXX KDM add another flag that is more specific.
*/
- if (ctl_softc->ha_mode == CTL_HA_MODE_SER_ONLY)
+ if (softc->ha_mode == CTL_HA_MODE_SER_ONLY)
io->io_hdr.flags |= CTL_FLAG_INT_COPY;
io->io_hdr.nexus = msg_info.hdr.nexus;
#if 0
@@ -688,7 +687,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
io->scsiio.tag_type = msg_info.scsi.tag_type;
memcpy(io->scsiio.cdb, msg_info.scsi.cdb,
CTL_MAX_CDBLEN);
- if (ctl_softc->ha_mode == CTL_HA_MODE_XFER) {
+ if (softc->ha_mode == CTL_HA_MODE_XFER) {
const struct ctl_cmd_entry *entry;
entry = ctl_get_cmd_entry(&io->scsiio, NULL);
@@ -854,11 +853,11 @@ ctl_isc_event_handler(ctl_ha_channel cha
* mode
*/
case CTL_MSG_FINISH_IO:
- if (ctl_softc->ha_mode == CTL_HA_MODE_XFER)
- ctl_isc_handler_finish_xfer(ctl_softc,
+ if (softc->ha_mode == CTL_HA_MODE_XFER)
+ ctl_isc_handler_finish_xfer(softc,
&msg_info);
else
- ctl_isc_handler_finish_ser_only(ctl_softc,
+ ctl_isc_handler_finish_ser_only(softc,
&msg_info);
break;
@@ -888,7 +887,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
case CTL_MSG_MANAGE_TASKS: {
struct ctl_taskio *taskio;
taskio = (struct ctl_taskio *)ctl_alloc_io_nowait(
- ctl_softc->othersc_pool);
+ softc->othersc_pool);
if (taskio == NULL) {
printf("ctl_isc_event_handler: can't allocate "
"ctl_io!\n");
@@ -917,7 +916,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
/* Persistent Reserve action which needs attention */
case CTL_MSG_PERS_ACTION:
presio = (struct ctl_prio *)ctl_alloc_io_nowait(
- ctl_softc->othersc_pool);
+ softc->othersc_pool);
if (presio == NULL) {
printf("ctl_isc_event_handler: can't allocate "
"ctl_io!\n");
@@ -1834,16 +1833,16 @@ bailout:
static int
ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio)
{
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
union ctl_ha_msg msg_info;
struct ctl_lun *lun;
int retval = 0;
uint32_t targ_lun;
- ctl_softc = control_softc;
+ softc = control_softc;
targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun;
- lun = ctl_softc->ctl_luns[targ_lun];
+ lun = softc->ctl_luns[targ_lun];
if (lun==NULL)
{
/*
@@ -1888,7 +1887,7 @@ ctl_serialize_other_sc_cmd(struct ctl_sc
break;
case CTL_ACTION_PASS:
case CTL_ACTION_SKIP:
- if (ctl_softc->ha_mode == CTL_HA_MODE_XFER) {
+ if (softc->ha_mode == CTL_HA_MODE_XFER) {
ctsio->io_hdr.flags |= CTL_FLAG_IS_WAS_ON_RTR;
ctl_enqueue_rtr((union ctl_io *)ctsio);
} else {
@@ -3604,11 +3603,11 @@ ctl_port_idx(int port_num)
}
static uint32_t
-ctl_map_lun(int port_num, uint32_t lun_id)
+ctl_map_lun(struct ctl_softc *softc, int port_num, uint32_t lun_id)
{
struct ctl_port *port;
- port = control_softc->ctl_ports[ctl_port_idx(port_num)];
+ port = softc->ctl_ports[ctl_port_idx(port_num)];
if (port == NULL)
return (UINT32_MAX);
if (port->lun_map == NULL)
@@ -3617,12 +3616,12 @@ ctl_map_lun(int port_num, uint32_t lun_i
}
static uint32_t
-ctl_map_lun_back(int port_num, uint32_t lun_id)
+ctl_map_lun_back(struct ctl_softc *softc, int port_num, uint32_t lun_id)
{
struct ctl_port *port;
uint32_t i;
- port = control_softc->ctl_ports[ctl_port_idx(port_num)];
+ port = softc->ctl_ports[ctl_port_idx(port_num)];
if (port->lun_map == NULL)
return (lun_id);
for (i = 0; i < CTL_MAX_LUNS; i++) {
@@ -4779,25 +4778,25 @@ ctl_free_lun(struct ctl_lun *lun)
static void
ctl_create_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
- ctl_softc = control_softc;
+ softc = control_softc;
/*
* ctl_alloc_lun() should handle all potential failure cases.
*/
- ctl_alloc_lun(ctl_softc, NULL, be_lun, ctl_softc->target);
+ ctl_alloc_lun(softc, NULL, be_lun, softc->target);
}
int
ctl_add_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc = control_softc;
+ struct ctl_softc *softc = control_softc;
- mtx_lock(&ctl_softc->ctl_lock);
- STAILQ_INSERT_TAIL(&ctl_softc->pending_lun_queue, be_lun, links);
- mtx_unlock(&ctl_softc->ctl_lock);
- wakeup(&ctl_softc->pending_lun_queue);
+ mtx_lock(&softc->ctl_lock);
+ STAILQ_INSERT_TAIL(&softc->pending_lun_queue, be_lun, links);
+ mtx_unlock(&softc->ctl_lock);
+ wakeup(&softc->pending_lun_queue);
return (0);
}
@@ -4805,16 +4804,15 @@ ctl_add_lun(struct ctl_be_lun *be_lun)
int
ctl_enable_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
struct ctl_port *port, *nport;
struct ctl_lun *lun;
int retval;
- ctl_softc = control_softc;
-
lun = (struct ctl_lun *)be_lun->ctl_lun;
+ softc = lun->ctl_softc;
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
mtx_lock(&lun->lun_lock);
if ((lun->flags & CTL_LUN_DISABLED) == 0) {
/*
@@ -4822,13 +4820,13 @@ ctl_enable_lun(struct ctl_be_lun *be_lun
* enabled?
*/
mtx_unlock(&lun->lun_lock);
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
return (0);
}
lun->flags &= ~CTL_LUN_DISABLED;
mtx_unlock(&lun->lun_lock);
- for (port = STAILQ_FIRST(&ctl_softc->port_list); port != NULL; port = nport) {
+ for (port = STAILQ_FIRST(&softc->port_list); port != NULL; port = nport) {
nport = STAILQ_NEXT(port, links);
/*
@@ -4836,9 +4834,9 @@ ctl_enable_lun(struct ctl_be_lun *be_lun
* This can lead to a callback into CTL (at least in the
* case of the internal initiator frontend.
*/
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
retval = port->lun_enable(port->targ_lun_arg, lun->target,lun->lun);
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
if (retval != 0) {
printf("%s: FETD %s port %d returned error "
"%d for lun_enable on target %ju lun %jd\n",
@@ -4853,7 +4851,7 @@ ctl_enable_lun(struct ctl_be_lun *be_lun
#endif
}
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
return (0);
}
@@ -4861,27 +4859,26 @@ ctl_enable_lun(struct ctl_be_lun *be_lun
int
ctl_disable_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
struct ctl_port *port;
struct ctl_lun *lun;
int retval;
- ctl_softc = control_softc;
-
lun = (struct ctl_lun *)be_lun->ctl_lun;
+ softc = lun->ctl_softc;
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
mtx_lock(&lun->lun_lock);
if (lun->flags & CTL_LUN_DISABLED) {
mtx_unlock(&lun->lun_lock);
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
return (0);
}
lun->flags |= CTL_LUN_DISABLED;
mtx_unlock(&lun->lun_lock);
- STAILQ_FOREACH(port, &ctl_softc->port_list, links) {
- mtx_unlock(&ctl_softc->ctl_lock);
+ STAILQ_FOREACH(port, &softc->port_list, links) {
+ mtx_unlock(&softc->ctl_lock);
/*
* Drop the lock before we call the frontend's disable
* routine, to avoid lock order reversals.
@@ -4891,7 +4888,7 @@ ctl_disable_lun(struct ctl_be_lun *be_lu
*/
retval = port->lun_disable(port->targ_lun_arg, lun->target,
lun->lun);
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
if (retval != 0) {
printf("ctl_alloc_lun: FETD %s port %d returned error "
"%d for lun_disable on target %ju lun %jd\n",
@@ -4900,7 +4897,7 @@ ctl_disable_lun(struct ctl_be_lun *be_lu
}
}
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
return (0);
}
@@ -4908,80 +4905,55 @@ ctl_disable_lun(struct ctl_be_lun *be_lu
int
ctl_start_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
- struct ctl_lun *lun;
-
- ctl_softc = control_softc;
-
- lun = (struct ctl_lun *)be_lun->ctl_lun;
+ struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun;
mtx_lock(&lun->lun_lock);
lun->flags &= ~CTL_LUN_STOPPED;
mtx_unlock(&lun->lun_lock);
-
return (0);
}
int
ctl_stop_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
- struct ctl_lun *lun;
-
- ctl_softc = control_softc;
-
- lun = (struct ctl_lun *)be_lun->ctl_lun;
+ struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun;
mtx_lock(&lun->lun_lock);
lun->flags |= CTL_LUN_STOPPED;
mtx_unlock(&lun->lun_lock);
-
return (0);
}
int
ctl_lun_offline(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
- struct ctl_lun *lun;
-
- ctl_softc = control_softc;
-
- lun = (struct ctl_lun *)be_lun->ctl_lun;
+ struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun;
mtx_lock(&lun->lun_lock);
lun->flags |= CTL_LUN_OFFLINE;
mtx_unlock(&lun->lun_lock);
-
return (0);
}
int
ctl_lun_online(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
- struct ctl_lun *lun;
-
- ctl_softc = control_softc;
-
- lun = (struct ctl_lun *)be_lun->ctl_lun;
+ struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun;
mtx_lock(&lun->lun_lock);
lun->flags &= ~CTL_LUN_OFFLINE;
mtx_unlock(&lun->lun_lock);
-
return (0);
}
int
ctl_invalidate_lun(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
struct ctl_lun *lun;
- ctl_softc = control_softc;
-
lun = (struct ctl_lun *)be_lun->ctl_lun;
+ softc = lun->ctl_softc;
mtx_lock(&lun->lun_lock);
@@ -5004,9 +4976,9 @@ ctl_invalidate_lun(struct ctl_be_lun *be
*/
if (TAILQ_EMPTY(&lun->ooa_queue)) {
mtx_unlock(&lun->lun_lock);
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
ctl_free_lun(lun);
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
} else
mtx_unlock(&lun->lun_lock);
@@ -5016,32 +4988,22 @@ ctl_invalidate_lun(struct ctl_be_lun *be
int
ctl_lun_inoperable(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
- struct ctl_lun *lun;
-
- ctl_softc = control_softc;
- lun = (struct ctl_lun *)be_lun->ctl_lun;
+ struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun;
mtx_lock(&lun->lun_lock);
lun->flags |= CTL_LUN_INOPERABLE;
mtx_unlock(&lun->lun_lock);
-
return (0);
}
int
ctl_lun_operable(struct ctl_be_lun *be_lun)
{
- struct ctl_softc *ctl_softc;
- struct ctl_lun *lun;
-
- ctl_softc = control_softc;
- lun = (struct ctl_lun *)be_lun->ctl_lun;
+ struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun;
mtx_lock(&lun->lun_lock);
lun->flags &= ~CTL_LUN_INOPERABLE;
mtx_unlock(&lun->lun_lock);
-
return (0);
}
@@ -5227,7 +5189,6 @@ int
ctl_scsi_release(struct ctl_scsiio *ctsio)
{
int length, longid, thirdparty_id, resv_id;
- struct ctl_softc *ctl_softc;
struct ctl_lun *lun;
uint32_t residx;
@@ -5238,7 +5199,6 @@ ctl_scsi_release(struct ctl_scsiio *ctsi
residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
- ctl_softc = control_softc;
switch (ctsio->cdb[0]) {
case RELEASE_10: {
@@ -5315,7 +5275,6 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsi
int extent, thirdparty, longid;
int resv_id, length;
uint64_t thirdparty_id;
- struct ctl_softc *ctl_softc;
struct ctl_lun *lun;
uint32_t residx;
@@ -5330,7 +5289,6 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsi
residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
- ctl_softc = control_softc;
switch (ctsio->cdb[0]) {
case RESERVE_10: {
@@ -5404,13 +5362,11 @@ ctl_start_stop(struct ctl_scsiio *ctsio)
{
struct scsi_start_stop_unit *cdb;
struct ctl_lun *lun;
- struct ctl_softc *ctl_softc;
int retval;
CTL_DEBUG_PRINT(("ctl_start_stop\n"));
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
- ctl_softc = control_softc;
retval = 0;
cdb = (struct scsi_start_stop_unit *)ctsio->cdb;
@@ -5531,7 +5487,7 @@ int
ctl_sync_cache(struct ctl_scsiio *ctsio)
{
struct ctl_lun *lun;
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
uint64_t starting_lba;
uint32_t block_count;
int retval;
@@ -5539,7 +5495,7 @@ ctl_sync_cache(struct ctl_scsiio *ctsio)
CTL_DEBUG_PRINT(("ctl_sync_cache\n"));
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
- ctl_softc = control_softc;
+ softc = lun->ctl_softc;
retval = 0;
switch (ctsio->cdb[0]) {
@@ -5592,7 +5548,7 @@ ctl_sync_cache(struct ctl_scsiio *ctsio)
* CACHE command directly to the back end.
*/
mtx_lock(&lun->lun_lock);
- if ((ctl_softc->flags & CTL_FLAG_REAL_SYNC)
+ if ((softc->flags & CTL_FLAG_REAL_SYNC)
&& (++(lun->sync_count) >= lun->sync_interval)) {
lun->sync_count = 0;
mtx_unlock(&lun->lun_lock);
@@ -5613,13 +5569,11 @@ ctl_format(struct ctl_scsiio *ctsio)
{
struct scsi_format *cdb;
struct ctl_lun *lun;
- struct ctl_softc *ctl_softc;
int length, defect_list_len;
CTL_DEBUG_PRINT(("ctl_format\n"));
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
- ctl_softc = control_softc;
cdb = (struct scsi_format *)ctsio->cdb;
@@ -6077,7 +6031,6 @@ ctl_control_page_handler(struct ctl_scsi
{
struct scsi_control_page *current_cp, *saved_cp, *user_cp;
struct ctl_lun *lun;
- struct ctl_softc *softc;
int set_ua;
uint32_t initidx;
@@ -6093,8 +6046,6 @@ ctl_control_page_handler(struct ctl_scsi
(page_index->page_data + (page_index->page_len *
CTL_PAGE_SAVED));
- softc = control_softc;
-
mtx_lock(&lun->lun_lock);
if (((current_cp->rlec & SCP_DSENSE) == 0)
&& ((user_cp->rlec & SCP_DSENSE) != 0)) {
@@ -7360,8 +7311,8 @@ ctl_report_tagret_port_groups(struct ctl
CTL_DEBUG_PRINT(("ctl_report_tagret_port_groups\n"));
cdb = (struct scsi_maintenance_in *)ctsio->cdb;
- softc = control_softc;
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+ softc = lun->ctl_softc;
retval = CTL_RETVAL_COMPLETE;
@@ -7392,7 +7343,8 @@ ctl_report_tagret_port_groups(struct ctl
STAILQ_FOREACH(port, &softc->port_list, links) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
- if (ctl_map_lun_back(port->targ_port, lun->lun) >= CTL_MAX_LUNS)
+ if (ctl_map_lun_back(softc, port->targ_port, lun->lun) >=
+ CTL_MAX_LUNS)
continue;
num_target_ports++;
}
@@ -7465,8 +7417,8 @@ ctl_report_tagret_port_groups(struct ctl
STAILQ_FOREACH(port, &softc->port_list, links) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
- if (ctl_map_lun_back(port->targ_port, lun->lun) >=
- CTL_MAX_LUNS)
+ if (ctl_map_lun_back(softc, port->targ_port, lun->lun)
+ >= CTL_MAX_LUNS)
continue;
p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS;
scsi_ulto2b(p, tpg_desc->descriptors[pc].
@@ -7758,13 +7710,12 @@ ctl_persistent_reserve_in(struct ctl_scs
CTL_DEBUG_PRINT(("ctl_persistent_reserve_in\n"));
- softc = control_softc;
-
cdb = (struct scsi_per_res_in *)ctsio->cdb;
alloc_len = scsi_2btoul(cdb->length);
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+ softc = lun->ctl_softc;
retry:
mtx_lock(&lun->lun_lock);
@@ -8387,10 +8338,9 @@ ctl_persistent_reserve_out(struct ctl_sc
retval = CTL_RETVAL_COMPLETE;
- softc = control_softc;
-
cdb = (struct scsi_per_res_out *)ctsio->cdb;
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+ softc = lun->ctl_softc;
/*
* We only support whole-LUN scope. The scope & type are ignored for
@@ -9306,6 +9256,7 @@ ctl_verify(struct ctl_scsiio *ctsio)
int
ctl_report_luns(struct ctl_scsiio *ctsio)
{
+ struct ctl_softc *softc = control_softc;
struct scsi_report_luns *cdb;
struct scsi_report_luns_data *lun_data;
struct ctl_lun *lun, *request_lun;
@@ -9321,9 +9272,9 @@ ctl_report_luns(struct ctl_scsiio *ctsio
CTL_DEBUG_PRINT(("ctl_report_luns\n"));
- mtx_lock(&control_softc->ctl_lock);
- num_luns = control_softc->num_luns;
- mtx_unlock(&control_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
+ num_luns = softc->num_luns;
+ mtx_unlock(&softc->ctl_lock);
switch (cdb->select_report) {
case RPL_REPORT_DEFAULT:
@@ -9375,12 +9326,13 @@ ctl_report_luns(struct ctl_scsiio *ctsio
initidx = ctl_get_initindex(&ctsio->io_hdr.nexus);
- mtx_lock(&control_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
for (targ_lun_id = 0, num_filled = 0; targ_lun_id < CTL_MAX_LUNS && num_filled < num_luns; targ_lun_id++) {
- lun_id = ctl_map_lun(ctsio->io_hdr.nexus.targ_port, targ_lun_id);
+ lun_id = ctl_map_lun(softc, ctsio->io_hdr.nexus.targ_port,
+ targ_lun_id);
if (lun_id >= CTL_MAX_LUNS)
continue;
- lun = control_softc->ctl_luns[lun_id];
+ lun = softc->ctl_luns[lun_id];
if (lun == NULL)
continue;
@@ -9436,7 +9388,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio
mtx_unlock(&lun->lun_lock);
}
}
- mtx_unlock(&control_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
/*
* It's quite possible that we've returned fewer LUNs than we allocated
@@ -9871,15 +9823,15 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio
{
struct scsi_vpd_device_id *devid_ptr;
struct scsi_vpd_id_descriptor *desc;
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
struct ctl_lun *lun;
struct ctl_port *port;
int data_len;
uint8_t proto;
- ctl_softc = control_softc;
+ softc = control_softc;
- port = ctl_softc->ctl_ports[ctl_port_idx(ctsio->io_hdr.nexus.targ_port)];
+ port = softc->ctl_ports[ctl_port_idx(ctsio->io_hdr.nexus.targ_port)];
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
data_len = sizeof(struct scsi_vpd_device_id) +
@@ -10013,7 +9965,7 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
if (lun != NULL &&
- ctl_map_lun_back(port->targ_port, lun->lun) >=
+ ctl_map_lun_back(softc, port->targ_port, lun->lun) >=
CTL_MAX_LUNS)
continue;
num_target_ports++;
@@ -10067,8 +10019,8 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
continue;
if (lun != NULL &&
- ctl_map_lun_back(port->targ_port, lun->lun) >=
- CTL_MAX_LUNS)
+ ctl_map_lun_back(softc, port->targ_port, lun->lun)
+ >= CTL_MAX_LUNS)
continue;
p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS;
scsi_ulto2b(p, pd->relative_port_id);
@@ -10344,20 +10296,20 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio
{
struct scsi_inquiry_data *inq_ptr;
struct scsi_inquiry *cdb;
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
struct ctl_lun *lun;
char *val;
uint32_t alloc_len, data_len;
ctl_port_type port_type;
- ctl_softc = control_softc;
+ 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
* SCSI front ends.
*/
- port_type = ctl_softc->ctl_ports[
+ port_type = softc->ctl_ports[
ctl_port_idx(ctsio->io_hdr.nexus.targ_port)]->port_type;
if (port_type == CTL_PORT_IOCTL || port_type == CTL_PORT_INTERNAL)
port_type = CTL_PORT_SCSI;
@@ -10434,7 +10386,7 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio
if (lun != NULL)
inq_ptr->device = (SID_QUAL_LU_CONNECTED << 5) |
lun->be_lun->lun_type;
- else if (ctl_softc->inquiry_pq_no_lun == 0)
+ else if (softc->inquiry_pq_no_lun == 0)
inq_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT;
else
inq_ptr->device = (SID_QUAL_BAD_LU << 5) | T_NODEVICE;
@@ -11067,7 +11019,6 @@ ctl_check_blocked(struct ctl_lun *lun)
break;
case CTL_ACTION_PASS:
case CTL_ACTION_SKIP: {
- struct ctl_softc *softc;
const struct ctl_cmd_entry *entry;
int isc_retval;
@@ -11106,7 +11057,6 @@ ctl_check_blocked(struct ctl_lun *lun)
break;
}
entry = ctl_get_cmd_entry(&cur_blocked->scsiio, NULL);
- softc = control_softc;
/*
* Check this I/O for LUN state changes that may
@@ -11116,7 +11066,7 @@ ctl_check_blocked(struct ctl_lun *lun)
* for any states that can be caused by SCSI
* commands.
*/
- if (ctl_scsiio_lun_check(softc, lun, entry,
+ if (ctl_scsiio_lun_check(lun, entry,
&cur_blocked->scsiio) == 0) {
cur_blocked->io_hdr.flags |=
CTL_FLAG_IS_WAS_ON_RTR;
@@ -11150,9 +11100,10 @@ ctl_check_blocked(struct ctl_lun *lun)
* careful attention to the placement of any new checks.
*/
static int
-ctl_scsiio_lun_check(struct ctl_softc *ctl_softc, struct ctl_lun *lun,
+ctl_scsiio_lun_check(struct ctl_lun *lun,
const struct ctl_cmd_entry *entry, struct ctl_scsiio *ctsio)
{
+ struct ctl_softc *softc = lun->ctl_softc;
int retval;
uint32_t residx;
@@ -11164,7 +11115,7 @@ ctl_scsiio_lun_check(struct ctl_softc *c
* If this shelf is a secondary shelf controller, we have to reject
* any media access commands.
*/
- if ((ctl_softc->flags & CTL_FLAG_ACTIVE_SHELF) == 0 &&
+ if ((softc->flags & CTL_FLAG_ACTIVE_SHELF) == 0 &&
(entry->flags & CTL_CMD_FLAG_OK_ON_SECONDARY) == 0) {
ctl_set_lun_standby(ctsio);
retval = 1;
@@ -11270,14 +11221,14 @@ static void
ctl_failover(void)
{
struct ctl_lun *lun;
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
union ctl_io *next_io, *pending_io;
union ctl_io *io;
int lun_idx;
- ctl_softc = control_softc;
+ softc = control_softc;
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
/*
* Remove any cmds from the other SC from the rtr queue. These
* will obviously only be for LUNs for which we're the primary.
@@ -11287,19 +11238,19 @@ ctl_failover(void)
* which HA mode we're in.
*/
#ifdef notyet
- mtx_lock(&ctl_softc->queue_lock);
- for (io = (union ctl_io *)STAILQ_FIRST(&ctl_softc->rtr_queue);
+ mtx_lock(&softc->queue_lock);
+ for (io = (union ctl_io *)STAILQ_FIRST(&softc->rtr_queue);
io != NULL; io = next_io) {
next_io = (union ctl_io *)STAILQ_NEXT(&io->io_hdr, links);
if (io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)
- STAILQ_REMOVE(&ctl_softc->rtr_queue, &io->io_hdr,
+ STAILQ_REMOVE(&softc->rtr_queue, &io->io_hdr,
ctl_io_hdr, links);
}
- mtx_unlock(&ctl_softc->queue_lock);
+ mtx_unlock(&softc->queue_lock);
#endif
- for (lun_idx=0; lun_idx < ctl_softc->num_luns; lun_idx++) {
- lun = ctl_softc->ctl_luns[lun_idx];
+ for (lun_idx=0; lun_idx < softc->num_luns; lun_idx++) {
+ lun = softc->ctl_luns[lun_idx];
if (lun==NULL)
continue;
@@ -11311,7 +11262,7 @@ ctl_failover(void)
continue;
if ((lun->flags & CTL_LUN_PRIMARY_SC)
- && (ctl_softc->ha_mode == CTL_HA_MODE_SER_ONLY)) {
+ && (softc->ha_mode == CTL_HA_MODE_SER_ONLY)) {
printf("FAILOVER: primary lun %d\n", lun_idx);
/*
* Remove all commands from the other SC. First from the
@@ -11353,7 +11304,7 @@ ctl_failover(void)
}
ctl_check_blocked(lun);
} else if ((lun->flags & CTL_LUN_PRIMARY_SC)
- && (ctl_softc->ha_mode == CTL_HA_MODE_XFER)) {
+ && (softc->ha_mode == CTL_HA_MODE_XFER)) {
printf("FAILOVER: primary lun %d\n", lun_idx);
/*
@@ -11371,7 +11322,7 @@ ctl_failover(void)
io->io_hdr.flags |= CTL_FLAG_ABORT;
}
} else if (((lun->flags & CTL_LUN_PRIMARY_SC) == 0)
- && (ctl_softc->ha_mode == CTL_HA_MODE_XFER)) {
+ && (softc->ha_mode == CTL_HA_MODE_XFER)) {
printf("FAILOVER: secondary lun %d\n", lun_idx);
@@ -11410,7 +11361,7 @@ ctl_failover(void)
ctl_est_ua_all(lun, -1, CTL_UA_ASYM_ACC_CHANGE);
} else if (((lun->flags & CTL_LUN_PRIMARY_SC) == 0)
- && (ctl_softc->ha_mode == CTL_HA_MODE_SER_ONLY)) {
+ && (softc->ha_mode == CTL_HA_MODE_SER_ONLY)) {
printf("FAILOVER: secondary lun %d\n", lun_idx);
/*
* if the first io on the OOA is not on the RtR queue
@@ -11500,15 +11451,15 @@ ctl_failover(void)
ctl_est_ua_all(lun, -1, CTL_UA_ASYM_ACC_CHANGE);
} else {
panic("Unhandled HA mode failover, LUN flags = %#x, "
- "ha_mode = #%x", lun->flags, ctl_softc->ha_mode);
+ "ha_mode = #%x", lun->flags, softc->ha_mode);
}
}
ctl_pause_rtr = 0;
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
}
static int
-ctl_scsiio_precheck(struct ctl_softc *ctl_softc, struct ctl_scsiio *ctsio)
+ctl_scsiio_precheck(struct ctl_softc *softc, struct ctl_scsiio *ctsio)
{
struct ctl_lun *lun;
const struct ctl_cmd_entry *entry;
@@ -11521,7 +11472,7 @@ ctl_scsiio_precheck(struct ctl_softc *ct
targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun;
if ((targ_lun < CTL_MAX_LUNS)
- && ((lun = ctl_softc->ctl_luns[targ_lun]) != NULL)) {
+ && ((lun = softc->ctl_luns[targ_lun]) != NULL)) {
/*
* If the LUN is invalid, pretend that it doesn't exist.
* It will go away as soon as all pending I/O has been
@@ -11653,7 +11604,7 @@ ctl_scsiio_precheck(struct ctl_softc *ct
}
- if (ctl_scsiio_lun_check(ctl_softc, lun, entry, ctsio) != 0) {
+ if (ctl_scsiio_lun_check(lun, entry, ctsio) != 0) {
mtx_unlock(&lun->lun_lock);
ctl_done((union ctl_io *)ctsio);
return (retval);
@@ -11861,13 +11812,13 @@ bailout:
* our single target.
*/
static int
-ctl_bus_reset(struct ctl_softc *ctl_softc, union ctl_io *io)
+ctl_bus_reset(struct ctl_softc *softc, union ctl_io *io)
{
- return(ctl_target_reset(ctl_softc, io, CTL_UA_BUS_RESET));
+ return(ctl_target_reset(softc, io, CTL_UA_BUS_RESET));
}
static int
-ctl_target_reset(struct ctl_softc *ctl_softc, union ctl_io *io,
+ctl_target_reset(struct ctl_softc *softc, union ctl_io *io,
ctl_ua_type ua_type)
{
struct ctl_lun *lun;
@@ -11891,10 +11842,10 @@ ctl_target_reset(struct ctl_softc *ctl_s
}
retval = 0;
- mtx_lock(&ctl_softc->ctl_lock);
- STAILQ_FOREACH(lun, &ctl_softc->lun_list, links)
+ mtx_lock(&softc->ctl_lock);
+ STAILQ_FOREACH(lun, &softc->lun_list, links)
retval += ctl_lun_reset(lun, io, ua_type);
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
return (retval);
}
@@ -12080,7 +12031,7 @@ ctl_abort_task(union ctl_io *io)
{
union ctl_io *xio;
struct ctl_lun *lun;
- struct ctl_softc *ctl_softc;
+ struct ctl_softc *softc;
#if 0
struct sbuf sb;
char printbuf[128];
@@ -12088,19 +12039,19 @@ ctl_abort_task(union ctl_io *io)
int found;
uint32_t targ_lun;
- ctl_softc = control_softc;
+ softc = control_softc;
found = 0;
/*
* Look up the LUN.
*/
targ_lun = io->io_hdr.nexus.targ_mapped_lun;
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
if ((targ_lun < CTL_MAX_LUNS)
- && (ctl_softc->ctl_luns[targ_lun] != NULL))
- lun = ctl_softc->ctl_luns[targ_lun];
+ && (softc->ctl_luns[targ_lun] != NULL))
+ lun = softc->ctl_luns[targ_lun];
else {
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
return (1);
}
@@ -12110,7 +12061,7 @@ ctl_abort_task(union ctl_io *io)
#endif
mtx_lock(&lun->lun_lock);
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
/*
* Run through the OOA queue and attempt to find the given I/O.
* The target port, initiator ID, tag type and tag number have to
@@ -12226,7 +12177,7 @@ ctl_abort_task(union ctl_io *io)
static void
ctl_run_task(union ctl_io *io)
{
- struct ctl_softc *ctl_softc = control_softc;
+ struct ctl_softc *softc = control_softc;
int retval = 1;
const char *task_desc;
@@ -12281,12 +12232,12 @@ ctl_run_task(union ctl_io *io)
uint32_t targ_lun;
targ_lun = io->io_hdr.nexus.targ_mapped_lun;
- mtx_lock(&ctl_softc->ctl_lock);
+ mtx_lock(&softc->ctl_lock);
if ((targ_lun < CTL_MAX_LUNS)
- && (ctl_softc->ctl_luns[targ_lun] != NULL))
- lun = ctl_softc->ctl_luns[targ_lun];
+ && (softc->ctl_luns[targ_lun] != NULL))
+ lun = softc->ctl_luns[targ_lun];
else {
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
retval = 1;
break;
}
@@ -12313,14 +12264,14 @@ ctl_run_task(union ctl_io *io)
retval = ctl_lun_reset(lun, io,
CTL_UA_LUN_RESET);
- mtx_unlock(&ctl_softc->ctl_lock);
+ mtx_unlock(&softc->ctl_lock);
break;
}
case CTL_TASK_TARGET_RESET:
- retval = ctl_target_reset(ctl_softc, io, CTL_UA_TARG_RESET);
+ retval = ctl_target_reset(softc, io, CTL_UA_TARG_RESET);
break;
case CTL_TASK_BUS_RESET:
- retval = ctl_bus_reset(ctl_softc, io);
+ retval = ctl_bus_reset(softc, io);
break;
case CTL_TASK_PORT_LOGIN:
break;
@@ -12347,13 +12298,13 @@ ctl_handle_isc(union ctl_io *io)
{
int free_io;
struct ctl_lun *lun;
- struct ctl_softc *ctl_softc;
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-stable
mailing list