From 4d9db975e6785ce86251f3905fdc6b924b074762 Mon Sep 17 00:00:00 2001 From: mav Date: Mon, 5 Oct 2015 11:25:48 +0000 Subject: MFC r288259: Remove some duplicate, legacy, dead and questionable code. --- sys/cam/ctl/ctl.c | 303 +++---------------------------------- sys/cam/ctl/ctl_backend_block.c | 12 +- sys/cam/ctl/ctl_backend_ramdisk.c | 8 +- sys/cam/ctl/ctl_frontend_cam_sim.c | 12 -- sys/cam/ctl/ctl_ioctl.h | 51 ------- sys/cam/ctl/ctl_private.h | 16 -- sys/cam/ctl/ctl_util.c | 25 +-- sys/cam/ctl/ctl_util.h | 2 +- 8 files changed, 23 insertions(+), 406 deletions(-) (limited to 'sys/cam') diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 5ce90e9..577b716 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -1756,12 +1756,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, @@ -2588,112 +2583,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; @@ -2776,38 +2665,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; @@ -2863,70 +2720,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; @@ -5303,8 +5096,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; /* @@ -5362,54 +5153,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); } @@ -5487,25 +5251,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); } @@ -6142,9 +5890,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); @@ -7800,18 +7545,6 @@ retry: * 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; } diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index 3e8550a..51215ac 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -2756,18 +2756,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 diff --git a/sys/cam/ctl/ctl_backend_ramdisk.c b/sys/cam/ctl/ctl_backend_ramdisk.c index 0382fde..caf3059 100644 --- a/sys/cam/ctl/ctl_backend_ramdisk.c +++ b/sys/cam/ctl/ctl_backend_ramdisk.c @@ -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 diff --git a/sys/cam/ctl/ctl_frontend_cam_sim.c b/sys/cam/ctl/ctl_frontend_cam_sim.c index fb862c6..428cf44 100644 --- a/sys/cam/ctl/ctl_frontend_cam_sim.c +++ b/sys/cam/ctl/ctl_frontend_cam_sim.c @@ -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; @@ -167,15 +164,6 @@ cfcs_init(void) } /* - * 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. */ diff --git a/sys/cam/ctl/ctl_ioctl.h b/sys/cam/ctl/ctl_ioctl.h index 937b51d..347f931 100644 --- a/sys/cam/ctl/ctl_ioctl.h +++ b/sys/cam/ctl/ctl_ioctl.h @@ -81,17 +81,6 @@ #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, CTL_DELAY_TYPE_ONESHOT @@ -121,22 +110,6 @@ struct ctl_io_delay_info { }; 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, CTL_STATS_WRITE @@ -322,23 +295,6 @@ struct ctl_ooa { }; 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, CTL_LUN_ERROR, @@ -792,18 +748,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) diff --git a/sys/cam/ctl/ctl_private.h b/sys/cam/ctl/ctl_private.h index caa6a4b..2da9727 100644 --- a/sys/cam/ctl/ctl_private.h +++ b/sys/cam/ctl/ctl_private.h @@ -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; diff --git a/sys/cam/ctl/ctl_util.c b/sys/cam/ctl/ctl_util.c index d501b57..6fcec03 100644 --- a/sys/cam/ctl/ctl_util.c +++ b/sys/cam/ctl/ctl_util.c @@ -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 } diff --git a/sys/cam/ctl/ctl_util.h b/sys/cam/ctl/ctl_util.h index b1c0d84..2966b49 100644 --- a/sys/cam/ctl/ctl_util.h +++ b/sys/cam/ctl/ctl_util.h @@ -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, -- cgit v1.1