Documentation ¶
Overview ¶
iSCSI Target Driver
iSCSI task management
Index ¶
- Constants
- Variables
- func GeniSCSIITNexusID(sess *ISCSISession) string
- func MakeSSID(ISID uint64, TPGT uint16) uint64
- func NewISCSITargetDriver(base *scsi.SCSITargetService) (scsi.SCSITargetDriver, error)
- func ParseSSID(SSID uint64) (uint64, uint16)
- func ParseUint(data []byte) uint64
- type AuthMethod
- type ISCSICommand
- type ISCSIDiscoveryMethod
- type ISCSIRedirectInfo
- type ISCSISession
- type ISCSISessionParam
- type ISCSISessionParamList
- type ISCSITarget
- func (tgt *ISCSITarget) CommandNotify(nid uint64, result int, cmd *api.SCSICommand) error
- func (tgt *ISCSITarget) CreateLu(lu *api.SCSILu) error
- func (tgt *ISCSITarget) CreatePortal(name string) error
- func (tgt *ISCSITarget) CreateTarget(target *api.SCSITarget) error
- func (tgt *ISCSITarget) DestroyPortal(name string) error
- func (tgt *ISCSITarget) DestroyTarget(target *api.SCSITarget) error
- func (tgt *ISCSITarget) Exit() error
- func (tgt *ISCSITarget) FindTPG(portal string) (uint16, error)
- func (tgt *ISCSITarget) GetLu(lun uint8) (uint64, error)
- func (tgt *ISCSITarget) Init() error
- type ISCSITargetDriver
- func (s *ISCSITargetDriver) AddiSCSIPortal(tgtName string, tpgt uint16, portal string) error
- func (s *ISCSITargetDriver) AllocTSIH() uint16
- func (s *ISCSITargetDriver) BindISCSISession(conn *iscsiConnection) error
- func (s *ISCSITargetDriver) Close() error
- func (s *ISCSITargetDriver) EnableBlockMultipleHostLogin()
- func (s *ISCSITargetDriver) HasPortal(tgtName string, tpgt uint16, portal string) bool
- func (s *ISCSITargetDriver) LookupISCSISession(tgtName string, iniName string, isid uint64, tsih uint16, tpgt uint16) *ISCSISession
- func (s *ISCSITargetDriver) NewISCSISession(conn *iscsiConnection) (*ISCSISession, error)
- func (s *ISCSITargetDriver) NewTarget(tgtName string, configInfo *config.Config) error
- func (s *ISCSITargetDriver) ReInstatement(existSess *ISCSISession, conn *iscsiConnection) (*ISCSISession, error)
- func (s *ISCSITargetDriver) ReleaseTSIH(tsih uint16)
- func (s *ISCSITargetDriver) RereadTargetLUNMap()
- func (s *ISCSITargetDriver) Resize(size uint64) error
- func (s *ISCSITargetDriver) Run(port int) error
- func (s *ISCSITargetDriver) SetClusterIP(ip string)
- func (s *ISCSITargetDriver) Stats() scsi.Stats
- func (s *ISCSITargetDriver) UnBindISCSISession(sess *ISCSISession)
- func (s *ISCSITargetDriver) UpdateStats(conn *iscsiConnection)
- type ISCSITaskManagementFunc
- type KeyConvFunc
- type KeyInConvFunc
- type OpCode
Constants ¶
const ( AuthNone = iota AuthChap )
const ( // Defined on the initiator. OpNoopOut OpCode = 0x00 OpSCSICmd = 0x01 OpSCSITaskReq = 0x02 OpLoginReq = 0x03 OpTextReq = 0x04 OpSCSIOut = 0x05 OpLogoutReq = 0x06 OpSNACKReq = 0x10 // Defined on the target. OpNoopIn OpCode = 0x20 OpSCSIResp = 0x21 OpSCSITaskResp = 0x22 OpLoginResp = 0x23 OpTextResp = 0x24 OpSCSIIn = 0x25 OpLogoutResp = 0x26 OpReady = 0x31 OpAsync = 0x32 OpReject = 0x3f )
const ( MaxBurstLength uint32 = 262144 MaxRecvDataSegmentLength uint32 = 65536 )
const ( CONN_STATE_FREE = 0 CONN_STATE_SECURITY = 1 CONN_STATE_SECURITY_AUTH = 2 CONN_STATE_SECURITY_DONE = 3 CONN_STATE_SECURITY_LOGIN = 4 CONN_STATE_SECURITY_FULL = 5 CONN_STATE_LOGIN = 6 CONN_STATE_LOGIN_FULL = 7 CONN_STATE_FULL = 8 CONN_STATE_KERNEL = 9 CONN_STATE_CLOSE = 10 CONN_STATE_EXIT = 11 CONN_STATE_SCSI = 12 CONN_STATE_INIT = 13 CONN_STATE_START = 14 CONN_STATE_READY = 15 )
const ( ISCSI_MAX_TSIH = uint16(0xffff) ISCSI_UNSPEC_TSIH = uint16(0) )
const ( STATE_INIT = iota STATE_RUNNING STATE_SHUTTING_DOWN STATE_TERMINATE )
const ( IOSTATE_FREE = iota IOSTATE_RX_BHS IOSTATE_RX_INIT_AHS IOSTATE_RX_AHS IOSTATE_RX_INIT_HDIGEST IOSTATE_RX_HDIGEST IOSTATE_RX_CHECK_HDIGEST IOSTATE_RX_INIT_DATA IOSTATE_RX_DATA IOSTATE_RX_INIT_DDIGEST IOSTATE_RX_DDIGEST IOSTATE_RX_CHECK_DDIGEST IOSTATE_RX_END IOSTATE_TX_BHS IOSTATE_TX_INIT_AHS IOSTATE_TX_AHS IOSTATE_TX_INIT_HDIGEST IOSTATE_TX_HDIGEST IOSTATE_TX_INIT_DATA IOSTATE_TX_DATA IOSTATE_TX_INIT_DDIGEST IOSTATE_TX_DDIGEST IOSTATE_TX_END )
const ( SecurityNegotiation iSCSILoginStage = 0 LoginOperationalNegotiation = 1 FullFeaturePhase = 3 )
const ( MAX_QUEUE_CMD_MIN = 1 MAX_QUEUE_CMD_DEF = 128 MAX_QUEUE_CMD_MAX = 512 )
const ( ISCSI_PARAM_MAX_RECV_DLENGTH = iota ISCSI_PARAM_HDRDGST_EN ISCSI_PARAM_DATADGST_EN ISCSI_PARAM_INITIAL_R2T_EN ISCSI_PARAM_MAX_R2T ISCSI_PARAM_IMM_DATA_EN ISCSI_PARAM_FIRST_BURST ISCSI_PARAM_MAX_BURST ISCSI_PARAM_PDU_INORDER_EN ISCSI_PARAM_DATASEQ_INORDER_EN ISCSI_PARAM_ERL ISCSI_PARAM_IFMARKER_EN ISCSI_PARAM_OFMARKER_EN ISCSI_PARAM_DEFAULTTIME2WAIT ISCSI_PARAM_DEFAULTTIME2RETAIN ISCSI_PARAM_OFMARKINT ISCSI_PARAM_IFMARKINT ISCSI_PARAM_MAXCONNECTIONS /* iSCSI Extensions for RDMA (RFC5046) */ ISCSI_PARAM_RDMA_EXTENSIONS ISCSI_PARAM_TARGET_RDSL ISCSI_PARAM_INITIATOR_RDSL ISCSI_PARAM_MAX_OUTST_PDU /* "local" parmas, never sent to the initiator */ ISCSI_PARAM_FIRST_LOCAL ISCSI_PARAM_MAX_XMIT_DLENGTH = ISCSI_PARAM_FIRST_LOCAL ISCSI_PARAM_MAX_QUEUE_CMD /* must always be last */ ISCSI_PARAM_MAX )
const ( ISCSI_FLAG_TM_FUNC_MASK byte = 0x7F // Function values // aborts the task identified by the Referenced Task Tag field ISCSI_TM_FUNC_ABORT_TASK = 1 // aborts all Tasks issued via this session on the logical unit ISCSI_TM_FUNC_ABORT_TASK_SET = 2 // clears the Auto Contingent Allegiance condition ISCSI_TM_FUNC_CLEAR_ACA = 3 // aborts all Tasks in the appropriate task set as defined by the TST field in the Control mode page ISCSI_TM_FUNC_CLEAR_TASK_SET = 4 ISCSI_TM_FUNC_LOGICAL_UNIT_RESET = 5 ISCSI_TM_FUNC_TARGET_WARM_RESET = 6 ISCSI_TM_FUNC_TARGET_COLD_RESET = 7 // reassigns connection allegiance for the task identified by the Referenced Task Tag field to this connection, thus resuming the iSCSI exchanges for the task ISCSI_TM_FUNC_TASK_REASSIGN = 8 // Response values // Function complete ISCSI_TMF_RSP_COMPLETE = 0x00 // Task does not exist ISCSI_TMF_RSP_NO_TASK = 0x01 // LUN does not exist ISCSI_TMF_RSP_NO_LUN = 0x02 // Task still allegiant ISCSI_TMF_RSP_TASK_ALLEGIANT = 0x03 // Task allegiance reassignment not supported ISCSI_TMF_RSP_NO_FAILOVER = 0x04 // Task management function not supported ISCSI_TMF_RSP_NOT_SUPPORTED = 0x05 // Function authorization failed ISCSI_TMF_RSP_AUTH_FAILED = 0x06 // Function rejected ISCSI_TMF_RSP_REJECTED = 0xff )
const DataPadding = 4
Variables ¶
var ( DATAIN byte = 0x01 DATAOUT byte = 0x10 )
var ( EnableStats bool CurrentHostIP string IPMutex sync.Mutex )
var ( SESSION_NORMAL int = 0 SESSION_DISCOVERY int = 1 )
var BHS_SIZE = 48
var DIGEST_ALL uint = DIGEST_NONE | DIGEST_CRC32C
var DIGEST_CRC32C uint = 1 << 1
var DIGEST_NONE uint = 1 << 0
var ISCSI_OPCODE_MASK byte = 0x3F
Functions ¶
func GeniSCSIITNexusID ¶
func GeniSCSIITNexusID(sess *ISCSISession) string
* iSCSI I_T nexus identifer = (iSCSI Initiator Name + 'i' + ISID, iSCSI Target Name + 't' + Portal Group Tag)
func MakeSSID ¶
* RFC 3720 iSCSI SSID = ISID , TPGT * ISID is an 6 bytes number, TPGT is an 2 bytes number * We combine ISID and TPGT together to be SSID
func NewISCSITargetDriver ¶
func NewISCSITargetDriver(base *scsi.SCSITargetService) (scsi.SCSITargetDriver, error)
Types ¶
type AuthMethod ¶
type AuthMethod int
type ISCSICommand ¶
type ISCSICommand struct { OpCode OpCode RawHeader []byte DataLen int RawData []byte Final bool FinalInSeq bool Immediate bool TaskTag uint32 StartTime time.Time ExpCmdSN, MaxCmdSN uint32 AHSLen int Resid uint32 // Connection ID. ConnID uint16 // Command serial number. CmdSN uint32 // Expected status serial. ExpStatSN uint32 Read, Write bool LUN [8]uint8 // Transit bit. Transit bool // Continue bit. Cont bool // Current Stage, Next Stage. CSG, NSG iSCSILoginStage // Initiator part of the SSID. ISID uint64 // Target-assigned Session Identifying Handle. TSIH uint16 // Status serial number. StatSN uint32 // For login response. StatusClass uint8 StatusDetail uint8 // SCSI commands SCSIOpCode byte ExpectedDataLen uint32 CDB []byte Status byte SCSIResponse byte // Task request ISCSITaskManagementFunc // R2T R2TSN uint32 DesiredLength uint32 // Data-In/Out HasStatus bool DataSN uint32 BufferOffset uint32 }
func (*ISCSICommand) Bytes ¶
func (cmd *ISCSICommand) Bytes() []byte
func (*ISCSICommand) String ¶
func (m *ISCSICommand) String() string
type ISCSIDiscoveryMethod ¶
type ISCSIDiscoveryMethod string
var ( ISCSIDiscoverySendTargets ISCSIDiscoveryMethod = "sendtargets" ISCSIDiscoveryStaticConfig ISCSIDiscoveryMethod = "static" ISCSIDiscoveryISNS ISCSIDiscoveryMethod = "isns" )
type ISCSIRedirectInfo ¶
type ISCSISession ¶
type ISCSISession struct { Refcount int Initiator string InitiatorAlias string Target *ISCSITarget ISID uint64 TSIH uint16 TPGT uint16 SessionType int ITNexus *api.ITNexus ExpCmdSN uint32 MaxCmdSN uint32 // currently, this is only one connection per session Connections map[uint16]*iscsiConnection ConnectionsRWMutex sync.RWMutex Commands []*ISCSICommand PendingTasks taskQueue PendingTasksMutex sync.RWMutex MaxQueueCommand uint32 SessionParam ISCSISessionParamList Info string Rdma int }
Session is an iSCSI session.
func (*ISCSISession) LookupConnection ¶
func (sess *ISCSISession) LookupConnection(cid uint16) *iscsiConnection
type ISCSISessionParam ¶
type ISCSISessionParamList ¶
type ISCSISessionParamList []ISCSISessionParam
func (ISCSISessionParamList) Len ¶
func (list ISCSISessionParamList) Len() int
func (ISCSISessionParamList) Less ¶
func (list ISCSISessionParamList) Less(i, j int) bool
func (ISCSISessionParamList) Swap ¶
func (list ISCSISessionParamList) Swap(i, j int)
type ISCSITarget ¶
type ISCSITarget struct { api.SCSITarget api.SCSITargetDriverCommon // TPGT number is the key TPGTs map[uint16]*iSCSITPGT // TSIH is the key Sessions map[uint16]*ISCSISession SessionsRWMutex sync.RWMutex Alias string MaxSessions int RedirectInfo ISCSIRedirectInfo Rdma int NopInterval int NopCount int }
func (*ISCSITarget) CommandNotify ¶
func (tgt *ISCSITarget) CommandNotify(nid uint64, result int, cmd *api.SCSICommand) error
func (*ISCSITarget) CreatePortal ¶
func (tgt *ISCSITarget) CreatePortal(name string) error
func (*ISCSITarget) CreateTarget ¶
func (tgt *ISCSITarget) CreateTarget(target *api.SCSITarget) error
func (*ISCSITarget) DestroyPortal ¶
func (tgt *ISCSITarget) DestroyPortal(name string) error
func (*ISCSITarget) DestroyTarget ¶
func (tgt *ISCSITarget) DestroyTarget(target *api.SCSITarget) error
func (*ISCSITarget) Exit ¶
func (tgt *ISCSITarget) Exit() error
func (*ISCSITarget) Init ¶
func (tgt *ISCSITarget) Init() error
type ISCSITargetDriver ¶
type ISCSITargetDriver struct { SCSI *scsi.SCSITargetService Name string TSIHPool map[uint16]bool TSIHPoolMutex sync.Mutex OpCode int TargetStats scsi.Stats // contains filtered or unexported fields }
func (*ISCSITargetDriver) AddiSCSIPortal ¶
func (s *ISCSITargetDriver) AddiSCSIPortal(tgtName string, tpgt uint16, portal string) error
func (*ISCSITargetDriver) AllocTSIH ¶
func (s *ISCSITargetDriver) AllocTSIH() uint16
func (*ISCSITargetDriver) BindISCSISession ¶
func (s *ISCSITargetDriver) BindISCSISession(conn *iscsiConnection) error
func (*ISCSITargetDriver) Close ¶
func (s *ISCSITargetDriver) Close() error
func (*ISCSITargetDriver) EnableBlockMultipleHostLogin ¶ added in v0.2.1
func (s *ISCSITargetDriver) EnableBlockMultipleHostLogin()
func (*ISCSITargetDriver) HasPortal ¶
func (s *ISCSITargetDriver) HasPortal(tgtName string, tpgt uint16, portal string) bool
func (*ISCSITargetDriver) LookupISCSISession ¶
func (s *ISCSITargetDriver) LookupISCSISession(tgtName string, iniName string, isid uint64, tsih uint16, tpgt uint16) *ISCSISession
func (*ISCSITargetDriver) NewISCSISession ¶
func (s *ISCSITargetDriver) NewISCSISession(conn *iscsiConnection) (*ISCSISession, error)
New creates a new session.
func (*ISCSITargetDriver) NewTarget ¶
func (s *ISCSITargetDriver) NewTarget(tgtName string, configInfo *config.Config) error
func (*ISCSITargetDriver) ReInstatement ¶
func (s *ISCSITargetDriver) ReInstatement(existSess *ISCSISession, conn *iscsiConnection) (*ISCSISession, error)
func (*ISCSITargetDriver) ReleaseTSIH ¶
func (s *ISCSITargetDriver) ReleaseTSIH(tsih uint16)
func (*ISCSITargetDriver) RereadTargetLUNMap ¶
func (s *ISCSITargetDriver) RereadTargetLUNMap()
func (*ISCSITargetDriver) Resize ¶
func (s *ISCSITargetDriver) Resize(size uint64) error
func (*ISCSITargetDriver) Run ¶
func (s *ISCSITargetDriver) Run(port int) error
func (*ISCSITargetDriver) SetClusterIP ¶ added in v0.2.0
func (s *ISCSITargetDriver) SetClusterIP(ip string)
func (*ISCSITargetDriver) Stats ¶
func (s *ISCSITargetDriver) Stats() scsi.Stats
func (*ISCSITargetDriver) UnBindISCSISession ¶
func (s *ISCSITargetDriver) UnBindISCSISession(sess *ISCSISession)
func (*ISCSITargetDriver) UpdateStats ¶
func (s *ISCSITargetDriver) UpdateStats(conn *iscsiConnection)
type ISCSITaskManagementFunc ¶
type KeyConvFunc ¶
* The defaults here are according to the spec and must not be changed, * otherwise the initiator may make the wrong assumption. If you want * to change a value, edit the value in iscsi_target_create. * * The param MaxXmitDataSegmentLength doesn't really exist. It's a way * to remember the RDSL of the initiator, which defaults to 8k if he has * not told us otherwise.