Add option to disable multipath and other fixes

Signed-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>
This commit is contained in:
Utkarsh Mani Tripathi
2019-11-21 09:57:46 +05:30
parent 25f0038456
commit 583e9b3a4a
5 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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
}
+9 -1
View File
@@ -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)