Deleted Added
full compact
ctl.c (275202) ctl.c (275493)
1/*-
2 * Copyright (c) 2003-2009 Silicon Graphics International Corp.
3 * Copyright (c) 2012 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Edward Tomasz Napierala
7 * under sponsorship from the FreeBSD Foundation.
8 *

--- 28 unchanged lines hidden (view full) ---

37 * CAM Target Layer, a SCSI device emulation subsystem.
38 *
39 * Author: Ken Merry <ken@FreeBSD.org>
40 */
41
42#define _CTL_C
43
44#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003-2009 Silicon Graphics International Corp.
3 * Copyright (c) 2012 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Edward Tomasz Napierala
7 * under sponsorship from the FreeBSD Foundation.
8 *

--- 28 unchanged lines hidden (view full) ---

37 * CAM Target Layer, a SCSI device emulation subsystem.
38 *
39 * Author: Ken Merry <ken@FreeBSD.org>
40 */
41
42#define _CTL_C
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl.c 275202 2014-11-28 08:54:43Z mav $");
45__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl.c 275493 2014-12-05 07:23:25Z mav $");
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/ctype.h>
50#include <sys/kernel.h>
51#include <sys/types.h>
52#include <sys/kthread.h>
53#include <sys/bio.h>

--- 298 unchanged lines hidden (view full) ---

352};
353
354/*
355 * XXX KDM move these into the softc.
356 */
357static int rcv_sync_msg;
358static int persis_offset;
359static uint8_t ctl_pause_rtr;
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/ctype.h>
50#include <sys/kernel.h>
51#include <sys/types.h>
52#include <sys/kthread.h>
53#include <sys/bio.h>

--- 298 unchanged lines hidden (view full) ---

352};
353
354/*
355 * XXX KDM move these into the softc.
356 */
357static int rcv_sync_msg;
358static int persis_offset;
359static uint8_t ctl_pause_rtr;
360static int ctl_is_single = 1;
361
362SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer");
363static int worker_threads = -1;
364TUNABLE_INT("kern.cam.ctl.worker_threads", &worker_threads);
365SYSCTL_INT(_kern_cam_ctl, OID_AUTO, worker_threads, CTLFLAG_RDTUN,
366 &worker_threads, 1, "Number of worker threads");
367static int ctl_debug = CTL_DEBUG_NONE;
368TUNABLE_INT("kern.cam.ctl.debug", &ctl_debug);

--- 598 unchanged lines hidden (view full) ---

967 sense = &dest->scsiio.sense_data;
968 bcopy(&src->scsi.sense_data, sense, sizeof(*sense));
969 dest->scsiio.scsi_status = src->scsi.scsi_status;
970 dest->scsiio.sense_len = src->scsi.sense_len;
971 dest->io_hdr.status = src->hdr.status;
972}
973
974static int
360
361SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer");
362static int worker_threads = -1;
363TUNABLE_INT("kern.cam.ctl.worker_threads", &worker_threads);
364SYSCTL_INT(_kern_cam_ctl, OID_AUTO, worker_threads, CTLFLAG_RDTUN,
365 &worker_threads, 1, "Number of worker threads");
366static int ctl_debug = CTL_DEBUG_NONE;
367TUNABLE_INT("kern.cam.ctl.debug", &ctl_debug);

--- 598 unchanged lines hidden (view full) ---

