Implement InitSCSILuMap func for jiva
Signed-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>
This commit is contained in:
@@ -397,6 +397,9 @@ type SCSILu struct {
|
|||||||
Storage BackingStore
|
Storage BackingStore
|
||||||
DeviceProtocol SCSIDeviceProtocol
|
DeviceProtocol SCSIDeviceProtocol
|
||||||
ModeBlockDescriptor []byte
|
ModeBlockDescriptor []byte
|
||||||
|
SCSIVendorID string
|
||||||
|
SCSIProductID string
|
||||||
|
SCSIID string
|
||||||
|
|
||||||
PerformCommand CommandFunc
|
PerformCommand CommandFunc
|
||||||
FinishCommand func(*SCSITarget, *SCSICommand)
|
FinishCommand func(*SCSITarget, *SCSICommand)
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ func (s *ISCSITargetDriver) Run() error {
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.l = l
|
s.l = l
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
log.Infof("iSCSI service listening on: %v", s.listen.Addr())
|
log.Infof("iSCSI service listening on: %v", s.l.Addr())
|
||||||
for {
|
for {
|
||||||
conn, err := l.Accept()
|
conn, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Size uint64
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
scsi.RegisterBackingStore("RemBs", newRemBs)
|
scsi.RegisterBackingStore("RemBs", newRemBs)
|
||||||
}
|
}
|
||||||
@@ -33,7 +37,7 @@ type RemBackingStore struct {
|
|||||||
scsi.BaseBackingStore
|
scsi.BaseBackingStore
|
||||||
// Remote backing store, remote server exposing
|
// Remote backing store, remote server exposing
|
||||||
// read and write methods.
|
// read and write methods.
|
||||||
RemBs api.RemBackingStore
|
RemBs api.RemoteBackingStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRemBs() (api.BackingStore, error) {
|
func newRemBs() (api.BackingStore, error) {
|
||||||
@@ -46,7 +50,11 @@ func newRemBs() (api.BackingStore, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bs *RemBackingStore) Open(dev *api.SCSILu, path string) error {
|
func (bs *RemBackingStore) Open(dev *api.SCSILu, path string) error {
|
||||||
bs.DataSize = uint64(dev.Size)
|
if Size == 0 {
|
||||||
|
return fmt.Errorf("Size is not initialized")
|
||||||
|
}
|
||||||
|
|
||||||
|
bs.DataSize = Size
|
||||||
bs.RemBs = scsi.GetTargetBSMap(path)
|
bs.RemBs = scsi.GetTargetBSMap(path)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -102,6 +110,6 @@ func (bs *RemBackingStore) DataSync(offset, length int64) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bs *RemBackingStore) Unmap(bd []api.UnmapBlockDescriptor) (err error) {
|
func (bs *RemBackingStore) Unmap(bd []api.UnmapBlockDescriptor) (err error) {
|
||||||
_, err = bs.RemBs.Unmap()
|
_, err = bs.RemBs.Unmap(int64(bd[0].Offset), int64(bd[0].TL))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ const (
|
|||||||
const (
|
const (
|
||||||
SCSIVendorID = "GOSTOR"
|
SCSIVendorID = "GOSTOR"
|
||||||
SCSIProductID = "GOTGT"
|
SCSIProductID = "GOTGT"
|
||||||
|
SCSIID = "iqn.2016-09.com.gotgt.gostor:iscsi-tgt"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (sbc SBCSCSIDeviceProtocol) InitLu(lu *api.SCSILu) error {
|
|||||||
leave it with a default target name
|
leave it with a default target name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lu.Attrs.SCSIID = "iqn.2016-09.com.gotgt.gostor:iscsi-tgt"
|
lu.Attrs.SCSIID = SCSIID
|
||||||
/*
|
/*
|
||||||
The PRODUCT SERIAL NUMBER field contains
|
The PRODUCT SERIAL NUMBER field contains
|
||||||
right-aligned ASCII data (see 4.3.1)
|
right-aligned ASCII data (see 4.3.1)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ func InitSCSILUMap(config *config.Config) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitSCSILUMapEx(tgtName, devpath string, deviceID, lun, size, sectorSize uint64, bs api.RemoteBackingStore) error {
|
func InitSCSILUMapEx(config *config.BackendStorage, tgtName string, lun uint64, bs api.RemoteBackingStore) error {
|
||||||
globalSCSILUMap.mutex.Lock()
|
globalSCSILUMap.mutex.Lock()
|
||||||
defer globalSCSILUMap.mutex.Unlock()
|
defer globalSCSILUMap.mutex.Unlock()
|
||||||
|
|
||||||
@@ -156,20 +156,14 @@ func InitSCSILUMapEx(tgtName, devpath string, deviceID, lun, size, sectorSize ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
globalSCSILUMap.TargetsBSMap[tgtName] = bs
|
globalSCSILUMap.TargetsBSMap[tgtName] = bs
|
||||||
|
lu, err := NewSCSILu(config)
|
||||||
lu, err := NewSCSILu(&config.BackendStorage{
|
|
||||||
DeviceID: deviceID,
|
|
||||||
Path: "RemBs:" + devpath,
|
|
||||||
Online: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Init SCSI LU map error.")
|
return errors.New("Init SCSI LU map error.")
|
||||||
}
|
}
|
||||||
globalSCSILUMap.AllDevices[deviceID] = lu
|
globalSCSILUMap.AllDevices[config.DeviceID] = lu
|
||||||
|
|
||||||
mappingLUN(LUNMapping{
|
mappingLUN(LUNMapping{
|
||||||
DeviceID: deviceID,
|
DeviceID: config.DeviceID,
|
||||||
LUN: lun,
|
LUN: lun,
|
||||||
TargetName: tgtName,
|
TargetName: tgtName,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user