scsi

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 15 Imported by: 24

Documentation

Overview

Target Driver Interface

SCSI block command processing

SCSI primary command processing

Index

Constants

View Source
const (
	// PERSISTENT_RESERVE_IN service action codes
	PR_IN_READ_KEYS           byte = 0x00
	PR_IN_READ_RESERVATION    byte = 0x01
	PR_IN_REPORT_CAPABILITIES byte = 0x02
	PR_IN_READ_FULL_STATUS    byte = 0x03

	// PERSISTENT_RESERVE_OUT service action codes
	PR_OUT_REGISTER                         byte = 0x00
	PR_OUT_RESERVE                          byte = 0x01
	PR_OUT_RELEASE                          byte = 0x02
	PR_OUT_CLEAR                            byte = 0x03
	PR_OUT_PREEMPT                          byte = 0x04
	PR_OUT_PREEMPT_AND_ABORT                byte = 0x05
	PR_OUT_REGISTER_AND_IGNORE_EXISTING_KEY byte = 0x06
	PR_OUT_REGISTER_AND_MOVE                byte = 0x07

	// Persistent Reservation scope
	PR_LU_SCOPE byte = 0x00

	// Persistent Reservation Type Mask format
	PR_TYPE_WRITE_EXCLUSIVE          byte = 0x01
	PR_TYPE_EXCLUSIVE_ACCESS         byte = 0x03
	PR_TYPE_WRITE_EXCLUSIVE_REGONLY  byte = 0x05
	PR_TYPE_EXCLUSIVE_ACCESS_REGONLY byte = 0x06
	PR_TYPE_WRITE_EXCLUSIVE_ALLREG   byte = 0x07
	PR_TYPE_EXCLUSIVE_ACCESS_ALLREG  byte = 0x08
)
View Source
const (
	//  6-byte commands
	CDB_GROUPID_0 = 6
	// 10-byte commands
	CDB_GROUPID_1 = 10
	// 10-byte commands
	CDB_GROUPID_2 = 10
	// reserved
	CDB_GROUPID_3 = 0
	// 16-byte commands
	CDB_GROUPID_4 = 16
	// 12-byte commands
	CDB_GROUPID_5 = 12
	// vendor specific
	CDB_GROUPID_6 = 0
	// vendor specific
	CDB_GROUPID_7 = 0
)
View Source
const (
	PIV_FCP   = byte(0x00)
	PIV_SPI   = byte(0x01)
	PIV_S3P   = byte(0x02)
	PIV_SBP   = byte(0x03)
	PIV_SRP   = byte(0x04)
	PIV_ISCSI = byte(0x05)
	PIV_SAS   = byte(0x06)
	PIV_ADT   = byte(0x07)
	PIV_ATA   = byte(0x08)
	PIV_USB   = byte(0x09)
	PIV_SOP   = byte(0x0A)
)
View Source
const (
	VERSION_NOT_CLAIM         = byte(0x00)
	VERSION_WITHDRAW_STANDARD = byte(0x03)
	VERSION_WITHDRAW_SPC2     = byte(0x04)
	VERSION_WITHDRAW_SPC3     = byte(0x05)
)
View Source
const (
	INQ_CODE_BIN   = byte(1)
	INQ_CODE_ASCII = byte(2)
	INQ_CODE_UTF8  = byte(3)
)

* Code Set * * 1 - Designator fild contains binary values * 2 - Designator field contains ASCII printable chars * 3 - Designaotor field contains UTF-8

View Source
const (
	ASS_LU       = byte(0x00)
	ASS_TGT_PORT = byte(0x01)
	ASS_TGT_DEV  = byte(0x02)
)

* Association field * * 00b - Associated with Logical Unit * 01b - Associated with target port * 10b - Associated with SCSI Target device * 11b - Reserved

View Source
const (
	PQ_DEVICE_CONNECTED   = byte(0x00 << 5)
	PQ_DEVICE_NOT_CONNECT = byte(0x01 << 5)
	PQ_RESERVED           = byte(0x02 << 5)
	PQ_NOT_SUPPORT        = byte(0x03 << 5)
)

* Table 177 — PERIPHERAL QUALIFIER field * Qualifier Description * 000b - A peripheral device having the indicated peripheral * device type is connected to this logical unit. If the device server is * unable to determine whether or not a peripheral device is connected, * then the device server also shall use this peripheral qualifier. * This peripheral qualifier does not indicate that the peripheral * device connected to the logical unit is ready for access. * 001b - A peripheral device having the indicated peripheral device type * is not connected to this logical unit. However, the device server is capable of * supporting the indicated peripheral device type on this logical unit. * 010b - Reserved * 011b - The device server is not capable of supporting a * peripheral device on this logical unit. For this peripheral * qualifier the peripheral device type shall be set to 1Fh. All other peripheral * device type values are reserved for this peripheral qualifier. * 100b to 111b Vendor specific