966 sense = &dest->scsiio.sense_data;
967 bcopy(&src->scsi.sense_data, sense, sizeof(*sense));
968 dest->scsiio.scsi_status = src->scsi.scsi_status;
969 dest->scsiio.sense_len = src->scsi.sense_len;
970 dest->io_hdr.status = src->hdr.status;
971}
972
973static int
974ctl_ha_state_sysctl(SYSCTL_HANDLER_ARGS)
975{
976 struct ctl_softc *softc = (struct ctl_softc *)arg1;
977 struct ctl_lun *lun;
978 int error, value, i;
979
980 if (softc->flags & CTL_FLAG_ACTIVE_SHELF)
981 value = 0;
982 else
983 value = 1;
984
985 error = sysctl_handle_int(oidp, &value, 0, req);
986 if ((error != 0) || (req->newptr == NULL))
987 return (error);
988
989 mtx_lock(&softc->ctl_lock);
990 if (value == 0)
991 softc->flags |= CTL_FLAG_ACTIVE_SHELF;
992 else
993 softc->flags &= ~CTL_FLAG_ACTIVE_SHELF;
994 STAILQ_FOREACH(lun, &softc->lun_list, links) {
995 mtx_lock(&lun->lun_lock);
996 for (i = 0; i < CTL_MAX_INITIATORS; i++)
997 lun->pending_ua[i] |= CTL_UA_ASYM_ACC_CHANGE;
998 mtx_unlock(&lun->lun_lock);
999 }
1000 mtx_unlock(&softc->ctl_lock);
1001 return (0);
1002}
1003
1004static int
975ctl_init(void)
976{
977 struct ctl_softc *softc;
978 struct ctl_io_pool *internal_pool, *emergency_pool, *other_pool;
979 struct ctl_port *port;
1005ctl_init(void)
1006{
1007 struct ctl_softc *softc;
1008 struct ctl_io_pool *internal_pool, *emergency_pool, *other_pool;
1009 struct ctl_port *port;
980 uint8_t sc_id =0;
981 int i, error, retval;
982 //int isc_retval;
983
984 retval = 0;
985 ctl_pause_rtr = 0;
986 rcv_sync_msg = 0;
987
988 control_softc = malloc(sizeof(*control_softc), M_DEVBUF,

--- 41 unchanged lines hidden (view full) ---

1030 * the drive.
1031 */
1032 softc->flags = CTL_FLAG_REAL_SYNC;
1033
1034 /*
1035 * In Copan's HA scheme, the "master" and "slave" roles are
1036 * figured out through the slot the controller is in. Although it
1037 * is an active/active system, someone has to be in charge.
1010 int i, error, retval;
1011 //int isc_retval;
1012
1013 retval = 0;
1014 ctl_pause_rtr = 0;
1015 rcv_sync_msg = 0;
1016
1017 control_softc = malloc(sizeof(*control_softc), M_DEVBUF,

--- 41 unchanged lines hidden (view full) ---

1059 * the drive.
1060 */
1061 softc->flags = CTL_FLAG_REAL_SYNC;
1062
1063 /*
1064 * In Copan's HA scheme, the "master" and "slave" roles are
1065 * figured out through the slot the controller is in. Although it
1066 * is an active/active system, someone has to be in charge.
1038 */
1039#ifdef NEEDTOPORT
1040 scmicro_rw(SCMICRO_GET_SHELF_ID, &sc_id);
1041#endif
1042
1043 if (sc_id == 0) {
1044 softc->flags |= CTL_FLAG_MASTER_SHELF;
1045 persis_offset = 0;
1067 */
1068 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
1069 OID_AUTO, "ha_id", CTLFLAG_RDTUN, &softc->ha_id, 0,
1070 "HA head ID (0 - no HA)");
1071 if (softc->ha_id == 0) {
1072 softc->flags |= CTL_FLAG_ACTIVE_SHELF;
1073 softc->is_single = 1;
1074 softc->port_offset = 0;
1046 } else
1075 } else
1047 persis_offset = CTL_MAX_INITIATORS;
1076 softc->port_offset = (softc->ha_id - 1) * CTL_MAX_PORTS;
1077 persis_offset = softc->port_offset * CTL_MAX_INIT_PER_PORT;
1048
1049 /*
1050 * XXX KDM need to figure out where we want to get our target ID
1051 * and WWID. Is it different on each port?
1052 */
1053 softc->target.id = 0;
1054 softc->target.wwid[0] = 0x12345678;
1055 softc->target.wwid[1] = 0x87654321;

--- 96 unchanged lines hidden (view full) ---

1152 port->lun_enable = ctl_ioctl_lun_enable;
1153 port->lun_disable = ctl_ioctl_lun_disable;
1154 port->targ_lun_arg = &softc->ioctl_info;
1155 port->fe_datamove = ctl_ioctl_datamove;
1156 port->fe_done = ctl_ioctl_done;
1157 port->max_targets = 15;
1158 port->max_target_id = 15;
1159
1078
1079 /*
1080 * XXX KDM need to figure out where we want to get our target ID
1081 * and WWID. Is it different on each port?
1082 */
1083 softc->target.id = 0;
1084 softc->target.wwid[0] = 0x12345678;
1085 softc->target.wwid[1] = 0x87654321;

--- 96 unchanged lines hidden (view full) ---

1182 port->lun_enable = ctl_ioctl_lun_enable;
1183 port->lun_disable = ctl_ioctl_lun_disable;
1184 port->targ_lun_arg = &softc->ioctl_info;
1185 port->fe_datamove = ctl_ioctl_datamove;
1186 port->fe_done = ctl_ioctl_done;
1187 port->max_targets = 15;
1188 port->max_target_id = 15;
1189
1160 if (ctl_port_register(&softc->ioctl_info.port,
1161 (softc->flags & CTL_FLAG_MASTER_SHELF)) != 0) {
1190 if (ctl_port_register(&softc->ioctl_info.port) != 0) {
1162 printf("ctl: ioctl front end registration failed, will "
1163 "continue anyway\n");
1164 }
1165
1191 printf("ctl: ioctl front end registration failed, will "
1192 "continue anyway\n");
1193 }
1194
1195 SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree),
1196 OID_AUTO, "ha_state", CTLTYPE_INT | CTLFLAG_RWTUN,
1197 softc, 0, ctl_ha_state_sysctl, "I", "HA state for this head");
1198
1166#ifdef CTL_IO_DELAY
1167 if (sizeof(struct callout) > CTL_TIMER_BYTES) {
1168 printf("sizeof(struct callout) %zd > CTL_TIMER_BYTES %zd\n",
1169 sizeof(struct callout), CTL_TIMER_BYTES);
1170 return (EINVAL);
1171 }
1172#endif /* CTL_IO_DELAY */
1173

