Date: Sat, 26 Sep 2015 11:28:46 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288259 - in head: sys/cam/ctl usr.sbin/ctladm usr.sbin/ctld Message-ID: <201509261128.t8QBSkgb017628@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sat Sep 26 11:28:45 2015 New Revision: 288259 URL: https://svnweb.freebsd.org/changeset/base/288259 Log: Remove some duplicate, legacy, dead and questionable code. Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_backend_ramdisk.c head/sys/cam/ctl/ctl_frontend_cam_sim.c head/sys/cam/ctl/ctl_ioctl.h head/sys/cam/ctl/ctl_private.h head/sys/cam/ctl/ctl_util.c head/sys/cam/ctl/ctl_util.h head/usr.sbin/ctladm/ctladm.8 head/usr.sbin/ctladm/ctladm.c head/usr.sbin/ctld/kernel.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl.c Sat Sep 26 11:28:45 2015 (r288259) @@ -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, 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, 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, #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? - */ -#ifdef NEEDTOPORT - mtx_lock(&lun->lun_lock); - - 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); + * 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 { - 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 ct 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 @@ 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; } Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_backend_block.c Sat Sep 26 11:28:45 2015 (r288259) @@ -2742,18 +2742,8 @@ ctl_be_block_config_write(union ctl_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 Modified: head/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_ramdisk.c Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_backend_ramdisk.c Sat Sep 26 11:28:45 2015 (r288259) @@ -877,14 +877,8 @@ ctl_backend_ramdisk_config_write(union c 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 Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_cam_sim.c Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_frontend_cam_sim.c Sat Sep 26 11:28:45 2015 (r288259) @@ -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. */ Modified: head/sys/cam/ctl/ctl_ioctl.h ============================================================================== --- head/sys/cam/ctl/ctl_ioctl.h Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_ioctl.h Sat Sep 26 11:28:45 2015 (r288259) @@ -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, @@ -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) Modified: head/sys/cam/ctl/ctl_private.h ============================================================================== --- head/sys/cam/ctl/ctl_private.h Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_private.h Sat Sep 26 11:28:45 2015 (r288259) @@ -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; Modified: head/sys/cam/ctl/ctl_util.c ============================================================================== --- head/sys/cam/ctl/ctl_util.c Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_util.c Sat Sep 26 11:28:45 2015 (r288259) @@ -489,8 +489,7 @@ ctl_scsi_mode_sense(union ctl_io *io, ui 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, in 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 } Modified: head/sys/cam/ctl/ctl_util.h ============================================================================== --- head/sys/cam/ctl/ctl_util.h Sat Sep 26 07:30:45 2015 (r288258) +++ head/sys/cam/ctl/ctl_util.h Sat Sep 26 11:28:45 2015 (r288259) @@ -77,7 +77,7 @@ void ctl_scsi_mode_sense(union ctl_io *i 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, Modified: head/usr.sbin/ctladm/ctladm.8 ============================================================================== --- head/usr.sbin/ctladm/ctladm.8 Sat Sep 26 07:30:45 2015 (r288258) +++ head/usr.sbin/ctladm/ctladm.8 Sat Sep 26 11:28:45 2015 (r288259) @@ -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 w 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. Modified: head/usr.sbin/ctladm/ctladm.c ============================================================================== --- head/usr.sbin/ctladm/ctladm.c Sat Sep 26 07:30:45 2015 (r288258) +++ head/usr.sbin/ctladm/ctladm.c Sat Sep 26 11:28:45 2015 (r288259) @@ -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 a 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 **a { 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 **a 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 @@ retry: 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 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; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509261128.t8QBSkgb017628>