enable UNMAP when LUN is thin provisioned

- support Block Limits VPD page (0xB0)
 - add UNMAP to REPORT SUPPORTED OPERATION CODES
 - READ CAPACITY(16): set LBPME when Thin provisioning is enabled
 - move Thinprovisioning and BlockShift to config
 - add Unmap to BackingStore
This commit is contained in:
chessman
2019-05-21 12:54:55 +03:00
parent e2192b7b01
commit 22d47a9212
10 changed files with 86 additions and 17 deletions
+7 -6
View File
@@ -20,13 +20,13 @@ import (
"strings"
"github.com/gostor/gotgt/pkg/api"
"github.com/gostor/gotgt/pkg/config"
)
// NewSCSILu: create a new SCSI LU
// path format <protocol>:/absolute/file/path
func NewSCSILu(device_uuid uint64, path string, online bool) (*api.SCSILu, error) {
pathinfo := strings.SplitN(path, ":", 2)
func NewSCSILu(bs *config.BackendStorage) (*api.SCSILu, error) {
pathinfo := strings.SplitN(bs.Path, ":", 2)
if len(pathinfo) < 2 {
return nil, errors.New("invalid device path string")
}
@@ -43,8 +43,8 @@ func NewSCSILu(device_uuid uint64, path string, online bool) (*api.SCSILu, error
PerformCommand: luPerformCommand,
DeviceProtocol: sbc,
Storage: backing,
BlockShift: api.DefaultBlockShift,
UUID: device_uuid,
BlockShift: bs.BlockShift,
UUID: bs.DeviceID,
}
err = backing.Open(lu, backendPath)
@@ -53,7 +53,8 @@ func NewSCSILu(device_uuid uint64, path string, online bool) (*api.SCSILu, error
}
lu.Size = backing.Size(lu)
lu.DeviceProtocol.InitLu(lu)
lu.Attrs.Online = online
lu.Attrs.Thinprovisioning = bs.Thinprovisioning
lu.Attrs.Online = bs.Online
lu.Attrs.Lbppbe = 3
return lu, nil
}