--- 85 unchanged lines hidden (view full) ---

1259ctl_close(struct cdev *dev, int flags, int fmt, struct thread *td)
1260{
1261 return (0);
1262}
1263
1264int
1265ctl_port_enable(ctl_port_type port_type)
1266{
1199#ifdef CTL_IO_DELAY
1200 if (sizeof(struct callout) > CTL_TIMER_BYTES) {
1201 printf("sizeof(struct callout) %zd > CTL_TIMER_BYTES %zd\n",
1202 sizeof(struct callout), CTL_TIMER_BYTES);
1203 return (EINVAL);
1204 }
1205#endif /* CTL_IO_DELAY */
1206

--- 85 unchanged lines hidden (view full) ---

1292ctl_close(struct cdev *dev, int flags, int fmt, struct thread *td)
1293{
1294 return (0);
1295}
1296
1297int
1298ctl_port_enable(ctl_port_type port_type)
1299{
1267 struct ctl_softc *softc;
1300 struct ctl_softc *softc = control_softc;
1268 struct ctl_port *port;
1269
1301 struct ctl_port *port;
1302
1270 if (ctl_is_single == 0) {
1303 if (softc->is_single == 0) {
1271 union ctl_ha_msg msg_info;
1272 int isc_retval;
1273
1274#if 0
1275 printf("%s: HA mode, synchronizing frontend enable\n",
1276 __func__);
1277#endif
1278 msg_info.hdr.msg_type = CTL_MSG_SYNC_FE;

--- 8 unchanged lines hidden (view full) ---

1287#if 0
1288 printf("CTL:Frontend Enable\n");
1289 } else {
1290 printf("%s: single mode, skipping frontend synchronization\n",
1291 __func__);
1292#endif
1293 }
1294
1304 union ctl_ha_msg msg_info;
1305 int isc_retval;
1306
1307#if 0
1308 printf("%s: HA mode, synchronizing frontend enable\n",
1309 __func__);
1310#endif
1311 msg_info.hdr.msg_type = CTL_MSG_SYNC_FE;

--- 8 unchanged lines hidden (view full) ---

1320#if 0
1321 printf("CTL:Frontend Enable\n");
1322 } else {
1323 printf("%s: single mode, skipping frontend synchronization\n",
1324 __func__);
1325#endif
1326 }
1327
1295 softc = control_softc;
1296
1297 STAILQ_FOREACH(port, &softc->port_list, links) {
1298 if (port_type & port->port_type)
1299 {
1300#if 0
1301 printf("port %d\n", port->targ_port);
1302#endif
1303 ctl_port_online(port);
1304 }

--- 6129 unchanged lines hidden (view full) ---

7434 return (CTL_RETVAL_COMPLETE);
7435}
7436
7437int
7438ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio)
7439{
7440 struct scsi_maintenance_in *cdb;
7441 int retval;
1328 STAILQ_FOREACH(port, &softc->port_list, links) {
1329 if (port_type & port->port_type)
1330 {
1331#if 0
1332 printf("port %d\n", port->targ_port);
1333#endif
1334 ctl_port_online(port);
1335 }

--- 6129 unchanged lines hidden (view full) ---

7465 return (CTL_RETVAL_COMPLETE);
7466}
7467
7468int
7469ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio)
7470{
7471 struct scsi_maintenance_in *cdb;
7472 int retval;
7442 int alloc_len, ext, total_len = 0, g, p, pc, pg;
7443 int num_target_port_groups, num_target_ports, single;
7473 int alloc_len, ext, total_len = 0, g, p, pc, pg, gs, os;
7474 int num_target_port_groups, num_target_ports;
7444 struct ctl_lun *lun;
7445 struct ctl_softc *softc;
7446 struct ctl_port *port;
7447 struct scsi_target_group_data *rtg_ptr;
7448 struct scsi_target_group_data_extended *rtg_ext_ptr;
7449 struct scsi_target_port_group_descriptor *tpg_desc;
7450
7451 CTL_DEBUG_PRINT(("ctl_report_tagret_port_groups\n"));

--- 17 unchanged lines hidden (view full) ---

7469 /*command*/ 1,
7470 /*field*/ 2,
7471 /*bit_valid*/ 1,
7472 /*bit*/ 5);
7473 ctl_done((union ctl_io *)ctsio);
7474 return(retval);
7475 }
7476
7475 struct ctl_lun *lun;
7476 struct ctl_softc *softc;
7477 struct ctl_port *port;
7478 struct scsi_target_group_data *rtg_ptr;
7479 struct scsi_target_group_data_extended *rtg_ext_ptr;
7480 struct scsi_target_port_group_descriptor *tpg_desc;
7481
7482 CTL_DEBUG_PRINT(("ctl_report_tagret_port_groups\n"));