View Source
const (
	INQUIRY_SCCS          = byte(0x80)
	INQUIRY_AAC           = byte(0x40)
	INQUIRY_TPGS_NO       = byte(0x00)
	INQUIRY_TPGS_IMPLICIT = byte(0x10)
	INQUIRY_TPGS_EXPLICIT = byte(0x20)
	INQUIRY_TPGS_BOTH     = byte(0x30)
	INQUIRY_3PC           = byte(0x08)
	INQUIRY_Reserved      = byte(0x06)
	INQUIRY_PROTECT       = byte(0x01)

	INQUIRY_NORM_ACA        = byte(0x20)
	INQUIRY_HISUP           = byte(0x10)
	INQUIRY_STANDARD_FORMAT = byte(0x02)

	INQUIRY_ENCSERV = byte(0x40)
	INQUIRY_VS0     = byte(0x20)
	INQUIRY_MULTIP  = byte(0x10)
	INQUIRY_ADDR16  = byte(0x01)

	INQUIRY_WBUS16 = byte(0x20)
	INQUIRY_SYNC   = byte(0x10)
	INQUIRY_CMDQUE = byte(0x02)
	INQUIRY_VS1    = byte(0x01)

	INQUIRY_QAS = byte(0x02)
	INQUIRY_IUS = byte(0x01)
)
View Source
const (
	ADDRESS_METHOD_PERIPHERAL_DEVICE     = byte(0x00)
	ADDRESS_METHOD_FLAT_SPACE            = byte(0x01)
	ADDRESS_METHOD_LOGICAL_UNIT          = byte(0x02)
	ADDRESS_METHOD_EXTENDED_LOGICAL_UNIT = byte(0x03)
)
View Source
const (
	DESG_VENDOR = iota
	DESG_T10
	DESG_EUI64
	DESG_NAA
	DESG_REL_TGT_PORT
	DESG_TGT_PORT_GRP
	DESG_LU_GRP
	DESG_MD5
	DESG_SCSI
)

* Designator type - SPC-4 Reference * * 0 - Vendor specific - 7.6.3.3 * 1 - T10 vendor ID - 7.6.3.4 * 2 - EUI-64 - 7.6.3.5 * 3 - NAA - 7.6.3.6 * 4 - Relative Target port identifier - 7.6.3.7 * 5 - Target Port group - 7.6.3.8 * 6 - Logical Unit group - 7.6.3.9 * 7 - MD5 logical unit identifier - 7.6.3.10 * 8 - SCSI name string - 7.6.3.11

View Source
const (
	NAA_IEEE_EXTD      = byte(0x2)
	NAA_LOCAL          = byte(0x3)
	NAA_IEEE_REGD      = byte(0x5)
	NAA_IEEE_REGD_EXTD = byte(0x6)
)
View Source
const (
	PR_SPECIAL = (1 << 5)
	PR_WE_FA   = (1 << 4)
	PR_EA_FA   = (1 << 3)
	PR_RR_FR   = (1 << 2)
	PR_WE_FN   = (1 << 1)
	PR_EA_FN   = (1 << 0)
)

Variables

View Source
var (
	SCSIVendorID  = "GOSTOR"
	SCSIProductID = "GOTGT"
	SCSIID        = "iqn.2016-09.com.gotgt.gostor:iscsi-tgt"
)
View Source
var (
	NO_SENSE        byte = 0x00
	RECOVERED_ERROR byte = 0x01
	NOT_READY       byte = 0x02
	MEDIUM_ERROR    byte = 0x03
	HARDWARE_ERROR  byte = 0x04
	ILLEGAL_REQUEST byte = 0x05
	UNIT_ATTENTION  byte = 0x06
	DATA_PROTECT    byte = 0x07
	BLANK_CHECK     byte = 0x08
	COPY_ABORTED    byte = 0x0a
	ABORTED_COMMAND byte = 0x0b
	VOLUME_OVERFLOW byte = 0x0d
	MISCOMPARE      byte = 0x0e
)
View Source
var (
	NoSenseError        = SCSIError{NO_SENSE, errors.New("no sense")}
	RecoveredError      = SCSIError{RECOVERED_ERROR, errors.New("recovered error")}
	NotReadyError       = SCSIError{NOT_READY, errors.New("not ready")}
	MediumError         = SCSIError{MEDIUM_ERROR, errors.New("medium error")}
	HardwareError       = SCSIError{HARDWARE_ERROR, errors.New("hardware error")}
	IllegalRequestError = SCSIError{ILLEGAL_REQUEST, errors.New("illegal request")}
	UnitAttentionError  = SCSIError{UNIT_ATTENTION, errors.New("unit attention")}
	DataProtectError    = SCSIError{DATA_PROTECT, errors.New("data protect")}
	BlankCheckError     = SCSIError{BLANK_CHECK, errors.New("blank check")}
	CopyAbortedError    = SCSIError{COPY_ABORTED, errors.New("copy aborted")}
	AbortedCommandError = SCSIError{ABORTED_COMMAND, errors.New("aborted command")}
	VolumeOverflowError = SCSIError{VOLUME_OVERFLOW, errors.New("volume overflow")}
	MiscompareError     = SCSIError{MISCOMPARE, errors.New("miscompare")}
)
View Source
var (
	EnableORWrite16             = true
	EnablePersistentReservation = true
)
View Source
var (
	EnableMultipath = true
)

