File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -366,18 +366,31 @@ func DisconnectVolume(c Connector) error {
366
366
//
367
367
// DisconnectVolume focuses on step 2 and 3.
368
368
// Note: make sure the volume is already unmounted before calling this method.
369
+
370
+ debug .Printf ("Disconnecting volume in path %s.\n " , c .DevicePath )
369
371
if c .Multipath {
370
- err := Flush (c .DevicePath )
372
+ debug .Printf ("Removing multipath device.\n " )
373
+ err := FlushMultipathDevice (c .DevicePath )
371
374
if err != nil {
372
375
return err
373
376
}
374
377
devices , err := GetSysDevicesFromMultipathDevice (c .DevicePath )
375
378
if err != nil {
376
379
return err
377
380
}
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
+ }
379
390
}
380
- return RemovePhysicalDevice (c .DevicePath )
391
+
392
+ debug .Printf ("Finished disconnecting volume.\n " )
393
+ return nil
381
394
}
382
395
383
396
// RemovePhysicalDevice removes device(s) sdx from a Linux host.
@@ -413,7 +426,7 @@ func RemovePhysicalDevice(devices ...string) error {
413
426
if len (errs ) > 0 {
414
427
return errs [0 ]
415
428
}
416
- debug .Println ("Finshed to remove SCSI devices." )
429
+ debug .Println ("Finshed removing SCSI devices." )
417
430
return nil
418
431
}
419
432
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ func GetSysDevicesFromMultipathDevice(device string) ([]string, error) {
65
65
return s , nil
66
66
}
67
67
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 {
70
70
debug .Printf ("Flushing multipath device '%v'.\n " , device )
71
71
72
72
fullDevice := filepath .Join (devPath , device )
You can’t perform that action at this time.
0 commit comments