--- 17 unchanged lines hidden (view full) ---

7500 /*command*/ 1,
7501 /*field*/ 2,
7502 /*bit_valid*/ 1,
7503 /*bit*/ 5);
7504 ctl_done((union ctl_io *)ctsio);
7505 return(retval);
7506 }
7507
7477 single = ctl_is_single;
7478 if (single)
7508 if (softc->is_single)
7479 num_target_port_groups = 1;
7480 else
7481 num_target_port_groups = NUM_TARGET_PORT_GROUPS;
7482 num_target_ports = 0;
7483 mtx_lock(&softc->ctl_lock);
7484 STAILQ_FOREACH(port, &softc->port_list, links) {
7485 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
7486 continue;

--- 39 unchanged lines hidden (view full) ---

7526 tpg_desc = &rtg_ext_ptr->groups[0];
7527 } else {
7528 rtg_ptr = (struct scsi_target_group_data *)
7529 ctsio->kern_data_ptr;
7530 scsi_ulto4b(total_len - 4, rtg_ptr->length);
7531 tpg_desc = &rtg_ptr->groups[0];
7532 }
7533
7509 num_target_port_groups = 1;
7510 else
7511 num_target_port_groups = NUM_TARGET_PORT_GROUPS;
7512 num_target_ports = 0;
7513 mtx_lock(&softc->ctl_lock);
7514 STAILQ_FOREACH(port, &softc->port_list, links) {
7515 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
7516 continue;

--- 39 unchanged lines hidden (view full) ---

7556 tpg_desc = &rtg_ext_ptr->groups[0];
7557 } else {
7558 rtg_ptr = (struct scsi_target_group_data *)
7559 ctsio->kern_data_ptr;
7560 scsi_ulto4b(total_len - 4, rtg_ptr->length);
7561 tpg_desc = &rtg_ptr->groups[0];
7562 }
7563
7534 pg = ctsio->io_hdr.nexus.targ_port / CTL_MAX_PORTS;
7535 mtx_lock(&softc->ctl_lock);
7564 mtx_lock(&softc->ctl_lock);
7565 pg = softc->port_offset / CTL_MAX_PORTS;
7566 if (softc->flags & CTL_FLAG_ACTIVE_SHELF) {
7567 if (softc->ha_mode == CTL_HA_MODE_ACT_STBY) {
7568 gs = TPG_ASYMMETRIC_ACCESS_OPTIMIZED;
7569 os = TPG_ASYMMETRIC_ACCESS_STANDBY;
7570 } else if (lun->flags & CTL_LUN_PRIMARY_SC) {
7571 gs = TPG_ASYMMETRIC_ACCESS_OPTIMIZED;
7572 os = TPG_ASYMMETRIC_ACCESS_NONOPTIMIZED;
7573 } else {
7574 gs = TPG_ASYMMETRIC_ACCESS_NONOPTIMIZED;
7575 os = TPG_ASYMMETRIC_ACCESS_OPTIMIZED;
7576 }
7577 } else {
7578 gs = TPG_ASYMMETRIC_ACCESS_STANDBY;
7579 os = TPG_ASYMMETRIC_ACCESS_OPTIMIZED;
7580 }
7536 for (g = 0; g < num_target_port_groups; g++) {
7581 for (g = 0; g < num_target_port_groups; g++) {
7537 if (g == pg)
7538 tpg_desc->pref_state = TPG_PRIMARY |
7539 TPG_ASYMMETRIC_ACCESS_OPTIMIZED;
7540 else
7541 tpg_desc->pref_state =
7542 TPG_ASYMMETRIC_ACCESS_NONOPTIMIZED;
7543 tpg_desc->support = TPG_AO_SUP;
7544 if (!single)
7545 tpg_desc->support |= TPG_AN_SUP;
7582 tpg_desc->pref_state = (g == pg) ? gs : os;
7583 tpg_desc->support = TPG_AO_SUP | TPG_AN_SUP | TPG_S_SUP;
7546 scsi_ulto2b(g + 1, tpg_desc->target_port_group);
7547 tpg_desc->status = TPG_IMPLICIT;
7548 pc = 0;
7549 STAILQ_FOREACH(port, &softc->port_list, links) {
7550 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
7551 continue;
7552 if (ctl_map_lun_back(port->targ_port, lun->lun) >=
7553 CTL_MAX_LUNS)

--- 2622 unchanged lines hidden (view full) ---

10176{
10177 struct ctl_softc *softc = control_softc;
10178 struct scsi_vpd_scsi_ports *sp;
10179 struct scsi_vpd_port_designation *pd;
10180 struct scsi_vpd_port_designation_cont *pdc;
10181 struct ctl_lun *lun;
10182 struct ctl_port *port;
10183 int data_len, num_target_ports, iid_len, id_len, g, pg, p;
7584 scsi_ulto2b(g + 1, tpg_desc->target_port_group);
7585 tpg_desc->status = TPG_IMPLICIT;
7586 pc = 0;
7587 STAILQ_FOREACH(port, &softc->port_list, links) {
7588 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
7589 continue;
7590 if (ctl_map_lun_back(port->targ_port, lun->lun) >=
7591 CTL_MAX_LUNS)

--- 2622 unchanged lines hidden (view full) ---

10214{
10215 struct ctl_softc *softc = control_softc;
10216 struct scsi_vpd_scsi_ports *sp;
10217 struct scsi_vpd_port_designation *pd;
10218 struct scsi_vpd_port_designation_cont *pdc;
10219 struct ctl_lun *lun;
10220 struct ctl_port *port;
10221 int data_len, num_target_ports, iid_len, id_len, g, pg, p;
10184 int num_target_port_groups, single;
10222 int num_target_port_groups;
10185
10186 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
10187
10223
10224 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
10225
10188 single = ctl_is_single;
10189 if (single)
10226 if (softc->is_single)
10190 num_target_port_groups = 1;
10191 else
10192 num_target_port_groups = NUM_TARGET_PORT_GROUPS;
10193 num_target_ports = 0;
10194 iid_len = 0;
10195 id_len = 0;
10196 mtx_lock(&softc->ctl_lock);
10197 STAILQ_FOREACH(port, &softc->port_list, links) {

--- 43 unchanged lines hidden (view full) ---

10241 sp->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT;
10242
10243 sp->page_code = SVPD_SCSI_PORTS;
10244 scsi_ulto2b(data_len - sizeof(struct scsi_vpd_scsi_ports),
10245 sp->page_length);
10246 pd = &sp->design[0];
10247
10248 mtx_lock(&softc->ctl_lock);
10227 num_target_port_groups = 1;
10228 else
10229 num_target_port_groups = NUM_TARGET_PORT_GROUPS;
10230 num_target_ports = 0;
10231 iid_len = 0;
10232 id_len = 0;
10233 mtx_lock(&softc->ctl_lock);
10234 STAILQ_FOREACH(port, &softc->port_list, links) {

--- 43 unchanged lines hidden (view full) ---

10278 sp->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT;
10279
10280 sp->page_code = SVPD_SCSI_PORTS;
10281 scsi_ulto2b(data_len - sizeof(struct scsi_vpd_scsi_ports),
10282 sp->page_length);
10283 pd = &sp->design[0];
10284
10285 mtx_lock(&softc->ctl_lock);
10249 if (softc->flags & CTL_FLAG_MASTER_SHELF)
10250 pg = 0;
10251 else
10252 pg = 1;
10286 pg = softc->port_offset / CTL_MAX_PORTS;
10253 for (g = 0; g < num_target_port_groups; g++) {
10254 STAILQ_FOREACH(port, &softc->port_list, links) {
10255 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
10256 continue;
10257 if (lun != NULL &&
10258 ctl_map_lun_back(port->targ_port, lun->lun) >=
10259 CTL_MAX_LUNS)
10260 continue;

--- 1063 unchanged lines hidden (view full) ---

11324 retval = 0;
11325
11326 mtx_assert(&lun->lun_lock, MA_OWNED);
11327
11328 /*
11329 * If this shelf is a secondary shelf controller, we have to reject
11330 * any media access commands.
11331 */
10287 for (g = 0; g < num_target_port_groups; g++) {
10288 STAILQ_FOREACH(port, &softc->port_list, links) {
10289 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
10290 continue;
10291 if (lun != NULL &&
10292 ctl_map_lun_back(port->targ_port, lun->lun) >=
10293 CTL_MAX_LUNS)
10294 continue;

--- 1063 unchanged lines hidden (view full) ---

11358 retval = 0;
11359
11360 mtx_assert(&lun->lun_lock, MA_OWNED);
11361
11362 /*
11363 * If this shelf is a secondary shelf controller, we have to reject
11364 * any media access commands.
11365 */
11332#if 0
11333 /* No longer needed for HA */
11334 if (((ctl_softc->flags & CTL_FLAG_MASTER_SHELF) == 0)
11335 && ((entry->flags & CTL_CMD_FLAG_OK_ON_SECONDARY) == 0)) {
11366 if ((ctl_softc->flags & CTL_FLAG_ACTIVE_SHELF) == 0 &&
11367 (entry->flags & CTL_CMD_FLAG_OK_ON_SECONDARY) == 0) {
11336 ctl_set_lun_standby(ctsio);
11337 retval = 1;
11338 goto bailout;
11339 }
11368 ctl_set_lun_standby(ctsio);
11369 retval = 1;
11370 goto bailout;
11371 }
11340#endif
11341
11342 if (entry->pattern & CTL_LUN_PAT_WRITE) {
11343 if (lun->flags & CTL_LUN_READONLY) {
11344 ctl_set_sense(ctsio, /*current_error*/ 1,
11345 /*sense_key*/ SSD_KEY_DATA_PROTECT,
11346 /*asc*/ 0x27, /*ascq*/ 0x01, SSD_ELEM_NONE);
11347 retval = 1;
11348 goto bailout;

--- 3038 unchanged lines hidden (view full) ---

14387ctl_isc_start(struct ctl_ha_component *c, ctl_ha_state state)
14388{
14389 ctl_ha_comp_status ret = CTL_HA_COMP_STATUS_OK;
14390
14391 printf("%s: go\n", __func__);
14392
14393 // UNKNOWN->HA or UNKNOWN->SINGLE (bootstrap)
14394 if (c->state == CTL_HA_STATE_UNKNOWN ) {
11372
11373 if (entry->pattern & CTL_LUN_PAT_WRITE) {
11374 if (lun->flags & CTL_LUN_READONLY) {
11375 ctl_set_sense(ctsio, /*current_error*/ 1,
11376 /*sense_key*/ SSD_KEY_DATA_PROTECT,
11377 /*asc*/ 0x27, /*ascq*/ 0x01, SSD_ELEM_NONE);
11378 retval = 1;
11379 goto bailout;

--- 3038 unchanged lines hidden (view full) ---

14418ctl_isc_start(struct ctl_ha_component *c, ctl_ha_state state)
14419{
14420 ctl_ha_comp_status ret = CTL_HA_COMP_STATUS_OK;
14421
14422 printf("%s: go\n", __func__);
14423
14424 // UNKNOWN->HA or UNKNOWN->SINGLE (bootstrap)
14425 if (c->state == CTL_HA_STATE_UNKNOWN ) {
14395 ctl_is_single = 0;
14426 control_softc->is_single = 0;
14396 if (ctl_ha_msg_create(CTL_HA_CHAN_CTL, ctl_isc_event_handler)
14397 != CTL_HA_STATUS_SUCCESS) {
14398 printf("ctl_isc_start: ctl_ha_msg_create failed.\n");
14399 ret = CTL_HA_COMP_STATUS_ERROR;
14400 }
14401 } else if (CTL_HA_STATE_IS_HA(c->state)
14402 && CTL_HA_STATE_IS_SINGLE(state)){
14403 // HA->SINGLE transition
14404 ctl_failover();
14427 if (ctl_ha_msg_create(CTL_HA_CHAN_CTL, ctl_isc_event_handler)
14428 != CTL_HA_STATUS_SUCCESS) {
14429 printf("ctl_isc_start: ctl_ha_msg_create failed.\n");
14430 ret = CTL_HA_COMP_STATUS_ERROR;
14431 }
14432 } else if (CTL_HA_STATE_IS_HA(c->state)
14433 && CTL_HA_STATE_IS_SINGLE(state)){
14434 // HA->SINGLE transition
14435 ctl_failover();
14405 ctl_is_single = 1;
14436 control_softc->is_single = 1;
14406 } else {
14407 printf("ctl_isc_start:Invalid state transition %X->%X\n",
14408 c->state, state);
14409 ret = CTL_HA_COMP_STATUS_ERROR;
14410 }
14411 if (CTL_HA_STATE_IS_SINGLE(state))
14437 } else {
14438 printf("ctl_isc_start:Invalid state transition %X->%X\n",
14439 c->state, state);
14440 ret = CTL_HA_COMP_STATUS_ERROR;
14441 }
14442 if (CTL_HA_STATE_IS_SINGLE(state))
14412 ctl_is_single = 1;
14443 control_softc->is_single = 1;
14413
14414 c->state = state;
14415 c->status = ret;
14416 return ret;
14417}
14418
14419/*
14420 * Quiesce component

--- 28 unchanged lines hidden ---
14444
14445 c->state = state;
14446 c->status = ret;
14447 return ret;
14448}
14449
14450/*
14451 * Quiesce component

--- 28 unchanged lines hidden ---