Skip to content

Commit

Permalink
fix(initiator): rename dmDeviceCleanupRequired to dmDeviceAndEndpoint…
Browse files Browse the repository at this point in the history
…CleanupRequired

dmDeviceAndEndpointCleanupRequired is for cleaning up both the dm device and the endpoint.

Longhorn 9032

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit authored and shuo-wu committed Jul 19, 2024
1 parent 3cdeed2 commit ed78c9b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/nvme/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ func (i *Initiator) replaceDmDeviceTarget() error {
}

// Start starts the NVMe initiator with the given transportAddress and transportServiceID
func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceCleanupRequired bool) (dmDeviceBusy bool, err error) {
func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceAndEndpointCleanupRequired bool) (dmDeviceBusy bool, err error) {
defer func() {
if err != nil {
err = errors.Wrapf(err, "failed to start NVMe initiator %s", i.Name)
}
}()

i.logger.WithFields(logrus.Fields{
"transportAddress": transportAddress,
"transportServiceID": transportServiceID,
"dmDeviceCleanupRequired": dmDeviceCleanupRequired,
"transportAddress": transportAddress,
"transportServiceID": transportServiceID,
"dmDeviceAndEndpointCleanupRequired": dmDeviceAndEndpointCleanupRequired,
})

i.logger.Info("Starting initiator")
Expand Down Expand Up @@ -273,7 +273,7 @@ func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceC
}

i.logger.Infof("Stopping NVMe initiator blindly before starting")
dmDeviceBusy, err = i.stopWithoutLock(dmDeviceCleanupRequired, false, false)
dmDeviceBusy, err = i.stopWithoutLock(dmDeviceAndEndpointCleanupRequired, false, false)
if err != nil {
return dmDeviceBusy, errors.Wrapf(err, "failed to stop the mismatching NVMe initiator %s before starting", i.Name)
}
Expand Down Expand Up @@ -322,7 +322,7 @@ func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceC
}

needMakeEndpoint := true
if dmDeviceCleanupRequired {
if dmDeviceAndEndpointCleanupRequired {
if dmDeviceBusy {
// Endpoint is already created, just replace the target device
needMakeEndpoint = false
Expand Down Expand Up @@ -356,7 +356,7 @@ func (i *Initiator) Start(transportAddress, transportServiceID string, dmDeviceC
return dmDeviceBusy, nil
}

func (i *Initiator) Stop(dmDeviceCleanupRequired, deferDmDeviceCleanup, errOnBusyDmDevice bool) (bool, error) {
func (i *Initiator) Stop(dmDeviceAndEndpointCleanupRequired, deferDmDeviceCleanup, errOnBusyDmDevice bool) (bool, error) {
if i.hostProc != "" {
lock := nsfilelock.NewLockWithTimeout(util.GetHostNamespacePath(i.hostProc), LockFile, LockTimeout)
if err := lock.Lock(); err != nil {
Expand All @@ -365,7 +365,7 @@ func (i *Initiator) Stop(dmDeviceCleanupRequired, deferDmDeviceCleanup, errOnBus
defer lock.Unlock()
}

return i.stopWithoutLock(dmDeviceCleanupRequired, deferDmDeviceCleanup, errOnBusyDmDevice)
return i.stopWithoutLock(dmDeviceAndEndpointCleanupRequired, deferDmDeviceCleanup, errOnBusyDmDevice)
}

func (i *Initiator) removeDmDeviceAndEndpoint(deferDmDeviceCleanup, errOnBusyDmDevice bool) (bool, error) {
Expand All @@ -384,9 +384,9 @@ func (i *Initiator) removeDmDeviceAndEndpoint(deferDmDeviceCleanup, errOnBusyDmD
return false, nil
}

func (i *Initiator) stopWithoutLock(dmDeviceCleanupRequired, deferDmDeviceCleanup, errOnBusyDmDevice bool) (bool, error) {
func (i *Initiator) stopWithoutLock(dmDeviceAndEndpointCleanupRequired, deferDmDeviceCleanup, errOnBusyDmDevice bool) (bool, error) {
dmDeviceBusy := false
if dmDeviceCleanupRequired {
if dmDeviceAndEndpointCleanupRequired {
var err error
dmDeviceBusy, err = i.removeDmDeviceAndEndpoint(deferDmDeviceCleanup, errOnBusyDmDevice)
if err != nil {
Expand Down

0 comments on commit ed78c9b

Please sign in to comment.