summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctladm
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-09-10 10:46:21 +0000
committermav <mav@FreeBSD.org>2015-09-10 10:46:21 +0000
commit1d4ff31d062979783b9c032a98744476927f858e (patch)
tree127ee3f592766935b5b1a07a19892f28c6092a53 /usr.sbin/ctladm
parent9701f78cf861e384fc384747619879acb0767a1c (diff)
downloadFreeBSD-src-1d4ff31d062979783b9c032a98744476927f858e.zip
FreeBSD-src-1d4ff31d062979783b9c032a98744476927f858e.tar.gz
Remove unused target and initiator IDs.
Diffstat (limited to 'usr.sbin/ctladm')
-rw-r--r--usr.sbin/ctladm/ctladm.856
-rw-r--r--usr.sbin/ctladm/ctladm.c282
2 files changed, 125 insertions, 213 deletions
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index cc1fc1f..deb6763 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 cca46c8..4e5b084 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;
@@ -4512,7 +4428,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;
@@ -4525,7 +4441,6 @@ main(int argc, char **argv)
device = NULL;
fd = -1;
retries = 0;
- target = 0;
lun = 0;
initid = 7;
@@ -4551,16 +4466,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++;
@@ -4691,16 +4603,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);
@@ -4713,7 +4625,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:
@@ -4726,44 +4638,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:
@@ -4773,20 +4685,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