From 82ae69682259efea190efc530739e91fb56bc60c Mon Sep 17 00:00:00 2001 From: Lei Xue Date: Mon, 28 Nov 2016 14:36:13 +0800 Subject: [PATCH] remove unnecessary code and doc --- README.md | 3 --- pkg/port/iscsit/cmd.go | 27 ++++++++++++++++++--------- pkg/port/iscsit/iscsit.go | 9 ++++++--- pkg/port/iscsit/portal.go | 25 ------------------------- pkg/port/iscsit/session.go | 25 ------------------------- pkg/scsi/cmd.go | 1 - pkg/scsi/lun.go | 2 +- pkg/scsi/scsi_pr.go | 16 ++++++++++++++++ pkg/scsi/scsilumap.go | 12 +++++++----- pkg/scsi/target.go | 2 +- 10 files changed, 49 insertions(+), 73 deletions(-) delete mode 100644 pkg/port/iscsit/portal.go diff --git a/README.md b/README.md index 67d64d0..4a017fd 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,6 @@ You can test this with [open-iscsi](http://www.open-iscsi.com/) or [libiscsi](ht * SCSI Command Queue (p2) * More SCSI commands * SPC3/SAM2 - * Page83(Inquiry) (orzhang, p1) - * Page0 (Inquiry) (orzhang, p1) - * Define Device UUID * Verify (carmark, p1) * Support `Target Group` and `Target Port` (p3) * Refactor (carmark, p1) diff --git a/pkg/port/iscsit/cmd.go b/pkg/port/iscsit/cmd.go index fc4a2de..727f2fb 100644 --- a/pkg/port/iscsit/cmd.go +++ b/pkg/port/iscsit/cmd.go @@ -67,18 +67,27 @@ type ISCSICommand struct { ExpCmdSN, MaxCmdSN uint32 AHSLen int - ConnID uint16 // Connection ID. - CmdSN uint32 // Command serial number. - ExpStatSN uint32 // Expected status serial. + // Connection ID. + ConnID uint16 + // Command serial number. + CmdSN uint32 + // Expected status serial. + ExpStatSN uint32 Read, Write bool LUN [8]uint8 - Transit bool // Transit bit. - Cont bool // Continue bit. - CSG, NSG Stage // Current Stage, Next Stage. - ISID uint64 // Initiator part of the SSID. - TSIH uint16 // Target-assigned Session Identifying Handle. - StatSN uint32 // Status serial number. + // Transit bit. + Transit bool + // Continue bit. + Cont bool + // Current Stage, Next Stage. + CSG, NSG Stage + // Initiator part of the SSID. + ISID uint64 + // Target-assigned Session Identifying Handle. + TSIH uint16 + // Status serial number. + StatSN uint32 // For login response. StatusClass uint8 diff --git a/pkg/port/iscsit/iscsit.go b/pkg/port/iscsit/iscsit.go index de18b35..9d7568e 100644 --- a/pkg/port/iscsit/iscsit.go +++ b/pkg/port/iscsit/iscsit.go @@ -70,15 +70,18 @@ type ISCSIRedirectInfo struct { } type iSCSITPGT struct { - TPGT uint16 /* Mapping to SCSI Reltive Target Port ID */ + // Mapping to SCSI Reltive Target Port ID + TPGT uint16 Portals map[string]struct{} } type ISCSITarget struct { api.SCSITarget api.SCSITargetDriverCommon - TPGTs map[uint16]*iSCSITPGT /* Key is a TPGT number */ - Sessions map[uint16]*ISCSISession /* Key is an TSIH */ + // TPGT number is the key + TPGTs map[uint16]*iSCSITPGT + // TSIH is the key + Sessions map[uint16]*ISCSISession SessionParam []ISCSISessionParam Alias string MaxSessions int diff --git a/pkg/port/iscsit/portal.go b/pkg/port/iscsit/portal.go deleted file mode 100644 index 679164a..0000000 --- a/pkg/port/iscsit/portal.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package iscsit - -type ISCSIPortal struct { - Address string - Port int - Tpgt int - Fd int - Af int -} diff --git a/pkg/port/iscsit/session.go b/pkg/port/iscsit/session.go index 88a2872..db6f593 100644 --- a/pkg/port/iscsit/session.go +++ b/pkg/port/iscsit/session.go @@ -192,31 +192,6 @@ func (tq *taskQueue) Pop() interface{} { return item } -// The BHS is 48 bytes long. The Opcode and DataSegmentLength fields -// appear in all iSCSI PDUs. In addition, when used, the Initiator Task -// Tag and Logical Unit Number always appear in the same location in the -// header. -type iscsiHeader struct { - opcode uint8 - flags uint8 // Final bit - rsvd2 [2]uint8 - hlength uint8 // AHSs total length - dlength [3]uint8 // Data length - lun [8]uint8 - itt uint8 // Initiator Task Tag - ttt uint8 // Target Task Tag - statsn uint8 - expStatSN uint8 - maxStatSN uint8 - other [12]uint8 -} - -type iscsiPdu struct { - bhs iscsiHeader - ahsSize uint - dataSize uint -} - // New creates a new session. func (s *ISCSITargetDriver) NewISCSISession(conn *iscsiConnection, isid uint64) (*ISCSISession, error) { var ( diff --git a/pkg/scsi/cmd.go b/pkg/scsi/cmd.go index 3ddb462..551e832 100644 --- a/pkg/scsi/cmd.go +++ b/pkg/scsi/cmd.go @@ -153,7 +153,6 @@ const ( * device type values are reserved for this peripheral qualifier. * 100b to 111b Vendor specific */ - const ( PQ_DEVICE_CONNECTED = byte(0x00 << 5) PQ_DEVICE_NOT_CONNECT = byte(0x01 << 5) diff --git a/pkg/scsi/lun.go b/pkg/scsi/lun.go index 564f7ef..9a381f4 100644 --- a/pkg/scsi/lun.go +++ b/pkg/scsi/lun.go @@ -87,7 +87,7 @@ func luPerformCommand(tid int, cmd *api.SCSICommand) api.SAMStat { fn := cmd.Device.DeviceProtocol.PerformCommand(op) if fn != nil { fnop := fn.(SCSIDeviceOperation) - // host := cmd.ITNexus.Host + // TODO host := cmd.ITNexus.Host host := 0 return fnop.CommandPerformFunc(host, cmd) } diff --git a/pkg/scsi/scsi_pr.go b/pkg/scsi/scsi_pr.go index 01749e0..3aade55 100644 --- a/pkg/scsi/scsi_pr.go +++ b/pkg/scsi/scsi_pr.go @@ -1,3 +1,19 @@ +/* +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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package scsi import ( diff --git a/pkg/scsi/scsilumap.go b/pkg/scsi/scsilumap.go index 08cea95..ec887ce 100644 --- a/pkg/scsi/scsilumap.go +++ b/pkg/scsi/scsilumap.go @@ -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. @@ -28,9 +28,11 @@ import ( type BackendType string type SCSILUMap struct { - mutex sync.RWMutex - AllDevices api.LUNMap /* use UUID as the key for all LUs*/ - TargetsLUNMap map[string]api.LUNMap /* use target name as the key for target's LUN map*/ + mutex sync.RWMutex + // use UUID as the key for all LUs + AllDevices api.LUNMap + // use target name as the key for target's LUN map + TargetsLUNMap map[string]api.LUNMap } var globalSCSILUMap = SCSILUMap{AllDevices: make(api.LUNMap), TargetsLUNMap: make(map[string]api.LUNMap)} @@ -85,7 +87,7 @@ func InitSCSILUMap(config *config.Config) error { return errors.New("LU Number must be a number") } mappingLUN(deviceID, lun, tgtName) - //Init SCSISimpleReservationOperator + // Init SCSISimpleReservationOperator op := GetSCSIReservationOperator() if simpleOp, ok = op.(*SCSISimpleReservationOperator); ok { simpleOp.InitLUReservation(tgtName, deviceID) diff --git a/pkg/scsi/target.go b/pkg/scsi/target.go index a1a7f30..b92893f 100644 --- a/pkg/scsi/target.go +++ b/pkg/scsi/target.go @@ -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.