summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctladm
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-08-15 13:34:38 +0000
committermav <mav@FreeBSD.org>2015-08-15 13:34:38 +0000
commitc9d448ea79d3a7a6fb7e135be03c5b2fbad87340 (patch)
treefad820e06835f9adb25d184e511521ca10203ed2 /usr.sbin/ctladm
parent3cd702f2719795c014a945d59e1c3f99b5b08d09 (diff)
downloadFreeBSD-src-c9d448ea79d3a7a6fb7e135be03c5b2fbad87340.zip
FreeBSD-src-c9d448ea79d3a7a6fb7e135be03c5b2fbad87340.tar.gz
Drop "internal" CTL frontend.
Its idea was to be a simple initiator and execute several commands from kernel level, but FreeBSD never had consumer for that functionality, while its implementation polluted many unrelated places..
Diffstat (limited to 'usr.sbin/ctladm')
-rw-r--r--usr.sbin/ctladm/ctladm.854
-rw-r--r--usr.sbin/ctladm/ctladm.c202
2 files changed, 1 insertions, 255 deletions
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index 114b5fe..2612056 100644
--- a/usr.sbin/ctladm/ctladm.8
+++ b/usr.sbin/ctladm/ctladm.8
@@ -83,12 +83,6 @@
.Op Fl c Ar cdbsize
.Op Fl N
.Nm
-.Ic bbrread
-.Aq target:lun
-.Op general options
-.Aq Fl -l Ar lba
-.Aq Fl -d Ar datalen
-.Nm
.Ic readcap
.Aq target:lun
.Op general options
@@ -129,10 +123,6 @@
.Ic startup
.Op general options
.Nm
-.Ic hardstop
-.Nm
-.Ic hardstart
-.Nm
.Ic lunlist
.Nm
.Ic delay
@@ -364,34 +354,6 @@ to the kernel when doing a write, just execute the command without copying
data.
This is to be used for performance testing.
.El
-.It Ic bbrread
-Issue a SCSI READ command to the logical device to potentially force a bad
-block on a disk in the RAID set to be reconstructed from the other disks in
-the array. This command should only be used on an array that is in the
-normal state. If used on a critical array, it could cause the array to go
-offline if the bad block to be remapped is on one of the disks that is
-still active in the array.
-.Pp
-The data for this particular command will be discarded, and not returned to
-the user.
-.Pp
-In order to determine which LUN to read from, the user should first
-determine which LUN the disk with a bad block belongs to. Then he should
-map the bad disk block back to the logical block address for the array in
-order to determine which LBA to pass in to the
-.Ic bbrread
-command.
-.Pp
-This command is primarily intended for testing. In practice, bad block
-remapping will generally be triggered by the in-kernel Disk Aerobics and
-Disk Scrubbing code.
-.Bl -tag -width 10n
-.It Fl l Ar lba
-Specify the starting Logical Block Address.
-.It Fl d Ar datalen
-Specify the amount of data in bytes to read from the LUN. This must be a
-multiple of the LUN blocksize.
-.El
.It Ic readcap
Send the
.Tn SCSI
@@ -545,22 +507,6 @@ START STOP UNIT command with the start bit set and the on/offline bit set
to all direct access LUNs. This will mark all direct access LUNs "online"
again. It will not cause any LUNs to start up. A separate start command
without the on/offline bit set is necessary for that.
-.It Ic hardstop
-Use the kernel facility for stopping all direct access LUNs and setting the
-offline bit. Unlike the
-.Ic shutdown
-command above, this command allows shutting down LUNs with I/O active. It
-will also issue a LUN reset to any reserved LUNs to break the reservation
-so that the LUN can be stopped.
-.Ic shutdown
-command instead.
-.It Ic hardstart
-This command is functionally identical to the
-.Ic startup
-command described above. The primary difference is that the LUNs are
-enumerated and commands sent by the in-kernel Front End Target Driver
-instead of by
-.Nm .
.It Ic lunlist
List all LUNs registered with CTL.
Because this command uses the ioctl port, it will only work when the FETDs
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 6baf0902..10d819f 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
#include <cam/scsi/scsi_message.h>
#include <cam/ctl/ctl.h>
#include <cam/ctl/ctl_io.h>
-#include <cam/ctl/ctl_frontend_internal.h>
#include <cam/ctl/ctl_backend.h>
#include <cam/ctl/ctl_ioctl.h>
#include <cam/ctl/ctl_backend_block.h>
@@ -106,14 +105,11 @@ typedef enum {
CTLADM_CMD_SHUTDOWN,
CTLADM_CMD_STARTUP,
CTLADM_CMD_LUNLIST,
- CTLADM_CMD_HARDSTOP,
- CTLADM_CMD_HARDSTART,
CTLADM_CMD_DELAY,
CTLADM_CMD_REALSYNC,
CTLADM_CMD_SETSYNC,
CTLADM_CMD_GETSYNC,
CTLADM_CMD_ERR_INJECT,
- CTLADM_CMD_BBRREAD,
CTLADM_CMD_PRES_IN,
CTLADM_CMD_PRES_OUT,
CTLADM_CMD_INQ_VPD_DEVID,
@@ -172,7 +168,6 @@ static const char startstop_opts[] = "io";
static struct ctladm_opts option_table[] = {
{"adddev", CTLADM_CMD_ADDDEV, CTLADM_ARG_NONE, NULL},
- {"bbrread", CTLADM_CMD_BBRREAD, CTLADM_ARG_NEED_TL, "d:l:"},
{"create", CTLADM_CMD_CREATE, CTLADM_ARG_NONE, "b:B:d:l:o:s:S:t:"},
{"delay", CTLADM_CMD_DELAY, CTLADM_ARG_NEED_TL, "T:l:t:"},
{"devid", CTLADM_CMD_INQ_VPD_DEVID, CTLADM_ARG_NEED_TL, NULL},
@@ -180,8 +175,6 @@ static struct ctladm_opts option_table[] = {
{"dumpooa", CTLADM_CMD_DUMPOOA, CTLADM_ARG_NONE, NULL},
{"dumpstructs", CTLADM_CMD_DUMPSTRUCTS, CTLADM_ARG_NONE, NULL},
{"getsync", CTLADM_CMD_GETSYNC, CTLADM_ARG_NEED_TL, NULL},
- {"hardstart", CTLADM_CMD_HARDSTART, CTLADM_ARG_NONE, NULL},
- {"hardstop", CTLADM_CMD_HARDSTOP, CTLADM_ARG_NONE, NULL},
{"help", CTLADM_CMD_HELP, CTLADM_ARG_NONE, NULL},
{"inject", CTLADM_CMD_ERR_INJECT, CTLADM_ARG_NEED_TL, "cd:i:p:r:s:"},
{"inquiry", CTLADM_CMD_INQUIRY, CTLADM_ARG_NEED_TL, NULL},
@@ -228,11 +221,6 @@ 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,
char *combinedopt);
static int cctl_lunlist(int fd);
-static void cctl_cfi_mt_statusstr(cfi_mt_status status, char *str, int str_len);
-static void cctl_cfi_bbr_statusstr(cfi_bbrread_status, char *str, int str_len);
-static int cctl_hardstopstart(int fd, ctladm_cmdfunction command);
-static int cctl_bbrread(int fd, int target, int lun, int iid, int argc,
- char **argv, char *combinedopt);
static int cctl_startup_shutdown(int fd, int target, int lun, int iid,
ctladm_cmdfunction command);
static int cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
@@ -1341,180 +1329,6 @@ bailout:
return (retval);
}
-static void
-cctl_cfi_mt_statusstr(cfi_mt_status status, char *str, int str_len)
-{
- switch (status) {
- case CFI_MT_PORT_OFFLINE:
- snprintf(str, str_len, "Port Offline");
- break;
- case CFI_MT_ERROR:
- snprintf(str, str_len, "Error");
- break;
- case CFI_MT_SUCCESS:
- snprintf(str, str_len, "Success");
- break;
- case CFI_MT_NONE:
- snprintf(str, str_len, "None??");
- break;
- default:
- snprintf(str, str_len, "Unknown status: %d", status);
- break;
- }
-}
-
-static void
-cctl_cfi_bbr_statusstr(cfi_bbrread_status status, char *str, int str_len)
-{
- switch (status) {
- case CFI_BBR_SUCCESS:
- snprintf(str, str_len, "Success");
- break;
- case CFI_BBR_LUN_UNCONFIG:
- snprintf(str, str_len, "LUN not configured");
- break;
- case CFI_BBR_NO_LUN:
- snprintf(str, str_len, "LUN does not exist");
- break;
- case CFI_BBR_NO_MEM:
- snprintf(str, str_len, "Memory allocation error");
- break;
- case CFI_BBR_BAD_LEN:
- snprintf(str, str_len, "Length is not a multiple of blocksize");
- break;
- case CFI_BBR_RESERV_CONFLICT:
- snprintf(str, str_len, "Reservation conflict");
- break;
- case CFI_BBR_LUN_STOPPED:
- snprintf(str, str_len, "LUN is powered off");
- break;
- case CFI_BBR_LUN_OFFLINE_CTL:
- snprintf(str, str_len, "LUN is offline");
- break;
- case CFI_BBR_LUN_OFFLINE_RC:
- snprintf(str, str_len, "RAIDCore array is offline (double "
- "failure?)");
- break;
- case CFI_BBR_SCSI_ERROR:
- snprintf(str, str_len, "SCSI Error");
- break;
- case CFI_BBR_ERROR:
- snprintf(str, str_len, "Error");
- break;
- default:
- snprintf(str, str_len, "Unknown status: %d", status);
- break;
- }
-}
-
-static int
-cctl_hardstopstart(int fd, ctladm_cmdfunction command)
-{
- struct ctl_hard_startstop_info hs_info;
- char error_str[256];
- int do_start;
- int retval;
-
- retval = 0;
-
- if (command == CTLADM_CMD_HARDSTART)
- do_start = 1;
- else
- do_start = 0;
-
- if (ioctl(fd, (do_start == 1) ? CTL_HARD_START : CTL_HARD_STOP,
- &hs_info) == -1) {
- warn("%s: CTL_HARD_%s ioctl failed", __func__,
- (do_start == 1) ? "START" : "STOP");
- retval = 1;
- goto bailout;
- }
-
- fprintf(stdout, "Hard %s Status: ", (command == CTLADM_CMD_HARDSTOP) ?
- "Stop" : "Start");
- cctl_cfi_mt_statusstr(hs_info.status, error_str, sizeof(error_str));
- fprintf(stdout, "%s\n", error_str);
- fprintf(stdout, "Total LUNs: %d\n", hs_info.total_luns);
- fprintf(stdout, "LUNs complete: %d\n", hs_info.luns_complete);
- fprintf(stdout, "LUNs failed: %d\n", hs_info.luns_failed);
-
-bailout:
- return (retval);
-}
-
-static int
-cctl_bbrread(int fd, int target __unused, int lun, int iid __unused,
- int argc, char **argv, char *combinedopt)
-{
- struct ctl_bbrread_info bbr_info;
- char error_str[256];
- int datalen = -1;
- uint64_t lba = 0;
- int lba_set = 0;
- int retval;
- int c;
-
- retval = 0;
-
- while ((c = getopt(argc, argv, combinedopt)) != -1) {
- switch (c) {
- case 'd':
- datalen = strtoul(optarg, NULL, 0);
- break;
- case 'l':
- lba = strtoull(optarg, NULL, 0);
- lba_set = 1;
- break;
- default:
- break;
- }
- }
-
- if (lba_set == 0) {
- warnx("%s: you must specify an LBA with -l", __func__);
- retval = 1;
- goto bailout;
- }
-
- if (datalen == -1) {
- warnx("%s: you must specify a length with -d", __func__);
- retval = 1;
- goto bailout;
- }
-
- bbr_info.lun_num = lun;
- bbr_info.lba = lba;
- /*
- * XXX KDM get the blocksize first??
- */
- if ((datalen % 512) != 0) {
- warnx("%s: data length %d is not a multiple of 512 bytes",
- __func__, datalen);
- retval = 1;
- goto bailout;
- }
- bbr_info.len = datalen;
-
- if (ioctl(fd, CTL_BBRREAD, &bbr_info) == -1) {
- warn("%s: CTL_BBRREAD ioctl failed", __func__);
- retval = 1;
- goto bailout;
- }
- cctl_cfi_mt_statusstr(bbr_info.status, error_str, sizeof(error_str));
- fprintf(stdout, "BBR Read Overall Status: %s\n", error_str);
- cctl_cfi_bbr_statusstr(bbr_info.bbr_status, error_str,
- sizeof(error_str));
- fprintf(stdout, "BBR Read Status: %s\n", error_str);
- /*
- * XXX KDM should we bother printing out SCSI status if we get
- * CFI_BBR_SCSI_ERROR back?
- *
- * Return non-zero if this fails?
- */
-bailout:
- return (retval);
-}
-
static int
cctl_startup_shutdown(int fd, int target, int lun, int iid,
ctladm_cmdfunction command)
@@ -4499,11 +4313,8 @@ usage(int error)
" ctladm devlist [-b backend] [-v] [-x]\n"
" ctladm shutdown\n"
" ctladm startup\n"
-" ctladm hardstop\n"
-" ctladm hardstart\n"
" ctladm lunlist\n"
" ctladm lunmap -p targ_port [-l pLUN] [-L cLUN]\n"
-" ctladm bbrread [dev_id] <-l lba> <-d datalen>\n"
" ctladm delay [dev_id] <-l datamove|done> [-T oneshot|cont]\n"
" [-t secs]\n"
" ctladm realsync <on|off|query>\n"
@@ -4610,10 +4421,7 @@ usage(int error)
"lunmap options:\n"
"-p targ_port : specify target port number\n"
"-L pLUN : specify port-visible LUN\n"
-"-L cLUN : specify CTL LUN\n"
-"bbrread options:\n"
-"-l lba : starting LBA\n"
-"-d datalen : length, in bytes, to read\n",
+"-L cLUN : specify CTL LUN\n",
CTL_DEFAULT_DEV);
}
@@ -4864,14 +4672,6 @@ main(int argc, char **argv)
retval = cctl_startup_shutdown(fd, target, lun, initid,
command);
break;
- case CTLADM_CMD_HARDSTOP:
- case CTLADM_CMD_HARDSTART:
- retval = cctl_hardstopstart(fd, command);
- break;
- case CTLADM_CMD_BBRREAD:
- retval = cctl_bbrread(fd, target, lun, initid, argc, argv,
- combinedopt);
- break;
case CTLADM_CMD_LUNLIST:
retval = cctl_lunlist(fd);
break;
OpenPOWER on IntegriCloud