return sense data while error

This commit is contained in:
Lei Xue
2016-10-06 12:09:24 +08:00
parent 13e73124a2
commit 4a1dcbfc27
4 changed files with 16 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright 2015 The GoStor Authors All rights reserved.
Copyright 2016 The GoStor Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -81,10 +81,9 @@ func (s *SCSITargetService) AddCommandQueue(tid int, scmd *api.SCSICommand) erro
scmd.Device = target.Devices[0]
glog.V(2).Infof("scsi opcode: 0x%x, LUN: %d:", int(scmd.SCB.Bytes()[0]), binary.LittleEndian.Uint64(scmd.Lun[:]))
result := scmd.Device.PerformCommand(tid, scmd)
scmd.Result = result.Stat
if result.Err != nil {
glog.Error(result.Err)
return result.Err
if result != api.SAMStatGood {
scmd.Result = result.Stat
glog.Warningf("%v", result.Err)
}
return nil
}
@@ -114,10 +113,8 @@ func NewSCSIDeviceOperation(fn api.CommandFunc, sa *SCSIServiceAction, pr uint8)
}
func BuildSenseData(cmd *api.SCSICommand, key byte, asc SCSISubError) {
senseBuffer := cmd.SenseBuffer
if senseBuffer == nil {
senseBuffer = &bytes.Buffer{}
}
senseBuffer := &bytes.Buffer{}
if cmd.Device.Attrs.SenseFormat {
// descriptor format
// current, not deferred
@@ -144,6 +141,8 @@ func BuildSenseData(cmd *api.SCSICommand, key byte, asc SCSISubError) {
senseBuffer.WriteByte(byte(asc) & 0xff)
cmd.SenseLength = length + 8
}
cmd.Result = key
cmd.SenseBuffer = senseBuffer
}
func getSCSIReadWriteOffset(scb []byte) uint64 {

View File

@@ -146,7 +146,7 @@ func SPCInquiry(host int, cmd *api.SCSICommand) api.SAMStat {
b = (uint8(0) & 0x7) << 5
b |= uint8(0) & 0x1f
}
fmt.Println(cmd.Device.Lun, *(*uint64)(unsafe.Pointer(&cmd.Lun)))
glog.V(2).Infof("%v, %v", cmd.Device.Lun, *(*uint64)(unsafe.Pointer(&cmd.Lun)))
if cmd.Device.Lun != *(*uint64)(unsafe.Pointer(&cmd.Lun)) {
goto sense
}
@@ -237,7 +237,7 @@ func SPCReportLuns(host int, cmd *api.SCSICommand) api.SAMStat {
}
for lunumber, lu := range cmd.Target.Devices {
fmt.Println("LUN:", lunumber)
glog.V(2).Infof("LUN: ", lunumber)
if remainLength > 0 {
lun := lu.Lun
if lun > 0xff {