Functions

func AddBackendStorage

func AddBackendStorage(bs config.BackendStorage) error

func AddITNexus

func AddITNexus(target *api.SCSITarget, itnexus *api.ITNexus) bool

func AddLUNMapping

func AddLUNMapping(m LUNMapping) error

func BuildSenseData

func BuildSenseData(cmd *api.SCSICommand, key byte, asc SCSISubError)

func DelBackendStorage

func DelBackendStorage(deviceID uint64)

func DelLUNMapping

func DelLUNMapping(m LUNMapping)

func FindTargetGroup

func FindTargetGroup(target *api.SCSITarget, relPortID uint16) uint16

func FindTargetPort

func FindTargetPort(target *api.SCSITarget, relPortID uint16) *api.SCSITargetPort

func GetLU

func GetLU(tgtName string, LUN uint64) *api.SCSILu

func GetReservation

func GetReservation(dev *api.SCSILu, nexusID uint64) *api.SCSIReservation

func GetTargetBSMap

func GetTargetBSMap(tgtName string) (api.RemoteBackingStore, error)

func GetTargetLUNMap

func GetTargetLUNMap(tgtName string) api.LUNMap

func InitSCSILUMap

func InitSCSILUMap(config *config.Config) error

func InitSCSILUMapEx

func InitSCSILUMapEx(config *config.BackendStorage, tgtName string, lun uint64, bs api.RemoteBackingStore) error

func InquiryPage0x00

func InquiryPage0x00(host int, cmd *api.SCSICommand) (*bytes.Buffer, uint16)

func InquiryPage0x80

func InquiryPage0x80(host int, cmd *api.SCSICommand) (*bytes.Buffer, uint16)

func InquiryPage0x83

func InquiryPage0x83(host int, cmd *api.SCSICommand) (*bytes.Buffer, uint16)

func InquiryPage0xB0

func InquiryPage0xB0(host int, cmd *api.SCSICommand) (*bytes.Buffer, uint16)

func InquiryPage0xB2

func InquiryPage0xB2(host int, cmd *api.SCSICommand) (*bytes.Buffer, uint16)

func NewBackingStore

func NewBackingStore(name string) (api.BackingStore, error)

func NewLUN0

func NewLUN0() *api.SCSILu

NewLUN0: create a new fake SCSI LU

func NewSBCDevice

func NewSBCDevice(deviceType api.SCSIDeviceType) api.SCSIDeviceProtocol

func NewSCSILu

func NewSCSILu(bs *config.BackendStorage) (*api.SCSILu, error)

NewSCSILu: create a new SCSI LU path format <protocol>:/absolute/file/path

func RegisterBackingStore

func RegisterBackingStore(name string, f BackingStoreFunc)

func RegisterTargetDriver

func RegisterTargetDriver(name string, f TargetDriverFunc)

func RemoveITNexus

func RemoveITNexus(target *api.SCSITarget, itnexus *api.ITNexus)

func SBCFormatUnit

func SBCFormatUnit(host int, cmd *api.SCSICommand) api.SAMStat

* SBCFormatUnit Implements SCSI FORMAT UNIT command * The FORMAT UNIT command requests that the device server format the medium into application client * accessible logical blocks as specified in the number of blocks and block length values received * in the last mode parameter block descriptor in a MODE SELECT command (see SPC-3). In addition, * the device server may certify the medium and create control structures for the management of the medium and defects. * The degree that the medium is altered by this command is vendor-specific. * * Reference : SBC2r16 * 5.2 - FORMAT UNIT

