diff --git a/pkg/port/iscsit/cmd.go b/pkg/port/iscsit/cmd.go index cc87469..f592568 100644 --- a/pkg/port/iscsit/cmd.go +++ b/pkg/port/iscsit/cmd.go @@ -371,7 +371,6 @@ func (m *ISCSICommand) dataInBytes() []byte { copy(buf[36:], util.MarshalUint32(m.DataSN)) copy(buf[40:], util.MarshalUint32(m.BufferOffset)) copy(buf[44:], util.MarshalUint32(m.Resid)) - copy(buf[48:], m.RawData[m.BufferOffset:m.BufferOffset+uint32(m.DataLen)]) if m.ExpectedDataLen != 0 { copy(buf[48:], m.RawData[m.BufferOffset:m.BufferOffset+uint32(m.DataLen)]) } diff --git a/pkg/port/iscsit/iscsid.go b/pkg/port/iscsit/iscsid.go index b28526b..ffc14d4 100644 --- a/pkg/port/iscsit/iscsid.go +++ b/pkg/port/iscsit/iscsid.go @@ -55,7 +55,6 @@ type ISCSITargetDriver struct { TSIHPoolMutex sync.Mutex isClientConnected bool enableStats bool - SCSIIOCount map[int]int64 mu *sync.RWMutex l net.Listener state uint8 @@ -77,8 +76,8 @@ func NewISCSITargetDriver(base *scsi.SCSITargetService) (scsi.SCSITargetDriver, } if EnableStats { - driver.SCSIIOCount = map[int]int64{} driver.enableStats = true + driver.TargetStats.SCSIIOCount = map[int]int64{} } return driver, nil } @@ -631,10 +630,12 @@ func (s *ISCSITargetDriver) scsiCommandHandler(conn *iscsiConnection) (err error switch req.OpCode { case OpSCSICmd: log.Debugf("SCSI Command processing...") - if _, ok := s.SCSIIOCount[(int)(req.CDB[0])]; ok != false { - s.SCSIIOCount[(int)(req.CDB[0])] += 1 - } else { - s.SCSIIOCount[(int)(req.CDB[0])] = 1 + if s.enableStats { + if _, ok := s.TargetStats.SCSIIOCount[(int)(req.CDB[0])]; ok != false { + s.TargetStats.SCSIIOCount[(int)(req.CDB[0])] += 1 + } else { + s.TargetStats.SCSIIOCount[(int)(req.CDB[0])] = 1 + } } scmd := &api.SCSICommand{ ITNexusID: conn.session.ITNexus.ID, diff --git a/pkg/scsi/backingstore.go b/pkg/scsi/backingstore.go index 920f97a..9890695 100644 --- a/pkg/scsi/backingstore.go +++ b/pkg/scsi/backingstore.go @@ -125,12 +125,12 @@ func bsPerformCommand(bs api.BackingStore, cmd *api.SCSICommand) (err error, key bs.DataAdvise(int64(offset), int64(length), util.POSIX_FADV_NOREUSE) } cmd.InSDBBuffer.Resid = uint32(length) - copy(cmd.InSDBBuffer.Buffer, rbuf) if cmd.InSDBBuffer.Length < uint32(length) { key = ILLEGAL_REQUEST asc = ASC_INVALID_FIELD_IN_CDB goto sense } + copy(cmd.InSDBBuffer.Buffer, rbuf) case api.PRE_FETCH_10, api.PRE_FETCH_16: err = bs.DataAdvise(int64(offset), tl, util.POSIX_FADV_WILLNEED) if err != nil { diff --git a/pkg/scsi/backingstore/remote/remote.go b/pkg/scsi/backingstore/remote/remote.go index 38aab1f..5d6a12e 100644 --- a/pkg/scsi/backingstore/remote/remote.go +++ b/pkg/scsi/backingstore/remote/remote.go @@ -113,6 +113,6 @@ func (bs *RemBackingStore) DataSync(offset, length int64) (err error) { } func (bs *RemBackingStore) Unmap(bd []api.UnmapBlockDescriptor) (err error) { - _, err = bs.RemBs.Unmap(int64(bd[0].Offset), int64(bd[0].TL)) + //_, err = bs.RemBs.Unmap(int64(bd[0].Offset), int64(bd[0].TL)) return } diff --git a/pkg/scsi/spc.go b/pkg/scsi/spc.go index 5e6a69e..6ed3ee4 100644 --- a/pkg/scsi/spc.go +++ b/pkg/scsi/spc.go @@ -28,6 +28,10 @@ import ( log "github.com/sirupsen/logrus" ) +var ( + EnableMultipath = true +) + func SPCIllegalOp(host int, cmd *api.SCSICommand) api.SAMStat { BuildSenseData(cmd, ILLEGAL_REQUEST, ASC_INVALID_OP_CODE) return api.SAMStatCheckCondition @@ -325,7 +329,11 @@ func SPCInquiry(host int, cmd *api.SCSICommand) api.SAMStat { } //byte 5 //SCCS(0) AAC(0) TPGS(0) 3PC(0) PROTECT(0) - addBuf.WriteByte(INQUIRY_TPGS_IMPLICIT) + if EnableMultipath { + addBuf.WriteByte(INQUIRY_TPGS_IMPLICIT) + } else { + addBuf.WriteByte(INQUIRY_TPGS_NO) + } //byte 6 //ENCSERV(0) VS(0) MULTIP(0) ADDR16(0) addBuf.WriteByte(0x00)