summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-10-05 08:55:59 +0000
committermav <mav@FreeBSD.org>2015-10-05 08:55:59 +0000
commit63b0da2b15c899762f1e6cd3b08ec33ef11175c0 (patch)
tree7bd7eb89c4a971ea62d2d8be87ed859cf8b7f02d
parent76966ba3a77b3630bf8f18df5ce8190743dbed6c (diff)
downloadFreeBSD-src-63b0da2b15c899762f1e6cd3b08ec33ef11175c0.zip
FreeBSD-src-63b0da2b15c899762f1e6cd3b08ec33ef11175c0.tar.gz
MFC r287620: Remove unused target and initiator IDs.
-rw-r--r--sys/cam/ctl/ctl.c56
-rw-r--r--sys/cam/ctl/ctl_frontend.h4
-rw-r--r--sys/cam/ctl/ctl_frontend_cam_sim.c12
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c9
-rw-r--r--sys/cam/ctl/ctl_io.h8
-rw-r--r--sys/cam/ctl/ctl_ioctl.h5
-rw-r--r--sys/cam/ctl/ctl_scsi_all.c2
-rw-r--r--sys/cam/ctl/ctl_tpc_local.c3
-rw-r--r--sys/cam/ctl/ctl_util.c2
-rw-r--r--sys/cam/ctl/ctl_util.h2
-rw-r--r--sys/cam/ctl/scsi_ctl.c11
-rw-r--r--usr.sbin/ctladm/ctladm.856
-rw-r--r--usr.sbin/ctladm/ctladm.c282
13 files changed, 167 insertions, 285 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index f9710b5..9a192df 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -571,15 +571,14 @@ ctl_isc_handler_finish_ser_only(struct ctl_softc *ctl_softc,
printf("%s: %p use after free!\n", __func__,
ctsio);
printf("%s: type %d msg %d cdb %x iptl: "
- "%d:%d:%d:%d tag 0x%04x "
+ "%u:%u:%u tag 0x%04x "
"flag %#x status %x\n",
__func__,
tmp_io->io_hdr.io_type,
tmp_io->io_hdr.msg_type,
tmp_io->scsiio.cdb[0],
- tmp_io->io_hdr.nexus.initid.id,
+ tmp_io->io_hdr.nexus.initid,
tmp_io->io_hdr.nexus.targ_port,
- tmp_io->io_hdr.nexus.targ_target.id,
tmp_io->io_hdr.nexus.targ_lun,
(tmp_io->io_hdr.io_type ==
CTL_IO_TASK) ?
@@ -667,10 +666,9 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_event event, int param)
io->io_hdr.flags |= CTL_FLAG_INT_COPY;
io->io_hdr.nexus = msg_info.hdr.nexus;
#if 0
- printf("targ %d, port %d, iid %d, lun %d\n",
- io->io_hdr.nexus.targ_target.id,
+ printf("port %u, iid %u, lun %u\n",
io->io_hdr.nexus.targ_port,
- io->io_hdr.nexus.initid.id,
+ io->io_hdr.nexus.initid,
io->io_hdr.nexus.targ_lun);
#endif
io->scsiio.tag_num = msg_info.scsi.tag_num;
@@ -3070,10 +3068,10 @@ uint32_t
ctl_get_initindex(struct ctl_nexus *nexus)
{
if (nexus->targ_port < CTL_MAX_PORTS)
- return (nexus->initid.id +
+ return (nexus->initid +
(nexus->targ_port * CTL_MAX_INIT_PER_PORT));
else
- return (nexus->initid.id +
+ return (nexus->initid +
((nexus->targ_port - CTL_MAX_PORTS) *
CTL_MAX_INIT_PER_PORT));
}
@@ -3081,7 +3079,7 @@ ctl_get_initindex(struct ctl_nexus *nexus)
uint32_t
ctl_get_resindex(struct ctl_nexus *nexus)
{
- return (nexus->initid.id + (nexus->targ_port * CTL_MAX_INIT_PER_PORT));
+ return (nexus->initid + (nexus->targ_port * CTL_MAX_INIT_PER_PORT));
}
uint32_t
@@ -10434,8 +10432,8 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_io *pending_io,
&& (ooa_io->scsiio.tag_type == CTL_TAG_UNTAGGED)
&& ((pending_io->io_hdr.nexus.targ_port ==
ooa_io->io_hdr.nexus.targ_port)
- && (pending_io->io_hdr.nexus.initid.id ==
- ooa_io->io_hdr.nexus.initid.id))
+ && (pending_io->io_hdr.nexus.initid ==
+ ooa_io->io_hdr.nexus.initid))
&& ((ooa_io->io_hdr.flags & (CTL_FLAG_ABORT |
CTL_FLAG_STATUS_SENT)) == 0))
return (CTL_ACTION_OVERLAP);
@@ -10456,8 +10454,8 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_io *pending_io,
&& (pending_io->scsiio.tag_num == ooa_io->scsiio.tag_num)
&& ((pending_io->io_hdr.nexus.targ_port ==
ooa_io->io_hdr.nexus.targ_port)
- && (pending_io->io_hdr.nexus.initid.id ==
- ooa_io->io_hdr.nexus.initid.id))
+ && (pending_io->io_hdr.nexus.initid ==
+ ooa_io->io_hdr.nexus.initid))
&& ((ooa_io->io_hdr.flags & (CTL_FLAG_ABORT |
CTL_FLAG_STATUS_SENT)) == 0))
return (CTL_ACTION_OVERLAP_TAG);
@@ -11571,9 +11569,9 @@ ctl_abort_tasks_lun(struct ctl_lun *lun, uint32_t targ_port, uint32_t init_id,
if ((targ_port == UINT32_MAX ||
targ_port == xio->io_hdr.nexus.targ_port) &&
(init_id == UINT32_MAX ||
- init_id == xio->io_hdr.nexus.initid.id)) {
+ init_id == xio->io_hdr.nexus.initid)) {
if (targ_port != xio->io_hdr.nexus.targ_port ||
- init_id != xio->io_hdr.nexus.initid.id)
+ init_id != xio->io_hdr.nexus.initid)
xio->io_hdr.flags |= CTL_FLAG_ABORT_STATUS;
xio->io_hdr.flags |= CTL_FLAG_ABORT;
if (!other_sc && !(lun->flags & CTL_LUN_PRIMARY_SC)) {
@@ -11616,7 +11614,7 @@ ctl_abort_task_set(union ctl_io *io)
mtx_unlock(&softc->ctl_lock);
if (io->taskio.task_action == CTL_TASK_ABORT_TASK_SET) {
ctl_abort_tasks_lun(lun, io->io_hdr.nexus.targ_port,
- io->io_hdr.nexus.initid.id,
+ io->io_hdr.nexus.initid,
(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) != 0);
} else { /* CTL_TASK_CLEAR_TASK_SET */
ctl_abort_tasks_lun(lun, UINT32_MAX, UINT32_MAX,
@@ -11639,7 +11637,7 @@ ctl_i_t_nexus_reset(union ctl_io *io)
STAILQ_FOREACH(lun, &softc->lun_list, links) {
mtx_lock(&lun->lun_lock);
ctl_abort_tasks_lun(lun, io->io_hdr.nexus.targ_port,
- io->io_hdr.nexus.initid.id,
+ io->io_hdr.nexus.initid,
(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) != 0);
#ifdef CTL_WITH_CA
ctl_clear_mask(lun->have_ca, initidx);
@@ -11718,7 +11716,7 @@ ctl_abort_task(union ctl_io *io)
#endif
if ((xio->io_hdr.nexus.targ_port != io->io_hdr.nexus.targ_port)
- || (xio->io_hdr.nexus.initid.id != io->io_hdr.nexus.initid.id)
+ || (xio->io_hdr.nexus.initid != io->io_hdr.nexus.initid)
|| (xio->io_hdr.flags & CTL_FLAG_ABORT))
continue;
@@ -11780,10 +11778,9 @@ ctl_abort_task(union ctl_io *io)
*/
#if 0
printf("ctl_abort_task: ABORT sent for nonexistent I/O: "
- "%d:%d:%d:%d tag %d type %d\n",
- io->io_hdr.nexus.initid.id,
+ "%u:%u:%u tag %d type %d\n",
+ io->io_hdr.nexus.initid,
io->io_hdr.nexus.targ_port,
- io->io_hdr.nexus.targ_target.id,
io->io_hdr.nexus.targ_lun, io->taskio.tag_num,
io->taskio.tag_type);
#endif
@@ -12210,10 +12207,9 @@ ctl_datamove(union ctl_io *io)
* the data move.
*/
if (io->io_hdr.flags & CTL_FLAG_ABORT) {
- printf("ctl_datamove: tag 0x%04x on (%ju:%d:%ju:%d) aborted\n",
- io->scsiio.tag_num,(uintmax_t)io->io_hdr.nexus.initid.id,
+ printf("ctl_datamove: tag 0x%04x on (%u:%u:%u) aborted\n",
+ io->scsiio.tag_num, io->io_hdr.nexus.initid,
io->io_hdr.nexus.targ_port,
- (uintmax_t)io->io_hdr.nexus.targ_target.id,
io->io_hdr.nexus.targ_lun);
io->io_hdr.port_status = 31337;
/*
@@ -12981,10 +12977,9 @@ ctl_datamove_remote(union ctl_io *io)
* have been done if need be on the other controller.
*/
if (io->io_hdr.flags & CTL_FLAG_ABORT) {
- printf("%s: tag 0x%04x on (%d:%d:%d:%d) aborted\n", __func__,
- io->scsiio.tag_num, io->io_hdr.nexus.initid.id,
+ printf("%s: tag 0x%04x on (%u:%u:%u) aborted\n", __func__,
+ io->scsiio.tag_num, io->io_hdr.nexus.initid,
io->io_hdr.nexus.targ_port,
- io->io_hdr.nexus.targ_target.id,
io->io_hdr.nexus.targ_lun);
io->io_hdr.port_status = 31338;
ctl_send_datamove_done(io, /*have_lock*/ 0);
@@ -13379,15 +13374,14 @@ ctl_done(union ctl_io *io)
#if 0
if (io->io_hdr.flags & CTL_FLAG_ALREADY_DONE) {
printf("%s: type %d msg %d cdb %x iptl: "
- "%d:%d:%d:%d tag 0x%04x "
+ "%u:%u:%u tag 0x%04x "
"flag %#x status %x\n",
__func__,
io->io_hdr.io_type,
io->io_hdr.msg_type,
io->scsiio.cdb[0],
- io->io_hdr.nexus.initid.id,
+ io->io_hdr.nexus.initid,
io->io_hdr.nexus.targ_port,
- io->io_hdr.nexus.targ_target.id,
io->io_hdr.nexus.targ_lun,
(io->io_hdr.io_type ==
CTL_IO_TASK) ?
@@ -13651,7 +13645,7 @@ ctl_enqueue_incoming(union ctl_io *io)
u_int idx;
idx = (io->io_hdr.nexus.targ_port * 127 +
- io->io_hdr.nexus.initid.id) % worker_threads;
+ io->io_hdr.nexus.initid) % worker_threads;
thr = &softc->threads[idx];
mtx_lock(&thr->queue_lock);
STAILQ_INSERT_TAIL(&thr->incoming_queue, &io->io_hdr, links);
diff --git a/sys/cam/ctl/ctl_frontend.h b/sys/cam/ctl/ctl_frontend.h
index 470d7a7..a6ca9e1 100644
--- a/sys/cam/ctl/ctl_frontend.h
+++ b/sys/cam/ctl/ctl_frontend.h
@@ -125,12 +125,12 @@ struct ctl_wwpn_iid {
* port_online(): This function is called, with onoff_arg as its
* argument, by the CTL layer when it wants the FETD
* to start responding to selections on the specified
- * target ID. (targ_target)
+ * target ID.
*
* port_offline(): This function is called, with onoff_arg as its
* argument, by the CTL layer when it wants the FETD
* to stop responding to selection on the specified
- * target ID. (targ_target)
+ * target ID.
*
* onoff_arg: This is supplied as an argument to port_online()
* and port_offline(). This is specified by the
diff --git a/sys/cam/ctl/ctl_frontend_cam_sim.c b/sys/cam/ctl/ctl_frontend_cam_sim.c
index 88dcb29..5ab03c9 100644
--- a/sys/cam/ctl/ctl_frontend_cam_sim.c
+++ b/sys/cam/ctl/ctl_frontend_cam_sim.c
@@ -546,12 +546,8 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
* down via the XPT_RESET_BUS/LUN CCBs below.
*/
io->io_hdr.io_type = CTL_IO_SCSI;
- io->io_hdr.nexus.initid.id = 1;
+ io->io_hdr.nexus.initid = 1;
io->io_hdr.nexus.targ_port = softc->port.targ_port;
- /*
- * XXX KDM how do we handle target IDs?
- */
- io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
/*
* This tag scheme isn't the best, since we could in theory
@@ -639,9 +635,8 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
ccb->ccb_h.io_ptr = io;
io->io_hdr.io_type = CTL_IO_TASK;
- io->io_hdr.nexus.initid.id = 1;
+ io->io_hdr.nexus.initid = 1;
io->io_hdr.nexus.targ_port = softc->port.targ_port;
- io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
io->taskio.task_action = CTL_TASK_ABORT_TASK;
io->taskio.tag_num = abort_ccb->csio.tag_id;
@@ -735,9 +730,8 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
ccb->ccb_h.io_ptr = io;
io->io_hdr.io_type = CTL_IO_TASK;
- io->io_hdr.nexus.initid.id = 0;
+ io->io_hdr.nexus.initid = 1;
io->io_hdr.nexus.targ_port = softc->port.targ_port;
- io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
if (ccb->ccb_h.func_code == XPT_RESET_BUS)
io->taskio.task_action = CTL_TASK_BUS_RESET;
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index 12a42f1..231c1c0 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -561,9 +561,8 @@ cfiscsi_pdu_handle_scsi_command(struct icl_pdu *request)
ctl_zero_io(io);
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = request;
io->io_hdr.io_type = CTL_IO_SCSI;
- io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
+ io->io_hdr.nexus.initid = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
- io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = cfiscsi_decode_lun(bhssc->bhssc_lun);
io->scsiio.tag_num = bhssc->bhssc_initiator_task_tag;
switch ((bhssc->bhssc_flags & BHSSC_FLAGS_ATTR)) {
@@ -618,9 +617,8 @@ cfiscsi_pdu_handle_task_request(struct icl_pdu *request)
ctl_zero_io(io);
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = request;
io->io_hdr.io_type = CTL_IO_TASK;
- io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
+ io->io_hdr.nexus.initid = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
- io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = cfiscsi_decode_lun(bhstmr->bhstmr_lun);
io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */
@@ -1078,9 +1076,8 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
ctl_zero_io(io);
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = cs;
io->io_hdr.io_type = CTL_IO_TASK;
- io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
+ io->io_hdr.nexus.initid = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
- io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = 0;
io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */
io->taskio.task_action = CTL_TASK_I_T_NEXUS_RESET;
diff --git a/sys/cam/ctl/ctl_io.h b/sys/cam/ctl/ctl_io.h
index 40e4664..0f3c0fe 100644
--- a/sys/cam/ctl/ctl_io.h
+++ b/sys/cam/ctl/ctl_io.h
@@ -183,11 +183,6 @@ struct ctl_sg_entry {
size_t len;
};
-struct ctl_id {
- uint32_t id;
- uint64_t wwid[2];
-};
-
typedef enum {
CTL_IO_NONE,
CTL_IO_SCSI,
@@ -195,9 +190,8 @@ typedef enum {
} ctl_io_type;
struct ctl_nexus {
- struct ctl_id initid; /* Initiator ID */
+ uint32_t initid; /* Initiator ID */
uint32_t targ_port; /* Target port, filled in by PORT */
- struct ctl_id targ_target; /* Destination target */
uint32_t targ_lun; /* Destination lun */
uint32_t targ_mapped_lun; /* Destination lun CTL-wide */
};
diff --git a/sys/cam/ctl/ctl_ioctl.h b/sys/cam/ctl/ctl_ioctl.h
index d7c3bc2..937b51d 100644
--- a/sys/cam/ctl/ctl_ioctl.h
+++ b/sys/cam/ctl/ctl_ioctl.h
@@ -86,7 +86,6 @@ typedef enum {
} ctl_ooa_status;
struct ctl_ooa_info {
- uint32_t target_id; /* Passed in to CTL */
uint32_t lun_id; /* Passed in to CTL */
uint32_t num_entries; /* Returned from CTL */
ctl_ooa_status status; /* Returned from CTL */
@@ -114,7 +113,6 @@ typedef enum {
} ctl_delay_status;
struct ctl_io_delay_info {
- uint32_t target_id;
uint32_t lun_id;
ctl_delay_type delay_type;
ctl_delay_location delay_loc;
@@ -133,7 +131,6 @@ typedef enum {
* means that we will let through every N SYNCHRONIZE CACHE commands.
*/
struct ctl_sync_info {
- uint32_t target_id; /* passed to kernel */
uint32_t lun_id; /* passed to kernel */
int sync_interval; /* depends on whether get/set */
ctl_gs_sync_status status; /* passed from kernel */
@@ -262,7 +259,6 @@ struct ctl_error_desc_cmd {
/*
* Error injection descriptor.
*
- * target_id: Target ID to act on.
* lun_id LUN to act on.
* lun_error: The type of error to inject. See above for descriptions.
* error_pattern: What kind of command to act on. See above.
@@ -273,7 +269,6 @@ struct ctl_error_desc_cmd {
* links: Kernel use only.
*/
struct ctl_error_desc {
- uint32_t target_id; /* To kernel */
uint32_t lun_id; /* To kernel */
ctl_lun_error lun_error; /* To kernel */
ctl_lun_error_pattern error_pattern; /* To kernel */
diff --git a/sys/cam/ctl/ctl_scsi_all.c b/sys/cam/ctl/ctl_scsi_all.c
index 815e383..acac6ea 100644
--- a/sys/cam/ctl/ctl_scsi_all.c
+++ b/sys/cam/ctl/ctl_scsi_all.c
@@ -114,7 +114,7 @@ ctl_scsi_path_string(union ctl_io *io, char *path_str, int len)
{
snprintf(path_str, len, "(%u:%u:%u/%u): ",
- io->io_hdr.nexus.initid.id, io->io_hdr.nexus.targ_port,
+ io->io_hdr.nexus.initid, io->io_hdr.nexus.targ_port,
io->io_hdr.nexus.targ_lun, io->io_hdr.nexus.targ_mapped_lun);
}
diff --git a/sys/cam/ctl/ctl_tpc_local.c b/sys/cam/ctl/ctl_tpc_local.c
index 7e66340..40e6df8 100644
--- a/sys/cam/ctl/ctl_tpc_local.c
+++ b/sys/cam/ctl/ctl_tpc_local.c
@@ -328,9 +328,8 @@ tpcl_queue(union ctl_io *io, uint64_t lun)
{
struct tpcl_softc *tsoftc = &tpcl_softc;
- io->io_hdr.nexus.initid.id = 0;
+ io->io_hdr.nexus.initid = 0;
io->io_hdr.nexus.targ_port = tsoftc->port.targ_port;
- io->io_hdr.nexus.targ_target.id = 0;
io->io_hdr.nexus.targ_lun = lun;
io->scsiio.tag_num = atomic_fetchadd_int(&tsoftc->cur_tag_num, 1);
io->scsiio.ext_data_filled = 0;
diff --git a/sys/cam/ctl/ctl_util.c b/sys/cam/ctl/ctl_util.c
index a991cfb..8c57a22 100644
--- a/sys/cam/ctl/ctl_util.c
+++ b/sys/cam/ctl/ctl_util.c
@@ -679,7 +679,7 @@ ctl_scsi_maintenance_in(union ctl_io *io, uint8_t *data_ptr, uint32_t data_len,
#ifndef _KERNEL
union ctl_io *
-ctl_scsi_alloc_io(struct ctl_id initid)
+ctl_scsi_alloc_io(uint32_t initid)
{
union ctl_io *io;
diff --git a/sys/cam/ctl/ctl_util.h b/sys/cam/ctl/ctl_util.h
index af5e55f..b1c0d84 100644
--- a/sys/cam/ctl/ctl_util.h
+++ b/sys/cam/ctl/ctl_util.h
@@ -94,7 +94,7 @@ void ctl_scsi_maintenance_in(union ctl_io *io, uint8_t *data_ptr,
uint32_t data_len, uint8_t action,
ctl_tag_type tag_type, uint8_t control);
#ifndef _KERNEL
-union ctl_io *ctl_scsi_alloc_io(struct ctl_id initid);
+union ctl_io *ctl_scsi_alloc_io(uint32_t initid);
void ctl_scsi_free_io(union ctl_io *io);
#endif /* !_KERNEL */
void ctl_scsi_zero_io(union ctl_io *io);
diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c
index 15912e2..aab1a30 100644
--- a/sys/cam/ctl/scsi_ctl.c
+++ b/sys/cam/ctl/scsi_ctl.c
@@ -1164,9 +1164,8 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
* down the immediate notify path below.
*/
io->io_hdr.io_type = CTL_IO_SCSI;
- io->io_hdr.nexus.initid.id = atio->init_id;
+ io->io_hdr.nexus.initid = atio->init_id;
io->io_hdr.nexus.targ_port = bus_softc->port.targ_port;
- io->io_hdr.nexus.targ_target.id = atio->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun;
io->scsiio.tag_num = atio->tag_id;
switch (atio->tag_action) {
@@ -1200,10 +1199,9 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
io->scsiio.cdb_len);
#ifdef CTLFEDEBUG
- printf("%s: %ju:%d:%ju:%d: tag %04x CDB %02x\n", __func__,
- (uintmax_t)io->io_hdr.nexus.initid.id,
+ printf("%s: %u:%u:%u: tag %04x CDB %02x\n", __func__,
+ io->io_hdr.nexus.initid,
io->io_hdr.nexus.targ_port,
- (uintmax_t)io->io_hdr.nexus.targ_target.id,
io->io_hdr.nexus.targ_lun,
io->scsiio.tag_num, io->scsiio.cdb[0]);
#endif
@@ -1440,9 +1438,8 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
io->io_hdr.io_type = CTL_IO_TASK;
io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr =done_ccb;
inot->ccb_h.io_ptr = io;
- io->io_hdr.nexus.initid.id = inot->initiator_id;
+ io->io_hdr.nexus.initid = inot->initiator_id;
io->io_hdr.nexus.targ_port = bus_softc->port.targ_port;
- io->io_hdr.nexus.targ_target.id = inot->ccb_h.target_id;
io->io_hdr.nexus.targ_lun = inot->ccb_h.target_lun;
/* XXX KDM should this be the tag_id? */
io->taskio.tag_num = inot->seq_id;
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index 11b953c..f673996 100644
--- a/usr.sbin/ctladm/ctladm.8
+++ b/usr.sbin/ctladm/ctladm.8
@@ -34,7 +34,7 @@
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
.\" $FreeBSD$
.\"
-.Dd September 6, 2015
+.Dd September 10, 2015
.Dt CTLADM 8
.Os
.Sh NAME
@@ -43,28 +43,28 @@
.Sh SYNOPSIS
.Nm
.Aq Ar command
-.Op target:lun
+.Op lun
.Op generic args
.Op command args
.Nm
.Ic tur
-.Aq target:lun
+.Aq lun
.Op general options
.Nm
.Ic inquiry
-.Aq target:lun
+.Aq lun
.Op general options
.Nm
.Ic reqsense
-.Aq target:lun
+.Aq lun
.Op general options
.Nm
.Ic reportluns
-.Aq target:lun
+.Aq lun
.Op general options
.Nm
.Ic read
-.Aq target:lun
+.Aq lun
.Op general options
.Aq Fl l Ar lba
.Aq Fl d Ar datalen
@@ -74,7 +74,7 @@
.Op Fl N
.Nm
.Ic write
-.Aq target:lun
+.Aq lun
.Op general options
.Aq Fl l Ar lba
.Aq Fl d Ar datalen
@@ -84,12 +84,12 @@
.Op Fl N
.Nm
.Ic readcap
-.Aq target:lun
+.Aq lun
.Op general options
.Op Fl c Ar cdbsize
.Nm
.Ic modesense
-.Aq target:lun
+.Aq lun
.Aq Fl m Ar page | Fl l
.Op Fl P Ar pc
.Op Fl d
@@ -97,19 +97,19 @@
.Op Fl c Ar size
.Nm
.Ic start
-.Aq target:lun
+.Aq lun
.Op general options
.Op Fl i
.Op Fl o
.Nm
.Ic stop
-.Aq target:lun
+.Aq lun
.Op general options
.Op Fl i
.Op Fl o
.Nm
.Ic synccache
-.Aq target:lun
+.Aq lun
.Op general options
.Op Fl l Ar lba
.Op Fl b Ar blockcount
@@ -126,7 +126,7 @@
.Ic lunlist
.Nm
.Ic delay
-.Aq target:lun
+.Aq lun
.Aq Fl l Ar datamove|done
.Aq Fl t Ar secs
.Op Fl T Ar oneshot|cont
@@ -134,11 +134,11 @@
.Ic realsync Aq on|off|query
.Nm
.Ic setsync interval
-.Aq target:lun
+.Aq lun
.Aq Fl i Ar interval
.Nm
.Ic getsync
-.Aq target:lun
+.Aq lun
.Nm
.Ic inject
.Aq Fl i Ar action
@@ -236,8 +236,8 @@ utility has a number of primary functions, many of which require a device
identifier.
The device identifier takes the following form:
.Bl -tag -width 14n
-.It target:lun
-Specify the target (almost always 0) and LUN number to operate on.
+.It lun
+Specify the LUN number to operate on.
.El
Many of the primary functions of the
.Nm
@@ -570,7 +570,7 @@ sending SYNCHRONIZE cache commands. An interval of 0 means that the cache
will be flushed for this LUN every time a SYNCHRONIZE CACHE command is
received.
.Pp
-You must specify the target and LUN you want to modify.
+You must specify the LUN you want to modify.
.It Ic getsync
Get the interval at which we actually service the SYNCHRONIZE CACHE
command, as set by the
@@ -580,7 +580,7 @@ The reported number means that we will actually flush the cache on every
Nth SYNCHRONIZE CACHE command. A value of 0 means that we will flush the
cache every time.
.Pp
-You must specify the target and LUN you want to query.
+You must specify the LUN you want to query.
.It Ic inject
Inject the specified type of error for the LUN specified, when a command
that matches the given pattern is seen.
@@ -1024,34 +1024,34 @@ Specifies file or device name to use for backing store.
Specifies number of backend threads to use for this LUN.
.El
.Sh EXAMPLES
-.Dl ctladm tur 0:1
+.Dl ctladm tur 1
.Pp
Send a
.Tn SCSI
TEST UNIT READY command to LUN 1.
.Pp
-.Dl ctladm modesense 0:1 -l
+.Dl ctladm modesense 1 -l
.Pp
Display the list of mode pages supported by LUN 1.
.Pp
-.Dl ctladm modesense 0:0 -m 10 -P 3 -d -c 10
+.Dl ctladm modesense 0 -m 10 -P 3 -d -c 10
.Pp
Display the saved version of the Control mode page (page 10) on LUN 0.
Disable fetching block descriptors, and use a 10 byte MODE SENSE command
instead of the default 6 byte command.
.Bd -literal
-ctladm read 0:2 -l 0 -d 1 -b 512 -f - > foo
+ctladm read 2 -l 0 -d 1 -b 512 -f - > foo
.Ed
.Pp
Read the first 512 byte block from LUN 2 and dump it to the file
.Pa foo .
.Bd -literal
-ctladm write 0:3 -l 0xff432140 -d 20 -b 512 -f /tmp/bar
+ctladm write 3 -l 0xff432140 -d 20 -b 512 -f /tmp/bar
.Ed
.Pp
Read 10240 bytes from the file
.Pa /tmp/bar
-and write it to target 0, LUN 3.
+and write it to LUN 3.
starting at LBA 0xff432140.
.Pp
.Dl ctladm create -b ramdisk -s 10485760000000000
@@ -1095,12 +1095,12 @@ List all LUNs in the system, along with their inquiry data and device type.
This only works when the FETDs are enabled, since the commands go through the
ioctl port.
.Pp
-.Dl ctladm inject 0:6 -i mediumerr -p read -r 0,512 -c
+.Dl ctladm inject 6 -i mediumerr -p read -r 0,512 -c
.Pp
Inject a medium error on LUN 6 for every read that covers the first 512
blocks of the LUN.
.Bd -literal -offset indent
-ctladm inject 0:6 -i custom -p tur -s 18 "f0 0 02 s12 04 02"
+ctladm inject 6 -i custom -p tur -s 18 "f0 0 02 s12 04 02"
.Ed
.Pp
Inject a custom error on LUN 6 for the next TEST UNIT READY command only.
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 71fd5f3..5834676 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -211,49 +211,47 @@ static struct ctladm_opts option_table[] = {
ctladm_optret getoption(struct ctladm_opts *table, char *arg, uint32_t *cmdnum,
ctladm_cmdargs *argnum, const char **subopt);
-static int cctl_parse_tl(char *str, int *target, int *lun);
static int cctl_dump_ooa(int fd, int argc, char **argv);
static int cctl_port_dump(int fd, int quiet, int xml, int32_t fe_num,
ctl_port_type port_type);
static int cctl_port(int fd, int argc, char **argv, char *combinedopt);
static int cctl_do_io(int fd, int retries, union ctl_io *io, const char *func);
-static int cctl_delay(int fd, int target, int lun, int argc, char **argv,
+static int cctl_delay(int fd, int lun, int argc, char **argv,
char *combinedopt);
static int cctl_lunlist(int fd);
-static int cctl_startup_shutdown(int fd, int target, int lun, int iid,
+static int cctl_startup_shutdown(int fd, int lun, int iid,
ctladm_cmdfunction command);
-static int cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
+static int cctl_sync_cache(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt);
-static int cctl_start_stop(int fd, int target, int lun, int iid, int retries,
+static int cctl_start_stop(int fd, int lun, int iid, int retries,
int start, int argc, char **argv, char *combinedopt);
-static int cctl_mode_sense(int fd, int target, int lun, int iid, int retries,
+static int cctl_mode_sense(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt);
-static int cctl_read_capacity(int fd, int target, int lun, int iid,
+static int cctl_read_capacity(int fd, int lun, int iid,
int retries, int argc, char **argv,
char *combinedopt);
-static int cctl_read_write(int fd, int target, int lun, int iid, int retries,
+static int cctl_read_write(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt,
ctladm_cmdfunction command);
-static int cctl_get_luns(int fd, int target, int lun, int iid, int retries,
+static int cctl_get_luns(int fd, int lun, int iid, int retries,
struct scsi_report_luns_data **lun_data,
uint32_t *num_luns);
-static int cctl_report_luns(int fd, int target, int lun, int iid, int retries);
-static int cctl_tur(int fd, int target, int lun, int iid, int retries);
-static int cctl_get_inquiry(int fd, int target, int lun, int iid, int retries,
+static int cctl_report_luns(int fd, int lun, int iid, int retries);
+static int cctl_tur(int fd, int lun, int iid, int retries);
+static int cctl_get_inquiry(int fd, int lun, int iid, int retries,
char *path_str, int path_len,
struct scsi_inquiry_data *inq_data);
-static int cctl_inquiry(int fd, int target, int lun, int iid, int retries);
-static int cctl_req_sense(int fd, int target, int lun, int iid, int retries);
-static int cctl_persistent_reserve_in(int fd, int target, int lun,
+static int cctl_inquiry(int fd, int lun, int iid, int retries);
+static int cctl_req_sense(int fd, int lun, int iid, int retries);
+static int cctl_persistent_reserve_in(int fd, int lun,
int initiator, int argc, char **argv,
char *combinedopt, int retry_count);
-static int cctl_persistent_reserve_out(int fd, int target, int lun,
+static int cctl_persistent_reserve_out(int fd, int lun,
int initiator, int argc, char **argv,
char *combinedopt, int retry_count);
static int cctl_create_lun(int fd, int argc, char **argv, char *combinedopt);
-static int cctl_inquiry_vpd_devid(int fd, int target, int lun, int initiator);
-static int cctl_report_target_port_group(int fd, int target, int lun,
- int initiator);
+static int cctl_inquiry_vpd_devid(int fd, int lun, int initiator);
+static int cctl_report_target_port_group(int fd, int lun, int initiator);
static int cctl_modify_lun(int fd, int argc, char **argv, char *combinedopt);
ctladm_optret
@@ -284,50 +282,20 @@ getoption(struct ctladm_opts *table, char *arg, uint32_t *cmdnum,
return(CC_OR_NOT_FOUND);
}
-
-static int
-cctl_parse_tl(char *str, int *target, int *lun)
-{
- char *tmpstr;
- int retval;
-
- retval = 0;
-
- while (isspace(*str) && (*str != '\0'))
- str++;
-
- tmpstr = (char *)strtok(str, ":");
- if ((tmpstr != NULL) && (*tmpstr != '\0')) {
- *target = strtol(tmpstr, NULL, 0);
- tmpstr = (char *)strtok(NULL, ":");
- if ((tmpstr != NULL) && (*tmpstr != '\0')) {
- *lun = strtol(tmpstr, NULL, 0);
- } else
- retval = -1;
- } else
- retval = -1;
-
- return (retval);
-}
-
static int
cctl_dump_ooa(int fd, int argc, char **argv)
{
struct ctl_ooa ooa;
long double cmd_latency;
int num_entries, len;
- int target = -1, lun = -1;
+ int lun = -1;
int retval;
unsigned int i;
num_entries = 104;
- if ((argc > 2)
- && (isdigit(argv[2][0]))) {
- retval = cctl_parse_tl(argv[2], &target, &lun);
- if (retval != 0)
- warnx("invalid target:lun argument %s", argv[2]);
- }
+ if ((argc > 2) && (isdigit(argv[2][0])))
+ lun = strtol(argv[2], NULL, 0);
retry:
len = num_entries * sizeof(struct ctl_ooa_entry);
@@ -776,7 +744,7 @@ cctl_do_io(int fd, int retries, union ctl_io *io, const char *func)
}
static int
-cctl_delay(int fd, int target, int lun, int argc, char **argv,
+cctl_delay(int fd, int lun, int argc, char **argv,
char *combinedopt)
{
struct ctl_io_delay_info delay_info;
@@ -831,7 +799,6 @@ cctl_delay(int fd, int target, int lun, int argc, char **argv,
goto bailout;
}
- delay_info.target_id = target;
delay_info.lun_id = lun;
delay_info.delay_secs = delaytime;
@@ -938,7 +905,7 @@ bailout:
}
static int
-cctl_getsetsync(int fd, int target, int lun, ctladm_cmdfunction command,
+cctl_getsetsync(int fd, int lun, ctladm_cmdfunction command,
int argc, char **argv, char *combinedopt)
{
struct ctl_sync_info sync_info;
@@ -950,7 +917,6 @@ cctl_getsetsync(int fd, int target, int lun, ctladm_cmdfunction command,
retval = 0;
memset(&sync_info, 0, sizeof(sync_info));
- sync_info.target_id = target;
sync_info.lun_id = lun;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
@@ -986,12 +952,12 @@ cctl_getsetsync(int fd, int target, int lun, ctladm_cmdfunction command,
switch (sync_info.status) {
case CTL_GS_SYNC_OK:
if (command == CTLADM_CMD_GETSYNC) {
- fprintf(stdout, "%d:%d: sync interval: %d\n",
- target, lun, sync_info.sync_interval);
+ fprintf(stdout, "%d: sync interval: %d\n",
+ lun, sync_info.sync_interval);
}
break;
case CTL_GS_SYNC_NO_LUN:
- warnx("%s: unknown target:LUN %d:%d", __func__, target, lun);
+ warnx("%s: unknown LUN %d", __func__, lun);
retval = 1;
break;
case CTL_GS_SYNC_NONE:
@@ -1030,7 +996,7 @@ static struct ctladm_opts cctl_err_patterns[] = {
};
static int
-cctl_error_inject(int fd, uint32_t target, uint32_t lun, int argc, char **argv,
+cctl_error_inject(int fd, uint32_t lun, int argc, char **argv,
char *combinedopt)
{
int retval = 0;
@@ -1045,7 +1011,6 @@ cctl_error_inject(int fd, uint32_t target, uint32_t lun, int argc, char **argv,
int c;
bzero(&err_desc, sizeof(err_desc));
- err_desc.target_id = target;
err_desc.lun_id = lun;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
@@ -1256,7 +1221,6 @@ cctl_lunlist(int fd)
struct scsi_report_luns_data *lun_data;
struct scsi_inquiry_data *inq_data;
uint32_t num_luns;
- int target;
int initid;
unsigned int i;
int retval;
@@ -1264,14 +1228,13 @@ cctl_lunlist(int fd)
retval = 0;
inq_data = NULL;
- target = 6;
initid = 7;
/*
* XXX KDM assuming LUN 0 is fine, but we may need to change this
* if we ever acquire the ability to have multiple targets.
*/
- if ((retval = cctl_get_luns(fd, target, /*lun*/ 0, initid,
+ if ((retval = cctl_get_luns(fd, /*lun*/ 0, initid,
/*retries*/ 2, &lun_data, &num_luns)) != 0)
goto bailout;
@@ -1308,7 +1271,7 @@ cctl_lunlist(int fd)
if (lun_val == -1)
continue;
- if ((retval = cctl_get_inquiry(fd, target, lun_val, initid,
+ if ((retval = cctl_get_inquiry(fd, lun_val, initid,
/*retries*/ 2, scsi_path,
sizeof(scsi_path),
inq_data)) != 0) {
@@ -1329,11 +1292,10 @@ bailout:
}
static int
-cctl_startup_shutdown(int fd, int target, int lun, int iid,
+cctl_startup_shutdown(int fd, int lun, int iid,
ctladm_cmdfunction command)
{
union ctl_io *io;
- struct ctl_id id;
struct scsi_report_luns_data *lun_data;
struct scsi_inquiry_data *inq_data;
uint32_t num_luns;
@@ -1353,15 +1315,13 @@ cctl_startup_shutdown(int fd, int target, int lun, int iid,
* and reissue the stop with the offline bit set
*/
- id.id = iid;
-
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warnx("%s: can't allocate memory", __func__);
return (1);
}
- if ((retval = cctl_get_luns(fd, target, lun, iid, /*retries*/ 2,
+ if ((retval = cctl_get_luns(fd, lun, iid, /*retries*/ 2,
&lun_data, &num_luns)) != 0)
goto bailout;
@@ -1402,7 +1362,7 @@ cctl_startup_shutdown(int fd, int target, int lun, int iid,
if (lun_val == -1)
continue;
- if ((retval = cctl_get_inquiry(fd, target, lun_val, iid,
+ if ((retval = cctl_get_inquiry(fd, lun_val, iid,
/*retries*/ 2, scsi_path,
sizeof(scsi_path),
inq_data)) != 0) {
@@ -1422,7 +1382,6 @@ cctl_startup_shutdown(int fd, int target, int lun, int iid,
if (command == CTLADM_CMD_SHUTDOWN) {
struct ctl_ooa_info ooa_info;
- ooa_info.target_id = target;
ooa_info.lun_id = lun_val;
if (ioctl(fd, CTL_CHECK_OOA, &ooa_info) == -1) {
@@ -1457,9 +1416,8 @@ cctl_startup_shutdown(int fd, int target, int lun, int iid,
CTL_TAG_SIMPLE :CTL_TAG_ORDERED,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun_val;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, /*retries*/ 3, io, __func__) != 0) {
retval = 1;
@@ -1488,11 +1446,10 @@ bailout:
}
static int
-cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
+cctl_sync_cache(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt)
{
union ctl_io *io;
- struct ctl_id id;
int cdb_size = -1;
int retval;
uint64_t our_lba = 0;
@@ -1500,10 +1457,9 @@ cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
int reladr = 0, immed = 0;
int c;
- id.id = iid;
retval = 0;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warnx("%s: can't allocate memory", __func__);
return (1);
@@ -1555,9 +1511,8 @@ cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
retval = 1;
@@ -1575,19 +1530,17 @@ bailout:
}
static int
-cctl_start_stop(int fd, int target, int lun, int iid, int retries, int start,
+cctl_start_stop(int fd, int lun, int iid, int retries, int start,
int argc, char **argv, char *combinedopt)
{
union ctl_io *io;
- struct ctl_id id;
char scsi_path[40];
int immed = 0, onoffline = 0;
int retval, c;
- id.id = iid;
retval = 0;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warnx("%s: can't allocate memory", __func__);
return (1);
@@ -1622,9 +1575,8 @@ cctl_start_stop(int fd, int target, int lun, int iid, int retries, int start,
CTL_TAG_ORDERED,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
retval = 1;
@@ -1645,11 +1597,10 @@ bailout:
}
static int
-cctl_mode_sense(int fd, int target, int lun, int iid, int retries,
+cctl_mode_sense(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt)
{
union ctl_io *io;
- struct ctl_id id;
uint32_t datalen;
uint8_t *dataptr;
int pc = -1, cdbsize, retval, dbd = 0, subpage = -1;
@@ -1657,12 +1608,11 @@ cctl_mode_sense(int fd, int target, int lun, int iid, int retries,
int page_code = -1;
int c;
- id.id = iid;
cdbsize = 0;
retval = 0;
dataptr = NULL;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory", __func__);
return (1);
@@ -1790,9 +1740,8 @@ cctl_mode_sense(int fd, int target, int lun, int iid, int retries,
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
retval = 1;
@@ -1863,11 +1812,10 @@ bailout:
}
static int
-cctl_read_capacity(int fd, int target, int lun, int iid, int retries,
+cctl_read_capacity(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt)
{
union ctl_io *io;
- struct ctl_id id;
struct scsi_read_capacity_data *data;
struct scsi_read_capacity_data_long *longdata;
int cdbsize = -1, retval;
@@ -1877,9 +1825,8 @@ cctl_read_capacity(int fd, int target, int lun, int iid, int retries,
cdbsize = 10;
dataptr = NULL;
retval = 0;
- id.id = iid;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory\n", __func__);
return (1);
@@ -1943,8 +1890,7 @@ retry:
break;
}
- io->io_hdr.nexus.initid = id;
- io->io_hdr.nexus.targ_target.id = target;
+ io->io_hdr.nexus.initid = iid;
io->io_hdr.nexus.targ_lun = lun;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
@@ -1989,12 +1935,11 @@ bailout:
}
static int
-cctl_read_write(int fd, int target, int lun, int iid, int retries,
+cctl_read_write(int fd, int lun, int iid, int retries,
int argc, char **argv, char *combinedopt,
ctladm_cmdfunction command)
{
union ctl_io *io;
- struct ctl_id id;
int file_fd, do_stdio;
int cdbsize = -1, databytes;
uint8_t *dataptr;
@@ -2009,9 +1954,8 @@ cctl_read_write(int fd, int target, int lun, int iid, int retries,
do_stdio = 0;
dataptr = NULL;
file_fd = -1;
- id.id = iid;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory\n", __func__);
return (1);
@@ -2135,9 +2079,8 @@ cctl_read_write(int fd, int target, int lun, int iid, int retries,
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
retval = 1;
@@ -2172,19 +2115,17 @@ bailout:
}
static int
-cctl_get_luns(int fd, int target, int lun, int iid, int retries, struct
+cctl_get_luns(int fd, int lun, int iid, int retries, struct
scsi_report_luns_data **lun_data, uint32_t *num_luns)
{
union ctl_io *io;
- struct ctl_id id;
uint32_t nluns;
int lun_datalen;
int retval;
retval = 0;
- id.id = iid;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warnx("%s: can't allocate memory", __func__);
return (1);
@@ -2213,8 +2154,7 @@ retry:
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.initid = id;
- io->io_hdr.nexus.targ_target.id = target;
+ io->io_hdr.nexus.initid = iid;
io->io_hdr.nexus.targ_lun = lun;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
@@ -2245,7 +2185,7 @@ bailout:
}
static int
-cctl_report_luns(int fd, int target, int lun, int iid, int retries)
+cctl_report_luns(int fd, int lun, int iid, int retries)
{
struct scsi_report_luns_data *lun_data;
uint32_t num_luns, i;
@@ -2253,7 +2193,7 @@ cctl_report_luns(int fd, int target, int lun, int iid, int retries)
lun_data = NULL;
- if ((retval = cctl_get_luns(fd, target, lun, iid, retries, &lun_data,
+ if ((retval = cctl_get_luns(fd, lun, iid, retries, &lun_data,
&num_luns)) != 0)
goto bailout;
@@ -2298,14 +2238,11 @@ bailout:
}
static int
-cctl_tur(int fd, int target, int lun, int iid, int retries)
+cctl_tur(int fd, int lun, int iid, int retries)
{
union ctl_io *io;
- struct ctl_id id;
-
- id.id = iid;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
fprintf(stderr, "can't allocate memory\n");
return (1);
@@ -2315,9 +2252,8 @@ cctl_tur(int fd, int target, int lun, int iid, int retries)
/* tag_type */ CTL_TAG_SIMPLE,
/* control */ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
ctl_scsi_free_io(io);
@@ -2333,19 +2269,16 @@ cctl_tur(int fd, int target, int lun, int iid, int retries)
}
static int
-cctl_get_inquiry(int fd, int target, int lun, int iid, int retries,
+cctl_get_inquiry(int fd, int lun, int iid, int retries,
char *path_str, int path_len,
struct scsi_inquiry_data *inq_data)
{
union ctl_io *io;
- struct ctl_id id;
int retval;
retval = 0;
- id.id = iid;
-
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warnx("cctl_inquiry: can't allocate memory\n");
return (1);
@@ -2359,9 +2292,8 @@ cctl_get_inquiry(int fd, int target, int lun, int iid, int retries,
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
retval = 1;
@@ -2381,7 +2313,7 @@ bailout:
}
static int
-cctl_inquiry(int fd, int target, int lun, int iid, int retries)
+cctl_inquiry(int fd, int lun, int iid, int retries)
{
struct scsi_inquiry_data *inq_data;
char scsi_path[40];
@@ -2396,7 +2328,7 @@ cctl_inquiry(int fd, int target, int lun, int iid, int retries)
goto bailout;
}
- if ((retval = cctl_get_inquiry(fd, target, lun, iid, retries, scsi_path,
+ if ((retval = cctl_get_inquiry(fd, lun, iid, retries, scsi_path,
sizeof(scsi_path), inq_data)) != 0)
goto bailout;
@@ -2411,18 +2343,15 @@ bailout:
}
static int
-cctl_req_sense(int fd, int target, int lun, int iid, int retries)
+cctl_req_sense(int fd, int lun, int iid, int retries)
{
union ctl_io *io;
struct scsi_sense_data *sense_data;
- struct ctl_id id;
int retval;
retval = 0;
- id.id = iid;
-
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warnx("cctl_req_sense: can't allocate memory\n");
return (1);
@@ -2437,9 +2366,8 @@ cctl_req_sense(int fd, int target, int lun, int iid, int retries)
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retries, io, __func__) != 0) {
retval = 1;
@@ -2462,19 +2390,17 @@ bailout:
}
static int
-cctl_report_target_port_group(int fd, int target, int lun, int initiator)
+cctl_report_target_port_group(int fd, int lun, int iid)
{
union ctl_io *io;
- struct ctl_id id;
uint32_t datalen;
uint8_t *dataptr;
int retval;
- id.id = initiator;
dataptr = NULL;
retval = 0;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory", __func__);
return (1);
@@ -2497,9 +2423,8 @@ cctl_report_target_port_group(int fd, int target, int lun, int initiator)
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, 0, io, __func__) != 0) {
retval = 1;
@@ -2530,19 +2455,17 @@ bailout:
}
static int
-cctl_inquiry_vpd_devid(int fd, int target, int lun, int initiator)
+cctl_inquiry_vpd_devid(int fd, int lun, int iid)
{
union ctl_io *io;
- struct ctl_id id;
uint32_t datalen;
uint8_t *dataptr;
int retval;
- id.id = initiator;
retval = 0;
dataptr = NULL;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory", __func__);
return (1);
@@ -2566,9 +2489,8 @@ cctl_inquiry_vpd_devid(int fd, int target, int lun, int initiator)
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, 0, io, __func__) != 0) {
retval = 1;
@@ -2599,23 +2521,21 @@ bailout:
}
static int
-cctl_persistent_reserve_in(int fd, int target, int lun, int initiator,
+cctl_persistent_reserve_in(int fd, int lun, int iid,
int argc, char **argv, char *combinedopt,
int retry_count)
{
union ctl_io *io;
- struct ctl_id id;
uint32_t datalen;
uint8_t *dataptr;
int action = -1;
int retval;
int c;
- id.id = initiator;
retval = 0;
dataptr = NULL;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory", __func__);
return (1);
@@ -2655,9 +2575,8 @@ cctl_persistent_reserve_in(int fd, int target, int lun, int initiator,
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retry_count, io, __func__) != 0) {
retval = 1;
@@ -2705,12 +2624,11 @@ bailout:
}
static int
-cctl_persistent_reserve_out(int fd, int target, int lun, int initiator,
+cctl_persistent_reserve_out(int fd, int lun, int iid,
int argc, char **argv, char *combinedopt,
int retry_count)
{
union ctl_io *io;
- struct ctl_id id;
uint32_t datalen;
uint64_t key = 0, sa_key = 0;
int action = -1, restype = -1;
@@ -2718,11 +2636,10 @@ cctl_persistent_reserve_out(int fd, int target, int lun, int initiator,
int retval;
int c;
- id.id = initiator;
retval = 0;
dataptr = NULL;
- io = ctl_scsi_alloc_io(id);
+ io = ctl_scsi_alloc_io(iid);
if (io == NULL) {
warn("%s: can't allocate memory", __func__);
return (1);
@@ -2780,9 +2697,8 @@ cctl_persistent_reserve_out(int fd, int target, int lun, int initiator,
/*tag_type*/ CTL_TAG_SIMPLE,
/*control*/ 0);
- io->io_hdr.nexus.targ_target.id = target;
io->io_hdr.nexus.targ_lun = lun;
- io->io_hdr.nexus.initid = id;
+ io->io_hdr.nexus.initid = iid;
if (cctl_do_io(fd, retry_count, io, __func__) != 0) {
retval = 1;
@@ -4507,7 +4423,7 @@ main(int argc, char **argv)
const char *mainopt = "C:D:I:";
const char *subopt = NULL;
char combinedopt[256];
- int target, lun;
+ int lun;
int optstart = 2;
int retval, fd;
int retries;
@@ -4520,7 +4436,6 @@ main(int argc, char **argv)
device = NULL;
fd = -1;
retries = 0;
- target = 0;
lun = 0;
initid = 7;
@@ -4546,16 +4461,13 @@ main(int argc, char **argv)
}
if (cmdargs & CTLADM_ARG_NEED_TL) {
- if ((argc < 3)
- || (!isdigit(argv[2][0]))) {
- warnx("option %s requires a target:lun argument",
+ if ((argc < 3) || (!isdigit(argv[2][0]))) {
+ warnx("option %s requires a lun argument",
argv[1]);
usage(0);
exit(1);
}
- retval = cctl_parse_tl(argv[2], &target, &lun);
- if (retval != 0)
- errx(1, "invalid target:lun argument %s", argv[2]);
+ lun = strtol(argv[2], NULL, 0);
cmdargs |= CTLADM_ARG_TARG_LUN;
optstart++;
@@ -4686,16 +4598,16 @@ main(int argc, char **argv)
switch (command) {
case CTLADM_CMD_TUR:
- retval = cctl_tur(fd, target, lun, initid, retries);
+ retval = cctl_tur(fd, lun, initid, retries);
break;
case CTLADM_CMD_INQUIRY:
- retval = cctl_inquiry(fd, target, lun, initid, retries);
+ retval = cctl_inquiry(fd, lun, initid, retries);
break;
case CTLADM_CMD_REQ_SENSE:
- retval = cctl_req_sense(fd, target, lun, initid, retries);
+ retval = cctl_req_sense(fd, lun, initid, retries);
break;
case CTLADM_CMD_REPORT_LUNS:
- retval = cctl_report_luns(fd, target, lun, initid, retries);
+ retval = cctl_report_luns(fd, lun, initid, retries);
break;
case CTLADM_CMD_CREATE:
retval = cctl_create_lun(fd, argc, argv, combinedopt);
@@ -4708,7 +4620,7 @@ main(int argc, char **argv)
break;
case CTLADM_CMD_READ:
case CTLADM_CMD_WRITE:
- retval = cctl_read_write(fd, target, lun, initid, retries,
+ retval = cctl_read_write(fd, lun, initid, retries,
argc, argv, combinedopt, command);
break;
case CTLADM_CMD_PORT:
@@ -4721,44 +4633,44 @@ main(int argc, char **argv)
retval = cctl_lunmap(fd, argc, argv, combinedopt);
break;
case CTLADM_CMD_READCAPACITY:
- retval = cctl_read_capacity(fd, target, lun, initid, retries,
+ retval = cctl_read_capacity(fd, lun, initid, retries,
argc, argv, combinedopt);
break;
case CTLADM_CMD_MODESENSE:
- retval = cctl_mode_sense(fd, target, lun, initid, retries,
+ retval = cctl_mode_sense(fd, lun, initid, retries,
argc, argv, combinedopt);
break;
case CTLADM_CMD_START:
case CTLADM_CMD_STOP:
- retval = cctl_start_stop(fd, target, lun, initid, retries,
+ retval = cctl_start_stop(fd, lun, initid, retries,
(command == CTLADM_CMD_START) ? 1 : 0,
argc, argv, combinedopt);
break;
case CTLADM_CMD_SYNC_CACHE:
- retval = cctl_sync_cache(fd, target, lun, initid, retries,
+ retval = cctl_sync_cache(fd, lun, initid, retries,
argc, argv, combinedopt);
break;
case CTLADM_CMD_SHUTDOWN:
case CTLADM_CMD_STARTUP:
- retval = cctl_startup_shutdown(fd, target, lun, initid,
+ retval = cctl_startup_shutdown(fd, lun, initid,
command);
break;
case CTLADM_CMD_LUNLIST:
retval = cctl_lunlist(fd);
break;
case CTLADM_CMD_DELAY:
- retval = cctl_delay(fd, target, lun, argc, argv, combinedopt);
+ retval = cctl_delay(fd, lun, argc, argv, combinedopt);
break;
case CTLADM_CMD_REALSYNC:
retval = cctl_realsync(fd, argc, argv);
break;
case CTLADM_CMD_SETSYNC:
case CTLADM_CMD_GETSYNC:
- retval = cctl_getsetsync(fd, target, lun, command,
+ retval = cctl_getsetsync(fd, lun, command,
argc, argv, combinedopt);
break;
case CTLADM_CMD_ERR_INJECT:
- retval = cctl_error_inject(fd, target, lun, argc, argv,
+ retval = cctl_error_inject(fd, lun, argc, argv,
combinedopt);
break;
case CTLADM_CMD_DUMPOOA:
@@ -4768,20 +4680,20 @@ main(int argc, char **argv)
retval = cctl_dump_structs(fd, cmdargs);
break;
case CTLADM_CMD_PRES_IN:
- retval = cctl_persistent_reserve_in(fd, target, lun, initid,
+ retval = cctl_persistent_reserve_in(fd, lun, initid,
argc, argv, combinedopt,
retries);
break;
case CTLADM_CMD_PRES_OUT:
- retval = cctl_persistent_reserve_out(fd, target, lun, initid,
+ retval = cctl_persistent_reserve_out(fd, lun, initid,
argc, argv, combinedopt,
retries);
break;
case CTLADM_CMD_INQ_VPD_DEVID:
- retval = cctl_inquiry_vpd_devid(fd, target, lun, initid);
+ retval = cctl_inquiry_vpd_devid(fd, lun, initid);
break;
case CTLADM_CMD_RTPG:
- retval = cctl_report_target_port_group(fd, target, lun, initid);
+ retval = cctl_report_target_port_group(fd, lun, initid);
break;
case CTLADM_CMD_MODIFY:
retval = cctl_modify_lun(fd, argc, argv, combinedopt);
OpenPOWER on IntegriCloud