Implement InitSCSILuMap func for jiva

Signed-off-by: Utkarsh Mani Tripathi <utkarsh.tripathi@mayadata.io>
This commit is contained in:
Utkarsh Mani Tripathi
2019-11-19 10:19:58 +05:30
parent 1b02c7897e
commit d7caf89610
6 changed files with 21 additions and 15 deletions

View File

@@ -24,6 +24,10 @@ import (
log "github.com/sirupsen/logrus"
)
var (
Size uint64
)
func init() {
scsi.RegisterBackingStore("RemBs", newRemBs)
}
@@ -33,7 +37,7 @@ type RemBackingStore struct {
scsi.BaseBackingStore
// Remote backing store, remote server exposing
// read and write methods.
RemBs api.RemBackingStore
RemBs api.RemoteBackingStore
}
func newRemBs() (api.BackingStore, error) {
@@ -46,7 +50,11 @@ func newRemBs() (api.BackingStore, 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)
return nil
}
@@ -102,6 +110,6 @@ func (bs *RemBackingStore) DataSync(offset, length int64) (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
}