func SBCGetLbaStatus

func SBCGetLbaStatus(host int, cmd *api.SCSICommand) api.SAMStat

func SBCModeSelect

func SBCModeSelect(host int, cmd *api.SCSICommand) api.SAMStat

func SBCModeSense

func SBCModeSense(host int, cmd *api.SCSICommand) api.SAMStat

func SBCReadCapacity

func SBCReadCapacity(host int, cmd *api.SCSICommand) api.SAMStat

* SBCReadCapacity Implements SCSI READ CAPACITY(10) command * The READ CAPACITY (10) command requests that the device server transfer 8 bytes of parameter data * describing the capacity and medium format of the direct-access block device to the data-in buffer. * This command may be processed as if it has a HEAD OF QUEUE task attribute. If the logical unit supports * protection information, the application client should use the READ CAPACITY (16) command instead of * the READ CAPACITY (10) command. * * Reference : SBC2r16 * 5.10 - READ CAPACITY(10)

func SBCReadCapacity16

func SBCReadCapacity16(host int, cmd *api.SCSICommand) api.SAMStat

* SBCReadCapacity16 Implements SCSI READ CAPACITY(16) command * The READ CAPACITY (16) command requests that the device server transfer parameter data * describing the capacity and medium format of the direct-access block device to the data-in buffer. * * Reference : SBC2r16 * 5.11 - READ CAPACITY(16)

func SBCReadWrite

func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat

* SBCReadWrite Implements SCSI READ(10/12/16), WRITE(10/12/16), WRITE AND VERIFY(10/12/16), WRITE SAME(10/12/16) * The READ command requests that the device server read the specified logical block(s) and transfer them to the data-in buffer. * The WRITE command requests that the device server transfer the specified logical block(s) from the data-out buffer and write them. * The WRITE AND VERIFY command requests that the device server transfer the specified logical block(s) from the data-out buffer, * write them to the medium, and then verify that they are correctly written. * * Reference : SBC2r16 * 5.6 - READ (10) * 5.7 - READ (12) * 5.8 - READ (16) * 5.25 - WRITE (10) * 5.26 - WRITE (12) * 5.27 - WRITE (16) * 5.29 - WRITE AND VERIFY (10) * 5.30 - WRITE AND VERIFY (12) * 5.31 - WRITE AND VERIFY (16)

func SBCRelease

func SBCRelease(host int, cmd *api.SCSICommand) api.SAMStat

func SBCReserve

func SBCReserve(host int, cmd *api.SCSICommand) api.SAMStat

func SBCServiceAction

func SBCServiceAction(host int, cmd *api.SCSICommand) api.SAMStat

func SBCSyncCache

func SBCSyncCache(host int, cmd *api.SCSICommand) api.SAMStat

* SBCSyncCache Implements SCSI SYNCHRONIZE CACHE(10) and SYNCHRONIZE CACHE(16) command * The SYNCHRONIZE CACHE command requests that the device server ensure that * the specified logical blocks have their most recent data values recorded in * non-volatile cache and/or on the medium, based on the SYNC_NV bit. * * Reference : SBC2r16 * 5.18 - SYNCHRONIZE CACHE (10) * 5.19 - SYNCHRONIZE CACHE (16)

func SBCUnmap

func SBCUnmap(host int, cmd *api.SCSICommand) api.SAMStat

func SBCVerify

func SBCVerify(host int, cmd *api.SCSICommand) api.SAMStat

SBCVerify Implements SCSI VERIFY(10) command * The VERIFY (10) command requests that the device server verify the specified logical block(s) on the medium. * * Reference : SBC2r16 * 5.20 - VERIFY(10)

func SCSICDBBufXLength

func SCSICDBBufXLength(scb []byte) (int64, bool)

* Transfer Length (if any) * Parameter List Length (if any) * Allocation Length (if any)

func SCSICDBGroupID

func SCSICDBGroupID(opcode byte) byte

func SPCIllegalOp

func SPCIllegalOp(host int, cmd *api.SCSICommand) api.SAMStat

func SPCInquiry

func SPCInquiry(host int, cmd *api.SCSICommand) api.SAMStat

* SPCInquiry Implements SCSI INQUIRY command * The INQUIRY command requests the device server to return information regarding the logical unit and SCSI target device. * * Reference : SPC4r11 * 6.6 - INQUIRY

func SPCLuOffline

func SPCLuOffline(lu *api.SCSILu) error

func SPCLuOnline

func SPCLuOnline(lu *api.SCSILu) error

func SPCModeSense

