Skip to content

Commit 6987264

Browse files
author
Lou
committed
update after review
Signed-off-by: Lou <[email protected]>
1 parent a11bd0f commit 6987264

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

iscsi/iscsi.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,31 @@ func DisconnectVolume(c Connector) error {
366366
//
367367
// DisconnectVolume focuses on step 2 and 3.
368368
// Note: make sure the volume is already unmounted before calling this method.
369+
370+
debug.Printf("Disconnecting volume in path %s.\n", c.DevicePath)
369371
if c.Multipath {
370-
err := Flush(c.DevicePath)
372+
debug.Printf("Removing multipath device.\n")
373+
err := FlushMultipathDevice(c.DevicePath)
371374
if err != nil {
372375
return err
373376
}
374377
devices, err := GetSysDevicesFromMultipathDevice(c.DevicePath)
375378
if err != nil {
376379
return err
377380
}
378-
return RemovePhysicalDevice(devices...)
381+
debug.Printf("Found multipath slaves %v, removing all of them.\n", devices)
382+
if err := RemovePhysicalDevice(devices...); err != nil {
383+
return err
384+
}
385+
} else {
386+
debug.Printf("Removing normal device.\n")
387+
if err := RemovePhysicalDevice(c.DevicePath); err != nil {
388+
return err
389+
}
379390
}
380-
return RemovePhysicalDevice(c.DevicePath)
391+
392+
debug.Printf("Finished disconnecting volume.\n")
393+
return nil
381394
}
382395

383396
// RemovePhysicalDevice removes device(s) sdx from a Linux host.
@@ -413,7 +426,7 @@ func RemovePhysicalDevice(devices ...string) error {
413426
if len(errs) > 0 {
414427
return errs[0]
415428
}
416-
debug.Println("Finshed to remove SCSI devices.")
429+
debug.Println("Finshed removing SCSI devices.")
417430
return nil
418431
}
419432

iscsi/multipath.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func GetSysDevicesFromMultipathDevice(device string) ([]string, error) {
6565
return s, nil
6666
}
6767

68-
// Flush flushes a multipath device dm-x with command multipath -f /dev/dm-x
69-
func Flush(device string) error {
68+
// FlushMultipathDevice flushes a multipath device dm-x with command multipath -f /dev/dm-x
69+
func FlushMultipathDevice(device string) error {
7070
debug.Printf("Flushing multipath device '%v'.\n", device)
7171

7272
fullDevice := filepath.Join(devPath, device)

0 commit comments

Comments
 (0)