FreeBSD/sys/cam/ctl/ctl.c
/*
 * For HA operation.  Handle commands that come in from the other
 * controller.
 */
For HA operation.  Handle commands that come in from the other
controller.
For HA operation . Handle commands that come in from the other controller .
static void
ctl_handle_isc(union ctl_io *io)
{
	int free_io;
	struct ctl_lun *lun;
	struct ctl_softc *softc = control_softc;
	uint32_t targ_lun;
	targ_lun = io->io_hdr.nexus.targ_mapped_lun;
	lun = softc->ctl_luns[targ_lun];
	switch (io->io_hdr.msg_type) {
	case CTL_MSG_SERIALIZE:
		free_io = ctl_serialize_other_sc_cmd(&io->scsiio);
		break;
	case CTL_MSG_R2R: {
		const struct ctl_cmd_entry *entry;
		free_io = 0;
		entry = ctl_get_cmd_entry(&io->scsiio, NULL);
		mtx_lock(&lun->lun_lock);
		if (ctl_scsiio_lun_check(lun,
		    entry, (struct ctl_scsiio *)io) != 0) {
			mtx_unlock(&lun->lun_lock);
			ctl_done(io);
			break;
		}
		io->io_hdr.flags |= CTL_FLAG_IS_WAS_ON_RTR;
		mtx_unlock(&lun->lun_lock);
		ctl_enqueue_rtr(io);
		break;
	}
	case CTL_MSG_FINISH_IO:
		if (softc->ha_mode == CTL_HA_MODE_XFER) {
			free_io = 0;
			ctl_done(io);
		} else {
			free_io = 1;
			mtx_lock(&lun->lun_lock);
			TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr,
				     ooa_links);
			ctl_check_blocked(lun);
			mtx_unlock(&lun->lun_lock);
		}
		break;
	case CTL_MSG_PERS_ACTION:
		ctl_hndl_per_res_out_on_other_sc(
			(union ctl_ha_msg *)&io->presio.pr_msg);
		free_io = 1;
		break;
	case CTL_MSG_BAD_JUJU:
		free_io = 0;
		ctl_done(io);
		break;
	case CTL_MSG_DATAMOVE:
		free_io = 0;
		ctl_datamove_remote(io);
		break;
	case CTL_MSG_DATAMOVE_DONE:
		free_io = 0;
		io->scsiio.be_move_done(io);
		break;
	case CTL_MSG_FAILOVER:
		ctl_failover_lun(io);
		free_io = 1;
		break;
	default:
		free_io = 1;
		printf("%s: Invalid message type %d\n",
		       __func__, io->io_hdr.msg_type);
		break;
	}
	if (free_io)
		ctl_free_io(io);
}
static void ctl_handle_isc ( union ctl_io * io ) { int free_io ; struct ctl_lun * lun ; struct ctl_softc * softc = control_softc ; uint32_t targ_lun ; targ_lun = io -> io_hdr . nexus . targ_mapped_lun ; lun = softc -> ctl_luns [ targ_lun ] ; switch ( io -> io_hdr . msg_type ) { case CTL_MSG_SERIALIZE : free_io = ctl_serialize_other_sc_cmd ( & io -> scsiio ) ; break ; case CTL_MSG_R2R : { const struct ctl_cmd_entry * entry ; free_io = 0 ; entry = ctl_get_cmd_entry ( & io -> scsiio , NULL ) ; mtx_lock ( & lun -> lun_lock ) ; if ( ctl_scsiio_lun_check ( lun , entry , ( struct ctl_scsiio * ) io ) != 0 ) { mtx_unlock ( & lun -> lun_lock ) ; ctl_done ( io ) ; break ; } io -> io_hdr . flags |= CTL_FLAG_IS_WAS_ON_RTR ; mtx_unlock ( & lun -> lun_lock ) ; ctl_enqueue_rtr ( io ) ; break ; } case CTL_MSG_FINISH_IO : if ( softc -> ha_mode == CTL_HA_MODE_XFER ) { free_io = 0 ; ctl_done ( io ) ; } else { free_io = 1 ; mtx_lock ( & lun -> lun_lock ) ; TAILQ_REMOVE ( & lun -> ooa_queue , & io -> io_hdr , ooa_links ) ; ctl_check_blocked ( lun ) ; mtx_unlock ( & lun -> lun_lock ) ; } break ; case CTL_MSG_PERS_ACTION : ctl_hndl_per_res_out_on_other_sc ( ( union ctl_ha_msg * ) & io -> presio . pr_msg ) ; free_io = 1 ; break ; case CTL_MSG_BAD_JUJU : free_io = 0 ; ctl_done ( io ) ; break ; case CTL_MSG_DATAMOVE : free_io = 0 ; ctl_datamove_remote ( io ) ; break ; case CTL_MSG_DATAMOVE_DONE : free_io = 0 ; io -> scsiio . be_move_done ( io ) ; break ; case CTL_MSG_FAILOVER : ctl_failover_lun ( io ) ; free_io = 1 ; break ; default : free_io = 1 ; printf ( " \n " , __func__ , io -> io_hdr . msg_type ) ; break ; } if ( free_io ) ctl_free_io ( io ) ; }
For HA operation.
For HA operation .
/*
		 * This is only used in SER_ONLY mode.
		 */ /* Only used in XFER mode */ /* Only used in XFER mode */