func SPCModeSense(host int, cmd *api.SCSICommand) api.SAMStat

* SPCModeSense Implement SCSI MODE SENSE(6) and MODE SENSE(10) command * The MODE SENSE command requests the device server to return the specified medium, * logical unit, or peripheral device parameters. * * Reference : SPC4r11 * 6.11 - MODE SENSE(6) * 6.12 - MODE SENSE(10)

func SPCPRClear

func SPCPRClear(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRPreempt

func SPCPRPreempt(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRReadKeys

func SPCPRReadKeys(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRReadReservation

func SPCPRReadReservation(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRRegister

func SPCPRRegister(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRRegisterAndMove

func SPCPRRegisterAndMove(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRRelease

func SPCPRRelease(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRReportCapabilities

func SPCPRReportCapabilities(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPRReserve

func SPCPRReserve(host int, cmd *api.SCSICommand) api.SAMStat

func SPCPreventAllowMediaRemoval

func SPCPreventAllowMediaRemoval(host int, cmd *api.SCSICommand) api.SAMStat

func SPCReportLuns

func SPCReportLuns(host int, cmd *api.SCSICommand) api.SAMStat

* SPCReportLuns Implements SCSI REPORT LUNS command * The REPORT LUNS command requests the device server to return the peripheral Device * logical unit inventory accessible to the I_T nexus. * * Reference : SPC4r11 * 6.33 - REPORT LUNS

func SPCReportSupportedOperationCodes

func SPCReportSupportedOperationCodes(host int, cmd *api.SCSICommand) api.SAMStat

func SPCRequestSense

func SPCRequestSense(host int, cmd *api.SCSICommand) api.SAMStat

* SPCRequestSense Implements SCSI REQUEST SENSE command * The REQUEST SENSE command requests the device server to return parameter data that contains sense data. * * Reference : SPC4r11 * 6.39 - REQUEST SENSE

func SPCSendDiagnostics

func SPCSendDiagnostics(host int, cmd *api.SCSICommand) api.SAMStat

* SPCSendDiagnostics Implements SCSI SEND DIAGNOSTIC command * The SEND DIAGNOSTIC command requests the device server to perform diagnostic operations * on the SCSI target device, on the logical unit, or on both. * * Reference : SPC4r11 * 6.42 - SEND DIAGNOSTIC

func SPCServiceAction

func SPCServiceAction(host int, cmd *api.SCSICommand) api.SAMStat

This is useful for the various commands using the SERVICE ACTION format.

func SPCStartStop

func SPCStartStop(host int, cmd *api.SCSICommand) api.SAMStat

func SPCTestUnit

func SPCTestUnit(host int, cmd *api.SCSICommand) api.SAMStat

* SPCTestUnit Implements SCSI TEST UNIT READY command * The TEST UNIT READY command requests the device server to indicate whether the logical unit is ready. * * Reference : SPC4r11 * 6.47 - TEST UNIT READY

Types

type BackendType

type BackendType string

type BackingStoreFunc

type BackingStoreFunc func() (api.BackingStore, error)

type BaseBackingStore

type BaseBackingStore struct {
	Name            string
	DataSize        uint64
	OflagsSupported int
}

type BaseSCSIDeviceProtocol

type BaseSCSIDeviceProtocol struct {
	DeviceType    api.SCSIDeviceType
	SCSIDeviceOps []SCSIDeviceOperation
}

type LUNMapping

type LUNMapping struct {
	TargetName string
	LUN        uint64
	DeviceID   uint64
}

type SBCSCSIDeviceProtocol

type SBCSCSIDeviceProtocol struct {
	BaseSCSIDeviceProtocol
}

func (SBCSCSIDeviceProtocol) ConfigLu

func (sbc SBCSCSIDeviceProtocol) ConfigLu(lu *api.SCSILu) error

func (SBCSCSIDeviceProtocol) ExitLu

func (sbc SBCSCSIDeviceProtocol) ExitLu(lu *api.SCSILu) error

func (SBCSCSIDeviceProtocol) InitLu

func (sbc SBCSCSIDeviceProtocol) InitLu(lu *api.SCSILu) error

func (SBCSCSIDeviceProtocol) OfflineLu

func (sbc SBCSCSIDeviceProtocol) OfflineLu(lu *api.SCSILu) error

func (SBCSCSIDeviceProtocol) OnlineLu

func (sbc SBCSCSIDeviceProtocol) OnlineLu(lu *api.SCSILu) error

func (SBCSCSIDeviceProtocol) PerformCommand

func (sbc SBCSCSIDeviceProtocol) PerformCommand(opcode int) interface{}

func (SBCSCSIDeviceProtocol) PerformServiceAction

func (sbc SBCSCSIDeviceProtocol) PerformServiceAction(opcode int, action uint8) interface{}

type SCSIDeviceOperation

type SCSIDeviceOperation struct {
	CommandPerformFunc api.CommandFunc
	ServiceAction      []*SCSIServiceAction
	PRConflictBits     uint8
}

func NewSCSIDeviceOperation

func NewSCSIDeviceOperation(fn api.CommandFunc, sa []*SCSIServiceAction, pr uint8) SCSIDeviceOperation

type SCSIError

type SCSIError struct {
	// contains filtered or unexported fields
}

type SCSILUMap

type SCSILUMap struct {

	// use UUID as the key for all LUs
	AllDevices api.LUNMap
	// use target name as the key for target's LUN map
	TargetsLUNMap map[string]api.LUNMap

	TargetsBSMap map[string]api.RemoteBackingStore /* use target name as the key for target's Backing Store (temp) */
	// contains filtered or unexported fields
}

type SCSILUReservation

type SCSILUReservation struct {
	TargetName         string
	DeviceUUID         uint64
	PRGeneration       uint32
	Reservations       []*api.SCSIReservation
	CurrentReservation *api.SCSIReservation
}

type SCSILUReservationMap

type SCSILUReservationMap map[uint64]*SCSILUReservation /* device uuid as the key */

type SCSIReservationOperator

type SCSIReservationOperator interface {
	GetCurrentReservation(tgtName string, devUUID uint64) *api.SCSIReservation
	SetCurrentReservation(tgtName string, devUUID uint64, res *api.SCSIReservation) bool
	IsCurrentReservation(tgtName string, devUUID uint64, res *api.SCSIReservation) bool

	GetPRGeneration(tgtName string, devUUID uint64) (uint32, bool)
	IncPRGeneration(tgtName string, devUUID uint64) bool

	AddReservation(tgtName string, devUUID uint64, res *api.SCSIReservation) bool
	GetReservation(tgtName string, devUUID uint64, ITNexusID uuid.UUID) *api.SCSIReservation
	GetReservationList(tgtName string, devUUID uint64) []*api.SCSIReservation
	DeleteAndRemoveReservation(tgtName string, devUUID uint64, res *api.SCSIReservation)
	RemoveReservation(tgtName string, devUUID uint64, res *api.SCSIReservation)
	RemoveAllReservation(tgtName string, devUUID uint64)

	IsKeyExists(tgtName string, devUUID uint64, key uint64) bool

	Save(tgtName string, devUUID uint64) bool
}

func GetSCSIReservationOperator

func GetSCSIReservationOperator() SCSIReservationOperator

type SCSIServiceAction

type SCSIServiceAction struct {
	ServiceAction      uint8
	CommandPerformFunc api.CommandFunc
}

type SCSISimpleReservationOperator

type SCSISimpleReservationOperator struct {
	SCSIReservationOperator
	// contains filtered or unexported fields
}

func (*SCSISimpleReservationOperator) AddReservation

func (op *SCSISimpleReservationOperator) AddReservation(tgtName string, devUUID uint64, res *api.SCSIReservation) bool

func (*SCSISimpleReservationOperator) DeleteAndRemoveReservation

func (op *SCSISimpleReservationOperator) DeleteAndRemoveReservation(tgtName string, devUUID uint64, res *api.SCSIReservation)

func (*SCSISimpleReservationOperator) GetCurrentReservation

func (op *SCSISimpleReservationOperator) GetCurrentReservation(tgtName string, devUUID uint64) *api.SCSIReservation

func (*SCSISimpleReservationOperator) GetPRGeneration

func (op *SCSISimpleReservationOperator) GetPRGeneration(tgtName string, devUUID uint64) (uint32, bool)

func (*SCSISimpleReservationOperator) GetReservation

func (op *SCSISimpleReservationOperator) GetReservation(tgtName string, devUUID uint64, ITNexusID uuid.UUID) *api.SCSIReservation

func (*SCSISimpleReservationOperator) GetReservationList

func (op *SCSISimpleReservationOperator) GetReservationList(tgtName string, devUUID uint64) []*api.SCSIReservation

func (*SCSISimpleReservationOperator) IncPRGeneration

func (op *SCSISimpleReservationOperator) IncPRGeneration(tgtName string, devUUID uint64) bool

func (*SCSISimpleReservationOperator) InitLUReservation

func (op *SCSISimpleReservationOperator) InitLUReservation(tgtName string, devUUID uint64)

func (*SCSISimpleReservationOperator) IsCurrentReservation

func (op *SCSISimpleReservationOperator) IsCurrentReservation(tgtName string, devUUID uint64, res *api.SCSIReservation) bool

func (*SCSISimpleReservationOperator) IsKeyExists

func (op *SCSISimpleReservationOperator) IsKeyExists(tgtName string, devUUID uint64, key uint64) bool

func (*SCSISimpleReservationOperator) RemoveAllReservation

func (op *SCSISimpleReservationOperator) RemoveAllReservation(tgtName string, devUUID uint64)

func (*SCSISimpleReservationOperator) RemoveReservation

func (op *SCSISimpleReservationOperator) RemoveReservation(tgtName string, devUUID uint64, res *api.SCSIReservation)

func (*SCSISimpleReservationOperator) Save

func (op *SCSISimpleReservationOperator) Save(tgtName string, devUUID uint64) bool

func (*SCSISimpleReservationOperator) SetCurrentReservation

func (op *SCSISimpleReservationOperator) SetCurrentReservation(tgtName string, devUUID uint64, res *api.SCSIReservation) bool

type SCSISubError

type SCSISubError uint16
var (
	// Key 0: No Sense Errors
	NO_ADDITIONAL_SENSE         SCSISubError = 0x0000
	ASC_MARK                    SCSISubError = 0x0001
	ASC_EOM                     SCSISubError = 0x0002
	ASC_BOM                     SCSISubError = 0x0004
	ASC_END_OF_DATA             SCSISubError = 0x0005
	ASC_OP_IN_PROGRESS          SCSISubError = 0x0016
	ASC_DRIVE_REQUIRES_CLEANING SCSISubError = 0x8282

	// Key 1: Recovered Errors
	ASC_WRITE_ERROR            SCSISubError = 0x0c00
	ASC_READ_ERROR             SCSISubError = 0x1100
	ASC_RECOVERED_WITH_RETRYS  SCSISubError = 0x1701
	ASC_MEDIA_LOAD_EJECT_ERROR SCSISubError = 0x5300
	ASC_FAILURE_PREDICTION     SCSISubError = 0x5d00

	// Key 2: Not ready
	ASC_CAUSE_NOT_REPORTABLE    SCSISubError = 0x0400
	ASC_BECOMING_READY          SCSISubError = 0x0401
	ASC_INITIALIZING_REQUIRED   SCSISubError = 0x0402
	ASC_CLEANING_CART_INSTALLED SCSISubError = 0x3003
	ASC_CLEANING_FAILURE        SCSISubError = 0x3007
	ASC_MEDIUM_NOT_PRESENT      SCSISubError = 0x3a00
	ASC_LOGICAL_UNIT_NOT_CONFIG SCSISubError = 0x3e00

	// Key 3: Medium Errors
	ASC_UNRECOVERED_READ           SCSISubError = 0x1100
	ASC_RECORDED_ENTITY_NOT_FOUND  SCSISubError = 0x1400
	ASC_UNKNOWN_FORMAT             SCSISubError = 0x3001
	ASC_IMCOMPATIBLE_FORMAT        SCSISubError = 0x3002
	ASC_MEDIUM_FORMAT_CORRUPT      SCSISubError = 0x3100
	ASC_SEQUENTIAL_POSITION_ERR    SCSISubError = 0x3b00
	ASC_WRITE_APPEND_ERR           SCSISubError = 0x5000
	ASC_CARTRIDGE_FAULT            SCSISubError = 0x5200
	ASC_MEDIA_LOAD_OR_EJECT_FAILED SCSISubError = 0x5300

	// Key 4: Hardware Failure
	ASC_COMPRESSION_CHECK            SCSISubError = 0x0c04
	ASC_DECOMPRESSION_CRC            SCSISubError = 0x110d
	ASC_MECHANICAL_POSITIONING_ERROR SCSISubError = 0x1501
	ASC_MANUAL_INTERVENTION_REQ      SCSISubError = 0x0403
	ASC_HARDWARE_FAILURE             SCSISubError = 0x4000
	ASC_INTERNAL_TGT_FAILURE         SCSISubError = 0x4400
	ASC_ERASE_FAILURE                SCSISubError = 0x5100

	// Key 5: Illegal Request
	ASC_PARAMETER_LIST_LENGTH_ERR                 SCSISubError = 0x1a00
	ASC_INVALID_OP_CODE                           SCSISubError = 0x2000
	ASC_LBA_OUT_OF_RANGE                          SCSISubError = 0x2100
	ASC_INVALID_FIELD_IN_CDB                      SCSISubError = 0x2400
	ASC_LUN_NOT_SUPPORTED                         SCSISubError = 0x2500
	ASC_INVALID_FIELD_IN_PARMS                    SCSISubError = 0x2600
	ASC_INVALID_RELEASE_OF_PERSISTENT_RESERVATION SCSISubError = 0x2604
	ASC_INCOMPATIBLE_FORMAT                       SCSISubError = 0x3005
	ASC_SAVING_PARMS_UNSUP                        SCSISubError = 0x3900
	ASC_MEDIUM_DEST_FULL                          SCSISubError = 0x3b0d
	ASC_MEDIUM_SRC_EMPTY                          SCSISubError = 0x3b0e
	ASC_POSITION_PAST_BOM                         SCSISubError = 0x3b0c
	ASC_MEDIUM_REMOVAL_PREVENTED                  SCSISubError = 0x5302
	ASC_INSUFFICENT_REGISTRATION_RESOURCES        SCSISubError = 0x5504
	ASC_BAD_MICROCODE_DETECTED                    SCSISubError = 0x8283

	// Key 6: Unit Attention
	ASC_NOT_READY_TO_TRANSITION         SCSISubError = 0x2800
	ASC_POWERON_RESET                   SCSISubError = 0x2900
	ASC_I_T_NEXUS_LOSS_OCCURRED         SCSISubError = 0x2907
	ASC_MODE_PARAMETERS_CHANGED         SCSISubError = 0x2a01
	ASC_RESERVATIONS_PREEMPTED          SCSISubError = 0x2a03
	ASC_RESERVATIONS_RELEASED           SCSISubError = 0x2a04
	ASC_INSUFFICIENT_TIME_FOR_OPERATION SCSISubError = 0x2e00
	ASC_CMDS_CLEARED_BY_ANOTHER_INI     SCSISubError = 0x2f00
	ASC_MICROCODE_DOWNLOADED            SCSISubError = 0x3f01
	ASC_INQUIRY_DATA_HAS_CHANGED        SCSISubError = 0x3f03
	ASC_REPORTED_LUNS_DATA_HAS_CHANGED  SCSISubError = 0x3f0e
	ASC_FAILURE_PREDICTION_FALSE        SCSISubError = 0x5dff

	// Data Protect
	ASC_WRITE_PROTECT              SCSISubError = 0x2700
	ASC_MEDIUM_OVERWRITE_ATTEMPTED SCSISubError = 0x300c

	// Miscompare
	ASC_MISCOMPARE_DURING_VERIFY_OPERATION SCSISubError = 0x1d00
)

type SCSITargetDriver

type SCSITargetDriver interface {
	Run() error
	NewTarget(string, *config.Config) error
	RereadTargetLUNMap()
	Close() error
	Resize(uint64) error
	Stats() Stats
	SetClusterIP(string)
}

func NewTargetDriver

func NewTargetDriver(tgtDriver string, s *SCSITargetService) (SCSITargetDriver, error)

type SCSITargetService

type SCSITargetService struct {
	Targets []*api.SCSITarget
	// contains filtered or unexported fields
}

func NewSCSITargetService

func NewSCSITargetService() *SCSITargetService

func (*SCSITargetService) AddCommandQueue

func (s *SCSITargetService) AddCommandQueue(tid int, scmd *api.SCSICommand) error

func (*SCSITargetService) GetTargetList

func (s *SCSITargetService) GetTargetList() ([]api.SCSITarget, error)

func (*SCSITargetService) NewSCSITarget

func (s *SCSITargetService) NewSCSITarget(tid int, driverName, name string) (*api.SCSITarget, error)

func (*SCSITargetService) RereadTargetLUNMap

func (s *SCSITargetService) RereadTargetLUNMap()

func (*SCSITargetService) Resize

func (s *SCSITargetService) Resize(size uint64) error

type Stats

type Stats struct {
	IsClientConnected bool
	RevisionCounter   int64
	ReplicaCounter    int64
	SCSIIOCount       map[int]int64

	ReadIOPS            int64
	TotalReadTime       int64
	TotalReadBlockCount int64

	WriteIOPS            int64
	TotalWriteTime       int64
	TotalWriteBlockCount int64

	UsedLogicalBlocks int64
	UsedBlocks        int64
	SectorSize        int64
}

type TargetDriverFunc

type TargetDriverFunc func(*SCSITargetService) (SCSITargetDriver, error)

Directories

Path Synopsis
Package backingstore provides the plugin to connect backend storage.
Package backingstore provides the plugin to connect backend storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL