delete cit to use new gotgt as main cmd, use logrus instead of glog
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/golang/glog"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/gostor/gotgt/pkg/util"
|
||||
)
|
||||
@@ -133,12 +133,12 @@ write:
|
||||
// hack: wbuf = []byte("hello world!")
|
||||
err = bs.Write(wbuf, int64(offset))
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
key = MEDIUM_ERROR
|
||||
asc = ASC_READ_ERROR
|
||||
goto sense
|
||||
}
|
||||
glog.V(2).Infof("write data at %d for length %d", offset, len(wbuf))
|
||||
log.Debugf("write data at %d for length %d", offset, len(wbuf))
|
||||
var pg *api.ModePage
|
||||
for _, p := range lu.ModePages {
|
||||
if p.PageCode == 0x08 && p.SubPageCode == 0 {
|
||||
@@ -181,11 +181,11 @@ verify:
|
||||
bs.DataAdvise(int64(offset), int64(length), util.POSIX_FADV_WILLNEED)
|
||||
}
|
||||
}
|
||||
glog.Infof("io done %s", string(scb))
|
||||
log.Infof("io done %s", string(scb))
|
||||
return nil
|
||||
sense:
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/gostor/gotgt/pkg/scsi"
|
||||
"github.com/gostor/gotgt/pkg/util"
|
||||
@@ -97,7 +97,7 @@ func (bs *FileBackingStore) Read(offset, tl int64) ([]byte, error) {
|
||||
func (bs *FileBackingStore) Write(wbuf []byte, offset int64) error {
|
||||
length, err := bs.file.WriteAt(wbuf, offset)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
if length != len(wbuf) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"encoding/binary"
|
||||
"unsafe"
|
||||
|
||||
"github.com/golang/glog"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/gostor/gotgt/pkg/util"
|
||||
"github.com/gostor/gotgt/pkg/version"
|
||||
@@ -331,7 +331,7 @@ func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
if dev.Attrs.Removable && !dev.Attrs.Online {
|
||||
key = NOT_READY
|
||||
asc = ASC_MEDIUM_NOT_PRESENT
|
||||
glog.Warningf("sense")
|
||||
log.Warnf("sense")
|
||||
goto sense
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
if scb[1]&0xe0 != 0 {
|
||||
key = ILLEGAL_REQUEST
|
||||
asc = ASC_INVALID_FIELD_IN_CDB
|
||||
glog.Warningf("sense")
|
||||
log.Warnf("sense")
|
||||
goto sense
|
||||
}
|
||||
*/
|
||||
@@ -384,7 +384,7 @@ func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
api.PRE_FETCH_10, api.PRE_FETCH_16, api.COMPARE_AND_WRITE:
|
||||
key = DATA_PROTECT
|
||||
asc = ASC_WRITE_PROTECT
|
||||
glog.Warningf("sense")
|
||||
log.Warnf("sense")
|
||||
goto sense
|
||||
}
|
||||
}
|
||||
@@ -397,14 +397,14 @@ func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
if lba+uint64(tl) < lba || lba+uint64(tl) > dev.Size>>dev.BlockShift {
|
||||
key = ILLEGAL_REQUEST
|
||||
asc = ASC_LBA_OUT_OF_RANGE
|
||||
glog.Warningf("sense: lba: %d, tl: %d, size: %d", lba, tl, dev.Size>>dev.BlockShift)
|
||||
log.Warnf("sense: lba: %d, tl: %d, size: %d", lba, tl, dev.Size>>dev.BlockShift)
|
||||
goto sense
|
||||
}
|
||||
} else {
|
||||
if lba >= dev.Size>>dev.BlockShift {
|
||||
key = ILLEGAL_REQUEST
|
||||
asc = ASC_LBA_OUT_OF_RANGE
|
||||
glog.Warningf("sense")
|
||||
log.Warnf("sense")
|
||||
goto sense
|
||||
}
|
||||
}
|
||||
@@ -437,7 +437,7 @@ func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
|
||||
err = bsPerformCommand(dev.Storage, cmd)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
key = HARDWARE_ERROR
|
||||
asc = ASC_INTERNAL_TGT_FAILURE
|
||||
} else {
|
||||
@@ -563,14 +563,14 @@ func SBCVerify(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
if lba+uint64(tl) < lba || lba+uint64(tl) > dev.Size>>dev.BlockShift {
|
||||
key = ILLEGAL_REQUEST
|
||||
asc = ASC_LBA_OUT_OF_RANGE
|
||||
glog.Warningf("sense: lba: %d, tl: %d, size: %d", lba, tl, dev.Size>>dev.BlockShift)
|
||||
log.Warnf("sense: lba: %d, tl: %d, size: %d", lba, tl, dev.Size>>dev.BlockShift)
|
||||
goto sense
|
||||
}
|
||||
} else {
|
||||
if lba >= dev.Size>>dev.BlockShift {
|
||||
key = ILLEGAL_REQUEST
|
||||
asc = ASC_LBA_OUT_OF_RANGE
|
||||
glog.Warningf("sense")
|
||||
log.Warnf("sense")
|
||||
goto sense
|
||||
}
|
||||
}
|
||||
@@ -579,7 +579,7 @@ func SBCVerify(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
cmd.TL = tl << dev.BlockShift
|
||||
err = bsPerformCommand(dev.Storage, cmd)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
key = HARDWARE_ERROR
|
||||
asc = ASC_INTERNAL_TGT_FAILURE
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/golang/glog"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/satori/go.uuid"
|
||||
)
|
||||
@@ -80,21 +80,21 @@ func (s *SCSITargetService) AddCommandQueue(tid int, scmd *api.SCSICommand) erro
|
||||
lun := *(*uint64)(unsafe.Pointer(&scmd.Lun))
|
||||
scmd.Device = target.Devices[lun]
|
||||
|
||||
glog.V(2).Infof("scsi opcode: 0x%x, LUN: %d", int(scmd.SCB.Bytes()[0]), binary.LittleEndian.Uint64(scmd.Lun[:]))
|
||||
log.Debugf("scsi opcode: 0x%x, LUN: %d", int(scmd.SCB.Bytes()[0]), binary.LittleEndian.Uint64(scmd.Lun[:]))
|
||||
|
||||
if scmd.Device == nil {
|
||||
scmd.Device = target.LUN0
|
||||
if lun != 0 {
|
||||
BuildSenseData(scmd, ILLEGAL_REQUEST, ASC_INVALID_FIELD_IN_CDB)
|
||||
scmd.Result = api.SAMStatCheckCondition.Stat
|
||||
glog.Warningf("%v", api.SAMStatCheckCondition.Err)
|
||||
log.Warnf("%v", api.SAMStatCheckCondition.Err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
result := scmd.Device.PerformCommand(tid, scmd)
|
||||
if result != api.SAMStatGood {
|
||||
scmd.Result = result.Stat
|
||||
glog.Warningf("%v", result.Err)
|
||||
log.Warnf("%v", result.Err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -162,7 +162,7 @@ func BuildSenseData(cmd *api.SCSICommand, key byte, asc SCSISubError) {
|
||||
senseBuffer.Truncate(int(inBufLen))
|
||||
}
|
||||
} else {
|
||||
glog.V(2).Infof("cannot calc cbd alloc length. truncate failed")
|
||||
log.Debugf("cannot calc cbd alloc length. truncate failed")
|
||||
}
|
||||
cmd.Result = key
|
||||
cmd.SenseBuffer = senseBuffer
|
||||
|
||||
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package scsi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
@@ -75,7 +75,7 @@ func InitSCSILUMap(config *config.Config) error {
|
||||
for _, bs := range config.Storages {
|
||||
lu, err := NewSCSILu(bs.DeviceID, bs.Path, bs.Online)
|
||||
if err != nil {
|
||||
return errors.New("Init SCSI LU map error.")
|
||||
return fmt.Errorf("Init SCSI LU map error: %v", err)
|
||||
}
|
||||
globalSCSILUMap.AllDevices[bs.DeviceID] = lu
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func InitSCSILUMap(config *config.Config) error {
|
||||
for lunstr, deviceID := range tgt.LUNs {
|
||||
lun, err := strconv.ParseUint(lunstr, 10, 64)
|
||||
if err != nil {
|
||||
return errors.New("LU Number must be a number")
|
||||
return fmt.Errorf("LU Number must be a number")
|
||||
}
|
||||
mappingLUN(deviceID, lun, tgtName)
|
||||
// Init SCSISimpleReservationOperator
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/gostor/gotgt/pkg/util"
|
||||
"github.com/satori/go.uuid"
|
||||
@@ -341,7 +341,7 @@ func SPCReportLuns(host int, cmd *api.SCSICommand) api.SAMStat {
|
||||
// Get Allocation Length
|
||||
allocationLength = util.GetUnalignedUint32(scb.Bytes()[6:10])
|
||||
if allocationLength < 16 {
|
||||
glog.Warningf("goto sense, allocationLength < 16")
|
||||
log.Warn("goto sense, allocationLength < 16")
|
||||
goto sense
|
||||
}
|
||||
|
||||
@@ -577,24 +577,24 @@ func SPCReportSupportedOperationCodes(host int, cmd *api.SCSICommand) api.SAMSta
|
||||
rsa := util.GetUnalignedUint16(scb[4:])
|
||||
switch reporting_options {
|
||||
case 0x00: /* report all */
|
||||
glog.V(3).Infof("Service Action: report all")
|
||||
log.Debugf("Service Action: report all")
|
||||
err := reportOpcodesAll(cmd, rctd)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
goto sense
|
||||
}
|
||||
case 0x01: /* report one no service action*/
|
||||
glog.V(3).Infof("Service Action: report one no service action")
|
||||
log.Debugf("Service Action: report one no service action")
|
||||
err := reportOpcodeOne(cmd, rctd, opcode, rsa, false)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
goto sense
|
||||
}
|
||||
case 0x02: /* report one service action */
|
||||
glog.V(3).Infof("Service Action: report one service action")
|
||||
log.Debugf("Service Action: report one service action")
|
||||
err := reportOpcodeOne(cmd, rctd, opcode, rsa, true)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
log.Error(err)
|
||||
goto sense
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/golang/glog"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/satori/go.uuid"
|
||||
)
|
||||
@@ -97,12 +97,12 @@ func deviceReserve(cmd *api.SCSICommand) error {
|
||||
}
|
||||
}
|
||||
if lu == nil {
|
||||
glog.Errorf("invalid target and lun %d %s", cmd.Target.TID, lun)
|
||||
log.Errorf("invalid target and lun %d %s", cmd.Target.TID, lun)
|
||||
return nil
|
||||
}
|
||||
|
||||
if !uuid.Equal(lu.ReserveID, uuid.Nil) && uuid.Equal(lu.ReserveID, cmd.ITNexusID) {
|
||||
glog.Errorf("already reserved %d, %d", lu.ReserveID, cmd.ITNexusID)
|
||||
log.Errorf("already reserved %d, %d", lu.ReserveID, cmd.ITNexusID)
|
||||
return fmt.Errorf("already reserved")
|
||||
}
|
||||
lu.ReserveID = cmd.ITNexusID
|
||||
|
||||
Reference in New Issue
Block a user