Remove some duplicate, legacy, dead and questionable code.
This commit is contained in:
parent
873a0bd675
commit
9c887a4f86
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=288259
@ -1754,12 +1754,7 @@ ctl_init(void)
|
||||
softc->io_zone = uma_zcreate("CTL IO", sizeof(union ctl_io),
|
||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
|
||||
softc->open_count = 0;
|
||||
|
||||
/*
|
||||
* Default to actually sending a SYNCHRONIZE CACHE command down to
|
||||
* the drive.
|
||||
*/
|
||||
softc->flags = CTL_FLAG_REAL_SYNC;
|
||||
softc->flags = 0;
|
||||
|
||||
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
|
||||
OID_AUTO, "ha_mode", CTLFLAG_RDTUN, (int *)&softc->ha_mode, 0,
|
||||
@ -2586,112 +2581,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
break;
|
||||
}
|
||||
case CTL_GET_PORT_LIST: {
|
||||
struct ctl_port *port;
|
||||
struct ctl_port_list *list;
|
||||
int i;
|
||||
|
||||
list = (struct ctl_port_list *)addr;
|
||||
|
||||
if (list->alloc_len != (list->alloc_num *
|
||||
sizeof(struct ctl_port_entry))) {
|
||||
printf("%s: CTL_GET_PORT_LIST: alloc_len %u != "
|
||||
"alloc_num %u * sizeof(struct ctl_port_entry) "
|
||||
"%zu\n", __func__, list->alloc_len,
|
||||
list->alloc_num, sizeof(struct ctl_port_entry));
|
||||
retval = EINVAL;
|
||||
break;
|
||||
}
|
||||
list->fill_len = 0;
|
||||
list->fill_num = 0;
|
||||
list->dropped_num = 0;
|
||||
i = 0;
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
STAILQ_FOREACH(port, &softc->port_list, links) {
|
||||
struct ctl_port_entry entry, *list_entry;
|
||||
|
||||
if (list->fill_num >= list->alloc_num) {
|
||||
list->dropped_num++;
|
||||
continue;
|
||||
}
|
||||
|
||||
entry.port_type = port->port_type;
|
||||
strlcpy(entry.port_name, port->port_name,
|
||||
sizeof(entry.port_name));
|
||||
entry.targ_port = port->targ_port;
|
||||
entry.physical_port = port->physical_port;
|
||||
entry.virtual_port = port->virtual_port;
|
||||
entry.wwnn = port->wwnn;
|
||||
entry.wwpn = port->wwpn;
|
||||
if (port->status & CTL_PORT_STATUS_ONLINE)
|
||||
entry.online = 1;
|
||||
else
|
||||
entry.online = 0;
|
||||
|
||||
list_entry = &list->entries[i];
|
||||
|
||||
retval = copyout(&entry, list_entry, sizeof(entry));
|
||||
if (retval != 0) {
|
||||
printf("%s: CTL_GET_PORT_LIST: copyout "
|
||||
"returned %d\n", __func__, retval);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
list->fill_num++;
|
||||
list->fill_len += sizeof(entry);
|
||||
}
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
|
||||
/*
|
||||
* If this is non-zero, we had a copyout fault, so there's
|
||||
* probably no point in attempting to set the status inside
|
||||
* the structure.
|
||||
*/
|
||||
if (retval != 0)
|
||||
break;
|
||||
|
||||
if (list->dropped_num > 0)
|
||||
list->status = CTL_PORT_LIST_NEED_MORE_SPACE;
|
||||
else
|
||||
list->status = CTL_PORT_LIST_OK;
|
||||
break;
|
||||
}
|
||||
case CTL_DUMP_OOA: {
|
||||
union ctl_io *io;
|
||||
char printbuf[128];
|
||||
struct sbuf sb;
|
||||
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
printf("Dumping OOA queues:\n");
|
||||
STAILQ_FOREACH(lun, &softc->lun_list, links) {
|
||||
mtx_lock(&lun->lun_lock);
|
||||
for (io = (union ctl_io *)TAILQ_FIRST(
|
||||
&lun->ooa_queue); io != NULL;
|
||||
io = (union ctl_io *)TAILQ_NEXT(&io->io_hdr,
|
||||
ooa_links)) {
|
||||
sbuf_new(&sb, printbuf, sizeof(printbuf),
|
||||
SBUF_FIXEDLEN);
|
||||
sbuf_printf(&sb, "LUN %jd tag 0x%04x%s%s%s%s: ",
|
||||
(intmax_t)lun->lun,
|
||||
io->scsiio.tag_num,
|
||||
(io->io_hdr.flags &
|
||||
CTL_FLAG_BLOCKED) ? "" : " BLOCKED",
|
||||
(io->io_hdr.flags &
|
||||
CTL_FLAG_DMA_INPROG) ? " DMA" : "",
|
||||
(io->io_hdr.flags &
|
||||
CTL_FLAG_ABORT) ? " ABORT" : "",
|
||||
(io->io_hdr.flags &
|
||||
CTL_FLAG_IS_WAS_ON_RTR) ? " RTR" : "");
|
||||
ctl_scsi_command_string(&io->scsiio, NULL, &sb);
|
||||
sbuf_finish(&sb);
|
||||
printf("%s\n", sbuf_data(&sb));
|
||||
}
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
}
|
||||
printf("OOA queues dump done\n");
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
break;
|
||||
}
|
||||
case CTL_GET_OOA: {
|
||||
struct ctl_ooa *ooa_hdr;
|
||||
struct ctl_ooa_entry *entries;
|
||||
@ -2774,38 +2663,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
|
||||
free(entries, M_CTL);
|
||||
break;
|
||||
}
|
||||
case CTL_CHECK_OOA: {
|
||||
union ctl_io *io;
|
||||
struct ctl_ooa_info *ooa_info;
|
||||
|
||||
|
||||
ooa_info = (struct ctl_ooa_info *)addr;
|
||||
|
||||
if (ooa_info->lun_id >= CTL_MAX_LUNS) {
|
||||
ooa_info->status = CTL_OOA_INVALID_LUN;
|
||||
break;
|
||||
}
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
lun = softc->ctl_luns[ooa_info->lun_id];
|
||||
if (lun == NULL) {
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
ooa_info->status = CTL_OOA_INVALID_LUN;
|
||||
break;
|
||||
}
|
||||
mtx_lock(&lun->lun_lock);
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
ooa_info->num_entries = 0;
|
||||
for (io = (union ctl_io *)TAILQ_FIRST(&lun->ooa_queue);
|
||||
io != NULL; io = (union ctl_io *)TAILQ_NEXT(
|
||||
&io->io_hdr, ooa_links)) {
|
||||
ooa_info->num_entries++;
|
||||
}
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
|
||||
ooa_info->status = CTL_OOA_SUCCESS;
|
||||
|
||||
break;
|
||||
}
|
||||
case CTL_DELAY_IO: {
|
||||
struct ctl_io_delay_info *delay_info;
|
||||
|
||||
@ -2861,70 +2718,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
|
||||
#endif /* CTL_IO_DELAY */
|
||||
break;
|
||||
}
|
||||
case CTL_REALSYNC_SET: {
|
||||
int *syncstate;
|
||||
|
||||
syncstate = (int *)addr;
|
||||
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
switch (*syncstate) {
|
||||
case 0:
|
||||
softc->flags &= ~CTL_FLAG_REAL_SYNC;
|
||||
break;
|
||||
case 1:
|
||||
softc->flags |= CTL_FLAG_REAL_SYNC;
|
||||
break;
|
||||
default:
|
||||
retval = EINVAL;
|
||||
break;
|
||||
}
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
break;
|
||||
}
|
||||
case CTL_REALSYNC_GET: {
|
||||
int *syncstate;
|
||||
|
||||
syncstate = (int*)addr;
|
||||
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
if (softc->flags & CTL_FLAG_REAL_SYNC)
|
||||
*syncstate = 1;
|
||||
else
|
||||
*syncstate = 0;
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
|
||||
break;
|
||||
}
|
||||
case CTL_SETSYNC:
|
||||
case CTL_GETSYNC: {
|
||||
struct ctl_sync_info *sync_info;
|
||||
|
||||
sync_info = (struct ctl_sync_info *)addr;
|
||||
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
lun = softc->ctl_luns[sync_info->lun_id];
|
||||
if (lun == NULL) {
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
sync_info->status = CTL_GS_SYNC_NO_LUN;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Get or set the sync interval. We're not bounds checking
|
||||
* in the set case, hopefully the user won't do something
|
||||
* silly.
|
||||
*/
|
||||
mtx_lock(&lun->lun_lock);
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
if (cmd == CTL_GETSYNC)
|
||||
sync_info->sync_interval = lun->sync_interval;
|
||||
else
|
||||
lun->sync_interval = sync_info->sync_interval;
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
|
||||
sync_info->status = CTL_GS_SYNC_OK;
|
||||
|
||||
break;
|
||||
}
|
||||
case CTL_GETSTATS: {
|
||||
struct ctl_stats *stats;
|
||||
int i;
|
||||
@ -5301,8 +5094,6 @@ ctl_start_stop(struct ctl_scsiio *ctsio)
|
||||
CTL_DEBUG_PRINT(("ctl_start_stop\n"));
|
||||
|
||||
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
|
||||
retval = 0;
|
||||
|
||||
cdb = (struct scsi_start_stop_unit *)ctsio->cdb;
|
||||
|
||||
/*
|
||||
@ -5360,54 +5151,27 @@ ctl_start_stop(struct ctl_scsiio *ctsio)
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX KDM Copan-specific offline behavior.
|
||||
* Figure out a reasonable way to port this?
|
||||
* In the non-immediate case, we send the request to
|
||||
* the backend and return status to the user when
|
||||
* it is done.
|
||||
*
|
||||
* In the immediate case, we allocate a new ctl_io
|
||||
* to hold a copy of the request, and send that to
|
||||
* the backend. We then set good status on the
|
||||
* user's request and return it immediately.
|
||||
*/
|
||||
#ifdef NEEDTOPORT
|
||||
mtx_lock(&lun->lun_lock);
|
||||
if (cdb->byte2 & SSS_IMMED) {
|
||||
union ctl_io *new_io;
|
||||
|
||||
if (((cdb->byte2 & SSS_ONOFFLINE) == 0)
|
||||
&& (lun->flags & CTL_LUN_OFFLINE)) {
|
||||
/*
|
||||
* If the LUN is offline, and the on/offline bit isn't set,
|
||||
* reject the start or stop. Otherwise, let it through.
|
||||
*/
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
ctl_set_lun_not_ready(ctsio);
|
||||
new_io = ctl_alloc_io(ctsio->io_hdr.pool);
|
||||
ctl_copy_io((union ctl_io *)ctsio, new_io);
|
||||
retval = lun->backend->config_write(new_io);
|
||||
ctl_set_success(ctsio);
|
||||
ctl_done((union ctl_io *)ctsio);
|
||||
} else {
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
#endif /* NEEDTOPORT */
|
||||
/*
|
||||
* This could be a start or a stop when we're online,
|
||||
* or a stop/offline or start/online. A start or stop when
|
||||
* we're offline is covered in the case above.
|
||||
*/
|
||||
/*
|
||||
* In the non-immediate case, we send the request to
|
||||
* the backend and return status to the user when
|
||||
* it is done.
|
||||
*
|
||||
* In the immediate case, we allocate a new ctl_io
|
||||
* to hold a copy of the request, and send that to
|
||||
* the backend. We then set good status on the
|
||||
* user's request and return it immediately.
|
||||
*/
|
||||
if (cdb->byte2 & SSS_IMMED) {
|
||||
union ctl_io *new_io;
|
||||
|
||||
new_io = ctl_alloc_io(ctsio->io_hdr.pool);
|
||||
ctl_copy_io((union ctl_io *)ctsio, new_io);
|
||||
retval = lun->backend->config_write(new_io);
|
||||
ctl_set_success(ctsio);
|
||||
ctl_done((union ctl_io *)ctsio);
|
||||
} else {
|
||||
retval = lun->backend->config_write(
|
||||
(union ctl_io *)ctsio);
|
||||
}
|
||||
#ifdef NEEDTOPORT
|
||||
retval = lun->backend->config_write(
|
||||
(union ctl_io *)ctsio);
|
||||
}
|
||||
#endif
|
||||
return (retval);
|
||||
}
|
||||
|
||||
@ -5485,25 +5249,9 @@ ctl_sync_cache(struct ctl_scsiio *ctsio)
|
||||
lbalen->lba = starting_lba;
|
||||
lbalen->len = block_count;
|
||||
lbalen->flags = byte2;
|
||||
|
||||
/*
|
||||
* Check to see whether we're configured to send the SYNCHRONIZE
|
||||
* CACHE command directly to the back end.
|
||||
*/
|
||||
mtx_lock(&lun->lun_lock);
|
||||
if ((softc->flags & CTL_FLAG_REAL_SYNC)
|
||||
&& (++(lun->sync_count) >= lun->sync_interval)) {
|
||||
lun->sync_count = 0;
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
retval = lun->backend->config_write((union ctl_io *)ctsio);
|
||||
} else {
|
||||
mtx_unlock(&lun->lun_lock);
|
||||
ctl_set_success(ctsio);
|
||||
ctl_done((union ctl_io *)ctsio);
|
||||
}
|
||||
retval = lun->backend->config_write((union ctl_io *)ctsio);
|
||||
|
||||
bailout:
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
@ -6140,9 +5888,6 @@ ctl_debugconf_sp_sense_handler(struct ctl_scsiio *ctsio,
|
||||
page->ctl_time_io_secs[1] = ctl_time_io_secs >> 0;
|
||||
break;
|
||||
default:
|
||||
#ifdef NEEDTOPORT
|
||||
EPRINT(0, "Invalid PC %d!!", pc);
|
||||
#endif /* NEEDTOPORT */
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
@ -7798,18 +7543,6 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
|
||||
* sync), we've got a problem.
|
||||
*/
|
||||
if (key_count >= lun->pr_key_count) {
|
||||
#ifdef NEEDTOPORT
|
||||
csevent_log(CSC_CTL | CSC_SHELF_SW |
|
||||
CTL_PR_ERROR,
|
||||
csevent_LogType_Fault,
|
||||
csevent_AlertLevel_Yellow,
|
||||
csevent_FRU_ShelfController,
|
||||
csevent_FRU_Firmware,
|
||||
csevent_FRU_Unknown,
|
||||
"registered keys %d >= key "
|
||||
"count %d", key_count,
|
||||
lun->pr_key_count);
|
||||
#endif
|
||||
key_count++;
|
||||
continue;
|
||||
}
|
||||
|
@ -2742,18 +2742,8 @@ ctl_be_block_config_write(union ctl_io *io)
|
||||
|
||||
if (cdb->how & SSS_START)
|
||||
retval = ctl_start_lun(cbe_lun);
|
||||
else {
|
||||
else
|
||||
retval = ctl_stop_lun(cbe_lun);
|
||||
/*
|
||||
* XXX KDM Copan-specific offline behavior.
|
||||
* Figure out a reasonable way to port this?
|
||||
*/
|
||||
#ifdef NEEDTOPORT
|
||||
if ((retval == 0)
|
||||
&& (cdb->byte2 & SSS_ONOFFLINE))
|
||||
retval = ctl_lun_offline(cbe_lun);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* In general, the above routines should not fail. They
|
||||
|
@ -877,14 +877,8 @@ ctl_backend_ramdisk_config_write(union ctl_io *io)
|
||||
|
||||
if (cdb->how & SSS_START)
|
||||
retval = ctl_start_lun(cbe_lun);
|
||||
else {
|
||||
else
|
||||
retval = ctl_stop_lun(cbe_lun);
|
||||
#ifdef NEEDTOPORT
|
||||
if ((retval == 0)
|
||||
&& (cdb->byte2 & SSS_ONOFFLINE))
|
||||
retval = ctl_lun_offline(cbe_lun);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* In general, the above routines should not fail. They
|
||||
|
@ -130,9 +130,6 @@ cfcs_init(void)
|
||||
struct cfcs_softc *softc;
|
||||
struct ccb_setasync csa;
|
||||
struct ctl_port *port;
|
||||
#ifdef NEEDTOPORT
|
||||
char wwnn[8];
|
||||
#endif
|
||||
int retval;
|
||||
|
||||
softc = &cfcs_softc;
|
||||
@ -166,15 +163,6 @@ cfcs_init(void)
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the WWNN out of the database, and create a WWPN as well.
|
||||
*/
|
||||
#ifdef NEEDTOPORT
|
||||
ddb_GetWWNN((char *)wwnn);
|
||||
softc->wwnn = be64dec(wwnn);
|
||||
softc->wwpn = softc->wwnn + (softc->port.targ_port & 0xff);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the CTL frontend didn't tell us what our WWNN/WWPN is, go
|
||||
* ahead and set something random.
|
||||
|
@ -80,17 +80,6 @@
|
||||
/* Hopefully this won't conflict with new misc devices that pop up */
|
||||
#define CTL_MINOR 225
|
||||
|
||||
typedef enum {
|
||||
CTL_OOA_INVALID_LUN,
|
||||
CTL_OOA_SUCCESS
|
||||
} ctl_ooa_status;
|
||||
|
||||
struct ctl_ooa_info {
|
||||
uint32_t lun_id; /* Passed in to CTL */
|
||||
uint32_t num_entries; /* Returned from CTL */
|
||||
ctl_ooa_status status; /* Returned from CTL */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_DELAY_TYPE_NONE,
|
||||
CTL_DELAY_TYPE_CONT,
|
||||
@ -120,22 +109,6 @@ struct ctl_io_delay_info {
|
||||
ctl_delay_status status;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_GS_SYNC_NONE,
|
||||
CTL_GS_SYNC_OK,
|
||||
CTL_GS_SYNC_NO_LUN
|
||||
} ctl_gs_sync_status;
|
||||
|
||||
/*
|
||||
* The target and LUN id specify which device to modify. The sync interval
|
||||
* means that we will let through every N SYNCHRONIZE CACHE commands.
|
||||
*/
|
||||
struct ctl_sync_info {
|
||||
uint32_t lun_id; /* passed to kernel */
|
||||
int sync_interval; /* depends on whether get/set */
|
||||
ctl_gs_sync_status status; /* passed from kernel */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_STATS_NO_IO,
|
||||
CTL_STATS_READ,
|
||||
@ -321,23 +294,6 @@ struct ctl_ooa {
|
||||
ctl_get_ooa_status status; /* passed to userland */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_PORT_LIST_NONE,
|
||||
CTL_PORT_LIST_OK,
|
||||
CTL_PORT_LIST_NEED_MORE_SPACE,
|
||||
CTL_PORT_LIST_ERROR
|
||||
} ctl_port_list_status;
|
||||
|
||||
struct ctl_port_list {
|
||||
uint32_t alloc_len; /* passed to kernel */
|
||||
uint32_t alloc_num; /* passed to kernel */
|
||||
struct ctl_port_entry *entries; /* filled in kernel */
|
||||
uint32_t fill_len; /* passed to userland */
|
||||
uint32_t fill_num; /* passed to userland */
|
||||
uint32_t dropped_num; /* passed to userland */
|
||||
ctl_port_list_status status; /* passed to userland */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_LUN_NOSTATUS,
|
||||
CTL_LUN_OK,
|
||||
@ -804,18 +760,11 @@ struct ctl_lun_map {
|
||||
#define CTL_IO _IOWR(CTL_MINOR, 0x00, union ctl_io)
|
||||
#define CTL_ENABLE_PORT _IOW(CTL_MINOR, 0x04, struct ctl_port_entry)
|
||||
#define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry)
|
||||
#define CTL_DUMP_OOA _IO(CTL_MINOR, 0x06)
|
||||
#define CTL_CHECK_OOA _IOWR(CTL_MINOR, 0x07, struct ctl_ooa_info)
|
||||
#define CTL_DELAY_IO _IOWR(CTL_MINOR, 0x10, struct ctl_io_delay_info)
|
||||
#define CTL_REALSYNC_GET _IOR(CTL_MINOR, 0x11, int)
|
||||
#define CTL_REALSYNC_SET _IOW(CTL_MINOR, 0x12, int)
|
||||
#define CTL_SETSYNC _IOWR(CTL_MINOR, 0x13, struct ctl_sync_info)
|
||||
#define CTL_GETSYNC _IOWR(CTL_MINOR, 0x14, struct ctl_sync_info)
|
||||
#define CTL_GETSTATS _IOWR(CTL_MINOR, 0x15, struct ctl_stats)
|
||||
#define CTL_ERROR_INJECT _IOWR(CTL_MINOR, 0x16, struct ctl_error_desc)
|
||||
#define CTL_GET_OOA _IOWR(CTL_MINOR, 0x18, struct ctl_ooa)
|
||||
#define CTL_DUMP_STRUCTS _IO(CTL_MINOR, 0x19)
|
||||
#define CTL_GET_PORT_LIST _IOWR(CTL_MINOR, 0x20, struct ctl_port_list)
|
||||
#define CTL_LUN_REQ _IOWR(CTL_MINOR, 0x21, struct ctl_lun_req)
|
||||
#define CTL_LUN_LIST _IOWR(CTL_MINOR, 0x22, struct ctl_lun_list)
|
||||
#define CTL_ERROR_INJECT_DELETE _IOW(CTL_MINOR, 0x23, struct ctl_error_desc)
|
||||
|
@ -345,17 +345,6 @@ struct ctl_lun_delay_info {
|
||||
uint32_t done_delay;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_ERR_INJ_NONE = 0x00,
|
||||
CTL_ERR_INJ_ABORTED = 0x01
|
||||
} ctl_err_inject_flags;
|
||||
|
||||
typedef enum {
|
||||
CTL_PR_FLAG_NONE = 0x00,
|
||||
CTL_PR_FLAG_REGISTERED = 0x01,
|
||||
CTL_PR_FLAG_ACTIVE_RES = 0x02
|
||||
} ctl_per_res_flags;
|
||||
|
||||
#define CTL_PR_ALL_REGISTRANTS 0xFFFFFFFF
|
||||
#define CTL_PR_NO_RESERVATION 0xFFFFFFF0
|
||||
|
||||
@ -381,10 +370,7 @@ struct ctl_lun {
|
||||
struct ctl_softc *ctl_softc;
|
||||
struct ctl_be_lun *be_lun;
|
||||
struct ctl_backend_driver *backend;
|
||||
int io_count;
|
||||
struct ctl_lun_delay_info delay_info;
|
||||
int sync_interval;
|
||||
int sync_count;
|
||||
#ifdef CTL_TIME_IO
|
||||
sbintime_t idle_time;
|
||||
sbintime_t last_busy;
|
||||
@ -392,7 +378,6 @@ struct ctl_lun {
|
||||
TAILQ_HEAD(ctl_ooaq, ctl_io_hdr) ooa_queue;
|
||||
TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue;
|
||||
STAILQ_ENTRY(ctl_lun) links;
|
||||
STAILQ_ENTRY(ctl_lun) run_links;
|
||||
#ifdef CTL_WITH_CA
|
||||
uint32_t have_ca[CTL_MAX_INITIATORS >> 5];
|
||||
struct scsi_sense_data pending_sense[CTL_MAX_INITIATORS];
|
||||
@ -415,7 +400,6 @@ struct ctl_lun {
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CTL_FLAG_REAL_SYNC = 0x02,
|
||||
CTL_FLAG_ACTIVE_SHELF = 0x04
|
||||
} ctl_gen_flags;
|
||||
|
||||
|
@ -489,8 +489,7 @@ ctl_scsi_mode_sense(union ctl_io *io, uint8_t *data_ptr, uint32_t data_len,
|
||||
|
||||
void
|
||||
ctl_scsi_start_stop(union ctl_io *io, int start, int load_eject, int immediate,
|
||||
int power_conditions, int onoffline __unused,
|
||||
ctl_tag_type tag_type, uint8_t control)
|
||||
int power_conditions, ctl_tag_type tag_type, uint8_t control)
|
||||
{
|
||||
struct scsi_start_stop_unit *cdb;
|
||||
|
||||
@ -501,10 +500,6 @@ ctl_scsi_start_stop(union ctl_io *io, int start, int load_eject, int immediate,
|
||||
cdb->opcode = START_STOP_UNIT;
|
||||
if (immediate)
|
||||
cdb->byte2 |= SSS_IMMED;
|
||||
#ifdef NEEDTOPORT
|
||||
if (onoffline)
|
||||
cdb->byte2 |= SSS_ONOFFLINE;
|
||||
#endif
|
||||
cdb->how = power_conditions;
|
||||
if (load_eject)
|
||||
cdb->how |= SSS_LOEJ;
|
||||
@ -849,24 +844,8 @@ void
|
||||
ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data)
|
||||
{
|
||||
char str[512];
|
||||
#ifdef NEEDTOPORT
|
||||
char *message;
|
||||
char *line;
|
||||
|
||||
message = io_error_string(io, inq_data, str, sizeof(str));
|
||||
|
||||
for (line = strsep(&message, "\n"); line != NULL;
|
||||
line = strsep(&message, "\n")) {
|
||||
csevent_log(CSC_CTL | CSC_SHELF_SW | CTL_ERROR_REPORT,
|
||||
csevent_LogType_Trace,
|
||||
csevent_Severity_Information,
|
||||
csevent_AlertLevel_Green,
|
||||
csevent_FRU_Firmware,
|
||||
csevent_FRU_Unknown, "%s", line);
|
||||
}
|
||||
#else
|
||||
printf("%s", ctl_io_error_string(io, inq_data, str, sizeof(str)));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ void ctl_scsi_mode_sense(union ctl_io *io, uint8_t *data_ptr,
|
||||
int minimum_cdb_size, ctl_tag_type tag_type,
|
||||
uint8_t control);
|
||||
void ctl_scsi_start_stop(union ctl_io *io, int start, int load_eject,
|
||||
int immediate, int power_conditions, int onoffline,
|
||||
int immediate, int power_conditions,
|
||||
ctl_tag_type tag_type, uint8_t control);
|
||||
void ctl_scsi_sync_cache(union ctl_io *io, int immed, int reladr,
|
||||
int minimum_cdb_size, uint64_t starting_lba,
|
||||
|
@ -35,7 +35,7 @@
|
||||
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 12, 2015
|
||||
.Dd September 26, 2015
|
||||
.Dt CTLADM 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -118,12 +118,6 @@
|
||||
.Op Fl i
|
||||
.Op Fl c Ar cdbsize
|
||||
.Nm
|
||||
.Ic shutdown
|
||||
.Op general options
|
||||
.Nm
|
||||
.Ic startup
|
||||
.Op general options
|
||||
.Nm
|
||||
.Ic lunlist
|
||||
.Nm
|
||||
.Ic delay
|
||||
@ -132,15 +126,6 @@
|
||||
.Aq Fl t Ar secs
|
||||
.Op Fl T Ar oneshot|cont
|
||||
.Nm
|
||||
.Ic realsync Aq on|off|query
|
||||
.Nm
|
||||
.Ic setsync interval
|
||||
.Aq lun
|
||||
.Aq Fl i Ar interval
|
||||
.Nm
|
||||
.Ic getsync
|
||||
.Aq lun
|
||||
.Nm
|
||||
.Ic inject
|
||||
.Aq Fl i Ar action
|
||||
.Aq Fl p Ar pattern
|
||||
@ -176,14 +161,11 @@
|
||||
.Op Fl x
|
||||
.Nm
|
||||
.Ic port
|
||||
.Op Fl l
|
||||
.Op Fl o Ar on|off
|
||||
.Op Fl w Ar wwpn
|
||||
.Op Fl W Ar wwnn
|
||||
.Op Fl p Ar targ_port
|
||||
.Op Fl t Ar fe_type
|
||||
.Op Fl q
|
||||
.Op Fl x
|
||||
.Nm
|
||||
.Ic portlist
|
||||
.Op Fl f Ar frontend
|
||||
@ -418,17 +400,6 @@ bit set.
|
||||
Set the immediate bit in the CDB. Note that CTL does not support the
|
||||
immediate bit, so this is primarily useful for making sure that CTL returns
|
||||
the proper error.
|
||||
.It Fl o
|
||||
Set the Copan proprietary on/offline bit in the CDB. When this flag is
|
||||
used, the LUN will be marked online again (see the description of the
|
||||
.Ic shutdown
|
||||
and
|
||||
.Ic startup
|
||||
commands). When this flag is used with a
|
||||
start command, the LUN will NOT be spun up. You need to use a start
|
||||
command without the
|
||||
.Fl o
|
||||
flag to spin up the disks in the LUN.
|
||||
.El
|
||||
.It Ic stop
|
||||
Send the
|
||||
@ -444,14 +415,6 @@ sends an ordered tag for completeness.)
|
||||
Set the immediate bit in the CDB. Note that CTL does not support the
|
||||
immediate bit, so this is primarily useful for making sure that CTL returns
|
||||
the proper error.
|
||||
.It Fl o
|
||||
Set the Copan proprietary on/offline bit in the CDB. When this flag is
|
||||
used, the LUN will be spun down and taken offline ("Logical unit not ready,
|
||||
manual intervention required"). See the description of the
|
||||
.Ic shutdown
|
||||
and
|
||||
.Ic startup
|
||||
options.
|
||||
.El
|
||||
.It Ic synccache
|
||||
Send the
|
||||
@ -483,32 +446,6 @@ support this bit.
|
||||
.It Fl c Ar cdbsize
|
||||
Specify the minimum CDB size. Valid values are 10 and 16 bytes.
|
||||
.El
|
||||
.It Ic shutdown
|
||||
Issue a
|
||||
.Tn SCSI
|
||||
START STOP UNIT command with the start bit cleared and the on/offline bit
|
||||
set to all direct access LUNs. This will spin down all direct access LUNs,
|
||||
and mark them offline ("Logical unit not ready, manual intervention
|
||||
required"). Once marked offline, the state can only be cleared by sending
|
||||
a START STOP UNIT command with the start bit set and the on/offline bit
|
||||
set. The
|
||||
.Nm
|
||||
commands
|
||||
.Ic startup
|
||||
and
|
||||
.Ic start
|
||||
will accomplish this. Note that the
|
||||
on/offline bit is a non-standard Copan extension to the
|
||||
.Tn SCSI
|
||||
START STOP UNIT command, so merely sending a normal start command from an
|
||||
initiator will not clear the condition. (This is by design.)
|
||||
.It Ic startup
|
||||
Issue a
|
||||
.Tn SCSI
|
||||
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 lunlist
|
||||
List all LUNs registered with CTL.
|
||||
Because this command uses the ioctl port, it will only work when the FETDs
|
||||
@ -549,39 +486,6 @@ the next command sent to the given LUN will be delayed and all subsequent
|
||||
commands will be completed normally.
|
||||
This is the default.
|
||||
.El
|
||||
.It Ic realsync
|
||||
Query and control CTL's SYNCHRONIZE CACHE behavior. The
|
||||
.Sq query
|
||||
argument
|
||||
will show whether SYNCHRONIZE CACHE commands are being sent to the backend
|
||||
or not.
|
||||
The default is to send SYNCHRONIZE CACHE commands to the backend.
|
||||
The
|
||||
.Sq on
|
||||
argument will cause all SYNCHRONIZE CACHE commands sent to all LUNs to be
|
||||
sent to the backend.
|
||||
The
|
||||
.Sq off
|
||||
argument will cause all SYNCHRONIZE CACHE commands sent to all LUNs to be
|
||||
immediately returned to the initiator with successful status.
|
||||
.It Ic setsync
|
||||
For a given lun, only actually service every Nth SYNCHRONIZE CACHE command
|
||||
that is sent. This can be used for debugging the optimal time period for
|
||||
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 LUN you want to modify.
|
||||
.It Ic getsync
|
||||
Get the interval at which we actually service the SYNCHRONIZE CACHE
|
||||
command, as set by the
|
||||
.Ic setsync
|
||||
command above.
|
||||
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 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.
|
||||
@ -689,8 +593,6 @@ must be specified.
|
||||
The WWNN and WWPN may both be specified at the same time, but cannot be
|
||||
combined with enabling/disabling or listing ports.
|
||||
.Bl -tag -width 12n
|
||||
.It Fl l
|
||||
List all CTL frontend ports or a specific port type or number.
|
||||
.It Fl o Ar on|off
|
||||
Turn the specified CTL frontend ports off or on.
|
||||
If no port number or port type is specified, all ports are turned on or
|
||||
@ -698,8 +600,6 @@ off.
|
||||
.It Fl p Ar targ_port
|
||||
Specify the frontend port number.
|
||||
The port numbers can be found in the frontend port list.
|
||||
.It Fl q
|
||||
Omit the header in the port list output.
|
||||
.It Fl t Ar fe_type
|
||||
Specify the frontend type.
|
||||
Currently defined port types are
|
||||
@ -727,8 +627,6 @@ The
|
||||
argument must be specified, since this is only possible to implement on a
|
||||
single port.
|
||||
As a general rule, the WWPN must be different for every port in the system.
|
||||
.It Fl x
|
||||
Output the port list in XML format.
|
||||
.El
|
||||
.It Ic portlist
|
||||
List CTL frontend ports.
|
||||
|
@ -101,13 +101,8 @@ typedef enum {
|
||||
CTLADM_CMD_START,
|
||||
CTLADM_CMD_STOP,
|
||||
CTLADM_CMD_SYNC_CACHE,
|
||||
CTLADM_CMD_SHUTDOWN,
|
||||
CTLADM_CMD_STARTUP,
|
||||
CTLADM_CMD_LUNLIST,
|
||||
CTLADM_CMD_DELAY,
|
||||
CTLADM_CMD_REALSYNC,
|
||||
CTLADM_CMD_SETSYNC,
|
||||
CTLADM_CMD_GETSYNC,
|
||||
CTLADM_CMD_ERR_INJECT,
|
||||
CTLADM_CMD_PRES_IN,
|
||||
CTLADM_CMD_PRES_OUT,
|
||||
@ -163,7 +158,7 @@ typedef enum {
|
||||
} ctladm_optret;
|
||||
|
||||
static const char rw_opts[] = "Nb:c:d:f:l:";
|
||||
static const char startstop_opts[] = "io";
|
||||
static const char startstop_opts[] = "i";
|
||||
|
||||
static struct ctladm_opts option_table[] = {
|
||||
{"adddev", CTLADM_CMD_ADDDEV, CTLADM_ARG_NONE, NULL},
|
||||
@ -173,7 +168,6 @@ static struct ctladm_opts option_table[] = {
|
||||
{"devlist", CTLADM_CMD_DEVLIST, CTLADM_ARG_NONE, "b:vx"},
|
||||
{"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},
|
||||
{"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},
|
||||
@ -190,15 +184,11 @@ static struct ctladm_opts option_table[] = {
|
||||
{"prout", CTLADM_CMD_PRES_OUT, CTLADM_ARG_NEED_TL, "a:k:r:s:"},
|
||||
{"read", CTLADM_CMD_READ, CTLADM_ARG_NEED_TL, rw_opts},
|
||||
{"readcapacity", CTLADM_CMD_READCAPACITY, CTLADM_ARG_NEED_TL, "c:"},
|
||||
{"realsync", CTLADM_CMD_REALSYNC, CTLADM_ARG_NONE, NULL},
|
||||
{"remove", CTLADM_CMD_RM, CTLADM_ARG_NONE, "b:l:o:"},
|
||||
{"reportluns", CTLADM_CMD_REPORT_LUNS, CTLADM_ARG_NEED_TL, NULL},
|
||||
{"reqsense", CTLADM_CMD_REQ_SENSE, CTLADM_ARG_NEED_TL, NULL},
|
||||
{"rtpg", CTLADM_CMD_RTPG, CTLADM_ARG_NEED_TL, NULL},
|
||||
{"setsync", CTLADM_CMD_SETSYNC, CTLADM_ARG_NEED_TL, "i:"},
|
||||
{"shutdown", CTLADM_CMD_SHUTDOWN, CTLADM_ARG_NONE, NULL},
|
||||
{"start", CTLADM_CMD_START, CTLADM_ARG_NEED_TL, startstop_opts},
|
||||
{"startup", CTLADM_CMD_STARTUP, CTLADM_ARG_NONE, NULL},
|
||||
{"stop", CTLADM_CMD_STOP, CTLADM_ARG_NEED_TL, startstop_opts},
|
||||
{"synccache", CTLADM_CMD_SYNC_CACHE, CTLADM_ARG_NEED_TL, "b:c:il:r"},
|
||||
{"tur", CTLADM_CMD_TUR, CTLADM_ARG_NEED_TL, NULL},
|
||||
@ -212,15 +202,11 @@ 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_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 lun, int argc, char **argv,
|
||||
char *combinedopt);
|
||||
static int cctl_lunlist(int fd);
|
||||
static int cctl_startup_shutdown(int fd, int lun, int iid,
|
||||
ctladm_cmdfunction command);
|
||||
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 lun, int iid, int retries,
|
||||
@ -253,6 +239,7 @@ static int cctl_create_lun(int fd, int argc, char **argv, char *combinedopt);
|
||||
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);
|
||||
static int cctl_portlist(int fd, int argc, char **argv, char *combinedopt);
|
||||
|
||||
ctladm_optret
|
||||
getoption(struct ctladm_opts *table, char *arg, uint32_t *cmdnum,
|
||||
@ -287,9 +274,7 @@ cctl_dump_ooa(int fd, int argc, char **argv)
|
||||
{
|
||||
struct ctl_ooa ooa;
|
||||
long double cmd_latency;
|
||||
int num_entries, len;
|
||||
int lun = -1;
|
||||
int retval;
|
||||
int num_entries, len, lun = -1, retval = 0;
|
||||
unsigned int i;
|
||||
|
||||
num_entries = 104;
|
||||
@ -299,21 +284,16 @@ cctl_dump_ooa(int fd, int argc, char **argv)
|
||||
retry:
|
||||
|
||||
len = num_entries * sizeof(struct ctl_ooa_entry);
|
||||
|
||||
bzero(&ooa, sizeof(ooa));
|
||||
|
||||
ooa.entries = malloc(len);
|
||||
|
||||
if (ooa.entries == NULL) {
|
||||
warn("%s: error mallocing %d bytes", __func__, len);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
if (lun >= 0) {
|
||||
ooa.lun_num = lun;
|
||||
} else
|
||||
ooa.flags |= CTL_OOA_FLAG_ALL_LUNS;
|
||||
|
||||
ooa.alloc_len = len;
|
||||
ooa.alloc_num = num_entries;
|
||||
if (ioctl(fd, CTL_GET_OOA, &ooa) == -1) {
|
||||
@ -368,17 +348,10 @@ cctl_dump_ooa(int fd, int argc, char **argv)
|
||||
cmd_latency);
|
||||
}
|
||||
fprintf(stdout, "OOA queues dump done\n");
|
||||
#if 0
|
||||
if (ioctl(fd, CTL_DUMP_OOA) == -1) {
|
||||
warn("%s: CTL_DUMP_OOA ioctl failed", __func__);
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
bailout:
|
||||
free(ooa.entries);
|
||||
|
||||
return (0);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -391,152 +364,6 @@ cctl_dump_structs(int fd, ctladm_cmdargs cmdargs __unused)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cctl_port_dump(int fd, int quiet, int xml, int32_t targ_port,
|
||||
ctl_port_type port_type)
|
||||
{
|
||||
struct ctl_port_list port_list;
|
||||
struct ctl_port_entry *entries;
|
||||
struct sbuf *sb = NULL;
|
||||
int num_entries;
|
||||
int did_print = 0;
|
||||
unsigned int i;
|
||||
|
||||
num_entries = 16;
|
||||
|
||||
retry:
|
||||
|
||||
entries = malloc(sizeof(*entries) * num_entries);
|
||||
bzero(&port_list, sizeof(port_list));
|
||||
port_list.entries = entries;
|
||||
port_list.alloc_num = num_entries;
|
||||
port_list.alloc_len = num_entries * sizeof(*entries);
|
||||
if (ioctl(fd, CTL_GET_PORT_LIST, &port_list) != 0) {
|
||||
warn("%s: CTL_GET_PORT_LIST ioctl failed", __func__);
|
||||
return (1);
|
||||
}
|
||||
if (port_list.status == CTL_PORT_LIST_NEED_MORE_SPACE) {
|
||||
printf("%s: allocated %d, need %d, retrying\n", __func__,
|
||||
num_entries, port_list.fill_num + port_list.dropped_num);
|
||||
free(entries);
|
||||
num_entries = port_list.fill_num + port_list.dropped_num;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
if ((quiet == 0)
|
||||
&& (xml == 0))
|
||||
printf("Port Online Type Name pp vp %-18s %-18s\n",
|
||||
"WWNN", "WWPN");
|
||||
|
||||
if (xml != 0) {
|
||||
sb = sbuf_new_auto();
|
||||
sbuf_printf(sb, "<ctlfelist>\n");
|
||||
}
|
||||
for (i = 0; i < port_list.fill_num; i++) {
|
||||
struct ctl_port_entry *entry;
|
||||
const char *type;
|
||||
|
||||
entry = &entries[i];
|
||||
|
||||
switch (entry->port_type) {
|
||||
case CTL_PORT_FC:
|
||||
type = "FC";
|
||||
break;
|
||||
case CTL_PORT_SCSI:
|
||||
type = "SCSI";
|
||||
break;
|
||||
case CTL_PORT_IOCTL:
|
||||
type = "IOCTL";
|
||||
break;
|
||||
case CTL_PORT_INTERNAL:
|
||||
type = "INTERNAL";
|
||||
break;
|
||||
case CTL_PORT_ISC:
|
||||
type = "ISC";
|
||||
break;
|
||||
case CTL_PORT_ISCSI:
|
||||
type = "ISCSI";
|
||||
break;
|
||||
case CTL_PORT_SAS:
|
||||
type = "SAS";
|
||||
break;
|
||||
default:
|
||||
type = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the user specified a frontend number or a particular
|
||||
* frontend type, only print out that particular frontend
|
||||
* or frontend type.
|
||||
*/
|
||||
if ((targ_port != -1)
|
||||
&& (targ_port != entry->targ_port))
|
||||
continue;
|
||||
else if ((port_type != CTL_PORT_NONE)
|
||||
&& ((port_type & entry->port_type) == 0))
|
||||
continue;
|
||||
|
||||
did_print = 1;
|
||||
|
||||
#if 0
|
||||
printf("Num: %ju Type: %s (%#x) Name: %s Physical Port: %d "
|
||||
"Virtual Port: %d\n", (uintmax_t)entry->fe_num, type,
|
||||
entry->port_type, entry->fe_name, entry->physical_port,
|
||||
entry->virtual_port);
|
||||
printf("WWNN %#jx WWPN %#jx Online: %s\n",
|
||||
(uintmax_t)entry->wwnn, (uintmax_t)entry->wwpn,
|
||||
(entry->online) ? "YES" : "NO" );
|
||||
#endif
|
||||
if (xml == 0) {
|
||||
printf("%-4d %-6s %-8s %-12s %-2d %-2d %#-18jx "
|
||||
"%#-18jx\n",
|
||||
entry->targ_port, (entry->online) ? "YES" : "NO",
|
||||
type, entry->port_name, entry->physical_port,
|
||||
entry->virtual_port, (uintmax_t)entry->wwnn,
|
||||
(uintmax_t)entry->wwpn);
|
||||
} else {
|
||||
sbuf_printf(sb, "<targ_port id=\"%d\">\n",
|
||||
entry->targ_port);
|
||||
sbuf_printf(sb, "<online>%s</online>\n",
|
||||
(entry->online) ? "YES" : "NO");
|
||||
sbuf_printf(sb, "<port_type>%s</port_type>\n", type);
|
||||
sbuf_printf(sb, "<port_name>%s</port_name>\n",
|
||||
entry->port_name);
|
||||
sbuf_printf(sb, "<physical_port>%d</physical_port>\n",
|
||||
entry->physical_port);
|
||||
sbuf_printf(sb, "<virtual_port>%d</virtual_port>\n",
|
||||
entry->virtual_port);
|
||||
sbuf_printf(sb, "<wwnn>%#jx</wwnn>\n",
|
||||
(uintmax_t)entry->wwnn);
|
||||
sbuf_printf(sb, "<wwpn>%#jx</wwpn>\n",
|
||||
(uintmax_t)entry->wwpn);
|
||||
sbuf_printf(sb, "</targ_port>\n");
|
||||
}
|
||||
|
||||
}
|
||||
if (xml != 0) {
|
||||
sbuf_printf(sb, "</ctlfelist>\n");
|
||||
if (sbuf_finish(sb) != 0)
|
||||
err(1, "%s: sbuf_finish", __func__);
|
||||
printf("%s", sbuf_data(sb));
|
||||
sbuf_delete(sb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give some indication that we didn't find the frontend or
|
||||
* frontend type requested by the user. We could print something
|
||||
* out, but it would probably be better to hide that behind a
|
||||
* verbose flag.
|
||||
*/
|
||||
if ((did_print == 0)
|
||||
&& ((targ_port != -1)
|
||||
|| (port_type != CTL_PORT_NONE)))
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
CCTL_PORT_MODE_NONE,
|
||||
CCTL_PORT_MODE_LIST,
|
||||
@ -672,9 +499,22 @@ cctl_port(int fd, int argc, char **argv, char *combinedopt)
|
||||
entry.targ_port = targ_port;
|
||||
|
||||
switch (port_mode) {
|
||||
case CCTL_PORT_MODE_LIST:
|
||||
cctl_port_dump(fd, quiet, xml, targ_port, port_type);
|
||||
case CCTL_PORT_MODE_LIST: {
|
||||
char opts[] = "xq";
|
||||
char argx[] = "-x";
|
||||
char argq[] = "-q";
|
||||
char *argvx[2];
|
||||
int argcx = 0;
|
||||
|
||||
optind = 0;
|
||||
optreset = 1;
|
||||
if (xml)
|
||||
argvx[argcx++] = argx;
|
||||
if (quiet)
|
||||
argvx[argcx++] = argq;
|
||||
cctl_portlist(fd, argcx, argvx, opts);
|
||||
break;
|
||||
}
|
||||
case CCTL_PORT_MODE_SET:
|
||||
if (targ_port == -1) {
|
||||
warnx("%s: -w and -W require -n", __func__);
|
||||
@ -839,136 +679,10 @@ cctl_delay(int fd, int lun, int argc, char **argv,
|
||||
retval = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
bailout:
|
||||
|
||||
/* delayloc should never be NULL, but just in case...*/
|
||||
if (delayloc != NULL)
|
||||
free(delayloc);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
cctl_realsync(int fd, int argc, char **argv)
|
||||
{
|
||||
int syncstate;
|
||||
int retval;
|
||||
char *syncarg;
|
||||
|
||||
retval = 0;
|
||||
|
||||
if (argc != 3) {
|
||||
warnx("%s %s takes exactly one argument", argv[0], argv[1]);
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
syncarg = argv[2];
|
||||
|
||||
if (strncasecmp(syncarg, "query", min(strlen(syncarg),
|
||||
strlen("query"))) == 0) {
|
||||
if (ioctl(fd, CTL_REALSYNC_GET, &syncstate) == -1) {
|
||||
warn("%s: CTL_REALSYNC_GET ioctl failed", __func__);
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
fprintf(stdout, "SYNCHRONIZE CACHE support is: ");
|
||||
switch (syncstate) {
|
||||
case 0:
|
||||
fprintf(stdout, "OFF\n");
|
||||
break;
|
||||
case 1:
|
||||
fprintf(stdout, "ON\n");
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "unknown (%d)\n", syncstate);
|
||||
break;
|
||||
}
|
||||
goto bailout;
|
||||
} else if (strcasecmp(syncarg, "on") == 0) {
|
||||
syncstate = 1;
|
||||
} else if (strcasecmp(syncarg, "off") == 0) {
|
||||
syncstate = 0;
|
||||
} else {
|
||||
warnx("%s: invalid realsync argument %s", __func__, syncarg);
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
if (ioctl(fd, CTL_REALSYNC_SET, &syncstate) == -1) {
|
||||
warn("%s: CTL_REALSYNC_SET ioctl failed", __func__);
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
bailout:
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
cctl_getsetsync(int fd, int lun, ctladm_cmdfunction command,
|
||||
int argc, char **argv, char *combinedopt)
|
||||
{
|
||||
struct ctl_sync_info sync_info;
|
||||
uint32_t ioctl_cmd;
|
||||
int sync_interval = -1;
|
||||
int retval;
|
||||
int c;
|
||||
|
||||
retval = 0;
|
||||
|
||||
memset(&sync_info, 0, sizeof(sync_info));
|
||||
sync_info.lun_id = lun;
|
||||
|
||||
while ((c = getopt(argc, argv, combinedopt)) != -1) {
|
||||
switch (c) {
|
||||
case 'i':
|
||||
sync_interval = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (command == CTLADM_CMD_SETSYNC) {
|
||||
if (sync_interval == -1) {
|
||||
warnx("%s: you must specify the sync interval with -i",
|
||||
__func__);
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
sync_info.sync_interval = sync_interval;
|
||||
ioctl_cmd = CTL_SETSYNC;
|
||||
} else {
|
||||
ioctl_cmd = CTL_GETSYNC;
|
||||
}
|
||||
|
||||
if (ioctl(fd, ioctl_cmd, &sync_info) == -1) {
|
||||
warn("%s: CTL_%sSYNC ioctl failed", __func__,
|
||||
(command == CTLADM_CMD_SETSYNC) ? "SET" : "GET");
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
switch (sync_info.status) {
|
||||
case CTL_GS_SYNC_OK:
|
||||
if (command == CTLADM_CMD_GETSYNC) {
|
||||
fprintf(stdout, "%d: sync interval: %d\n",
|
||||
lun, sync_info.sync_interval);
|
||||
}
|
||||
break;
|
||||
case CTL_GS_SYNC_NO_LUN:
|
||||
warnx("%s: unknown LUN %d", __func__, lun);
|
||||
retval = 1;
|
||||
break;
|
||||
case CTL_GS_SYNC_NONE:
|
||||
default:
|
||||
warnx("%s: unknown CTL_%sSYNC status %d", __func__,
|
||||
(command == CTLADM_CMD_SETSYNC) ? "SET" : "GET",
|
||||
sync_info.status);
|
||||
retval = 1;
|
||||
break;
|
||||
}
|
||||
bailout:
|
||||
free(delayloc);
|
||||
free(delaytype);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
@ -1225,9 +939,7 @@ cctl_lunlist(int fd)
|
||||
unsigned int i;
|
||||
int retval;
|
||||
|
||||
retval = 0;
|
||||
inq_data = NULL;
|
||||
|
||||
initid = 7;
|
||||
|
||||
/*
|
||||
@ -1291,160 +1003,6 @@ cctl_lunlist(int fd)
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
cctl_startup_shutdown(int fd, int lun, int iid,
|
||||
ctladm_cmdfunction command)
|
||||
{
|
||||
union ctl_io *io;
|
||||
struct scsi_report_luns_data *lun_data;
|
||||
struct scsi_inquiry_data *inq_data;
|
||||
uint32_t num_luns;
|
||||
unsigned int i;
|
||||
int retval;
|
||||
|
||||
retval = 0;
|
||||
inq_data = NULL;
|
||||
|
||||
/*
|
||||
* - report luns
|
||||
* - step through each lun, do an inquiry
|
||||
* - check OOA queue on direct access luns
|
||||
* - send stop with offline bit to each direct access device with a
|
||||
* clear OOA queue
|
||||
* - if we get a reservation conflict, reset the LUN to clear it
|
||||
* and reissue the stop with the offline bit set
|
||||
*/
|
||||
|
||||
io = ctl_scsi_alloc_io(iid);
|
||||
if (io == NULL) {
|
||||
warnx("%s: can't allocate memory", __func__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((retval = cctl_get_luns(fd, lun, iid, /*retries*/ 2,
|
||||
&lun_data, &num_luns)) != 0)
|
||||
goto bailout;
|
||||
|
||||
inq_data = malloc(sizeof(*inq_data));
|
||||
if (inq_data == NULL) {
|
||||
warn("%s: couldn't allocate memory for inquiry data\n",
|
||||
__func__);
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
for (i = 0; i < num_luns; i++) {
|
||||
char scsi_path[40];
|
||||
int lun_val;
|
||||
|
||||
/*
|
||||
* XXX KDM figure out a way to share this code with
|
||||
* cctl_lunlist()?
|
||||
*/
|
||||
switch (lun_data->luns[i].lundata[0] & RPL_LUNDATA_ATYP_MASK) {
|
||||
case RPL_LUNDATA_ATYP_PERIPH:
|
||||
lun_val = lun_data->luns[i].lundata[1];
|
||||
break;
|
||||
case RPL_LUNDATA_ATYP_FLAT:
|
||||
lun_val = (lun_data->luns[i].lundata[0] &
|
||||
RPL_LUNDATA_FLAT_LUN_MASK) |
|
||||
(lun_data->luns[i].lundata[1] <<
|
||||
RPL_LUNDATA_FLAT_LUN_BITS);
|
||||
break;
|
||||
case RPL_LUNDATA_ATYP_LUN:
|
||||
case RPL_LUNDATA_ATYP_EXTLUN:
|
||||
default:
|
||||
fprintf(stdout, "Unsupported LUN format %d\n",
|
||||
lun_data->luns[i].lundata[0] &
|
||||
RPL_LUNDATA_ATYP_MASK);
|
||||
lun_val = -1;
|
||||
break;
|
||||
}
|
||||
if (lun_val == -1)
|
||||
continue;
|
||||
|
||||
if ((retval = cctl_get_inquiry(fd, lun_val, iid,
|
||||
/*retries*/ 2, scsi_path,
|
||||
sizeof(scsi_path),
|
||||
inq_data)) != 0) {
|
||||
goto bailout;
|
||||
}
|
||||
printf("%s", scsi_path);
|
||||
scsi_print_inquiry(inq_data);
|
||||
/*
|
||||
* We only want to shutdown direct access devices.
|
||||
*/
|
||||
if (SID_TYPE(inq_data) != T_DIRECT) {
|
||||
printf("%s LUN is not direct access, skipped\n",
|
||||
scsi_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (command == CTLADM_CMD_SHUTDOWN) {
|
||||
struct ctl_ooa_info ooa_info;
|
||||
|
||||
ooa_info.lun_id = lun_val;
|
||||
|
||||
if (ioctl(fd, CTL_CHECK_OOA, &ooa_info) == -1) {
|
||||
printf("%s CTL_CHECK_OOA ioctl failed\n",
|
||||
scsi_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ooa_info.status != CTL_OOA_SUCCESS) {
|
||||
printf("%s CTL_CHECK_OOA returned status %d\n",
|
||||
scsi_path, ooa_info.status);
|
||||
continue;
|
||||
}
|
||||
if (ooa_info.num_entries != 0) {
|
||||
printf("%s %d entr%s in the OOA queue, "
|
||||
"skipping shutdown\n", scsi_path,
|
||||
ooa_info.num_entries,
|
||||
(ooa_info.num_entries > 1)?"ies" : "y" );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ctl_scsi_start_stop(/*io*/ io,
|
||||
/*start*/(command == CTLADM_CMD_STARTUP) ?
|
||||
1 : 0,
|
||||
/*load_eject*/ 0,
|
||||
/*immediate*/ 0,
|
||||
/*power_conditions*/ SSS_PC_START_VALID,
|
||||
/*onoffline*/ 1,
|
||||
/*ctl_tag_type*/
|
||||
(command == CTLADM_CMD_STARTUP) ?
|
||||
CTL_TAG_SIMPLE :CTL_TAG_ORDERED,
|
||||
/*control*/ 0);
|
||||
|
||||
io->io_hdr.nexus.targ_lun = lun_val;
|
||||
io->io_hdr.nexus.initid = iid;
|
||||
|
||||
if (cctl_do_io(fd, /*retries*/ 3, io, __func__) != 0) {
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS)
|
||||
ctl_io_error_print(io, inq_data, stderr);
|
||||
else {
|
||||
printf("%s LUN is now %s\n", scsi_path,
|
||||
(command == CTLADM_CMD_STARTUP) ? "online" :
|
||||
"offline");
|
||||
}
|
||||
}
|
||||
bailout:
|
||||
if (lun_data != NULL)
|
||||
free(lun_data);
|
||||
|
||||
if (inq_data != NULL)
|
||||
free(inq_data);
|
||||
|
||||
if (io != NULL)
|
||||
ctl_scsi_free_io(io);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
cctl_sync_cache(int fd, int lun, int iid, int retries,
|
||||
int argc, char **argv, char *combinedopt)
|
||||
@ -1535,7 +1093,7 @@ cctl_start_stop(int fd, int lun, int iid, int retries, int start,
|
||||
{
|
||||
union ctl_io *io;
|
||||
char scsi_path[40];
|
||||
int immed = 0, onoffline = 0;
|
||||
int immed = 0;
|
||||
int retval, c;
|
||||
|
||||
retval = 0;
|
||||
@ -1551,9 +1109,6 @@ cctl_start_stop(int fd, int lun, int iid, int retries, int start,
|
||||
case 'i':
|
||||
immed = 1;
|
||||
break;
|
||||
case 'o':
|
||||
onoffline = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1570,7 +1125,6 @@ cctl_start_stop(int fd, int lun, int iid, int retries, int start,
|
||||
/*load_eject*/ 0,
|
||||
/*immediate*/ immed,
|
||||
/*power_conditions*/ SSS_PC_START_VALID,
|
||||
/*onoffline*/ onoffline,
|
||||
/*ctl_tag_type*/ start ? CTL_TAG_SIMPLE :
|
||||
CTL_TAG_ORDERED,
|
||||
/*control*/ 0);
|
||||
@ -2319,8 +1873,6 @@ cctl_inquiry(int fd, int lun, int iid, int retries)
|
||||
char scsi_path[40];
|
||||
int retval;
|
||||
|
||||
retval = 0;
|
||||
|
||||
inq_data = malloc(sizeof(*inq_data));
|
||||
if (inq_data == NULL) {
|
||||
warnx("%s: can't allocate inquiry data", __func__);
|
||||
@ -2586,8 +2138,6 @@ cctl_persistent_reserve_in(int fd, int lun, int iid,
|
||||
if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) {
|
||||
int returned_len, used_len;
|
||||
|
||||
returned_len = 0;
|
||||
|
||||
switch (action) {
|
||||
case 0:
|
||||
returned_len = scsi_4btoul(&dataptr[4]) + 8;
|
||||
@ -4303,19 +3853,14 @@ usage(int error)
|
||||
" ctladm remove <-b backend> <-l lun_id> [-o name=value]\n"
|
||||
" ctladm modify <-b backend> <-l lun_id> <-s size_bytes>\n"
|
||||
" ctladm devlist [-b backend] [-v] [-x]\n"
|
||||
" ctladm shutdown\n"
|
||||
" ctladm startup\n"
|
||||
" ctladm lunlist\n"
|
||||
" ctladm lunmap -p targ_port [-l pLUN] [-L cLUN]\n"
|
||||
" ctladm delay [dev_id] <-l datamove|done> [-T oneshot|cont]\n"
|
||||
" [-t secs]\n"
|
||||
" ctladm realsync <on|off|query>\n"
|
||||
" ctladm setsync [dev_id] <-i interval>\n"
|
||||
" ctladm getsync [dev_id]\n"
|
||||
" ctladm inject [dev_id] <-i action> <-p pattern> [-r lba,len]\n"
|
||||
" [-s len fmt [args]] [-c] [-d delete_id]\n"
|
||||
" ctladm port <-l | -o <on|off> | [-w wwnn][-W wwpn]>\n"
|
||||
" [-p targ_port] [-t port_type] [-q] [-x]\n"
|
||||
" ctladm port <-o <on|off> | [-w wwnn][-W wwpn]>\n"
|
||||
" [-p targ_port] [-t port_type]\n"
|
||||
" ctladm portlist [-f frontend] [-i] [-p targ_port] [-q] [-v] [-x]\n"
|
||||
" ctladm islist [-v | -x]\n"
|
||||
" ctladm islogout <-a | -c connection-id | -i name | -p portal>\n"
|
||||
@ -4655,25 +4200,12 @@ main(int argc, char **argv)
|
||||
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, lun, initid,
|
||||
command);
|
||||
break;
|
||||
case CTLADM_CMD_LUNLIST:
|
||||
retval = cctl_lunlist(fd);
|
||||
break;
|
||||
case CTLADM_CMD_DELAY:
|
||||
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, lun, command,
|
||||
argc, argv, combinedopt);
|
||||
break;
|
||||
case CTLADM_CMD_ERR_INJECT:
|
||||
retval = cctl_error_inject(fd, lun, argc, argv,
|
||||
combinedopt);
|
||||
|
@ -475,7 +475,7 @@ conf_new_from_kernel(void)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (list.status == CTL_PORT_LIST_ERROR) {
|
||||
if (list.status == CTL_LUN_LIST_ERROR) {
|
||||
log_warnx("error returned from CTL_PORT_LIST ioctl: %s",
|
||||
list.error_str);
|
||||
free(str);
|
||||
|
Loading…
Reference in New Issue
Block a user