We no longer pass "pool" anywhere that uses byHash() per the last
commit, so we can now remove this hack.
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
| ... | ... |
@@ -658,19 +658,18 @@ func (devices *DeviceSet) deactivatePool() error {
|
| 658 | 658 |
func (devices *DeviceSet) deactivateDevice(hash string) error {
|
| 659 | 659 |
utils.Debugf("[devmapper] deactivateDevice(%s)", hash)
|
| 660 | 660 |
defer utils.Debugf("[devmapper] deactivateDevice END")
|
| 661 |
- var devname string |
|
| 662 |
- // FIXME: shouldn't we just register the pool into devices? |
|
| 663 |
- devname, err := devices.byHash(hash) |
|
| 664 |
- if err != nil {
|
|
| 665 |
- return err |
|
| 661 |
+ |
|
| 662 |
+ info := devices.Devices[hash] |
|
| 663 |
+ if info == nil {
|
|
| 664 |
+ return fmt.Errorf("Unknown device %s", hash)
|
|
| 666 | 665 |
} |
| 667 |
- devinfo, err := getInfo(devname) |
|
| 666 |
+ devinfo, err := getInfo(info.Name()) |
|
| 668 | 667 |
if err != nil {
|
| 669 | 668 |
utils.Debugf("\n--->Err: %s\n", err)
|
| 670 | 669 |
return err |
| 671 | 670 |
} |
| 672 | 671 |
if devinfo.Exists != 0 {
|
| 673 |
- if err := devices.removeDeviceAndWait(devname); err != nil {
|
|
| 672 |
+ if err := devices.removeDeviceAndWait(info.Name()); err != nil {
|
|
| 674 | 673 |
utils.Debugf("\n--->Err: %s\n", err)
|
| 675 | 674 |
return err |
| 676 | 675 |
} |
| ... | ... |
@@ -741,18 +740,18 @@ func (devices *DeviceSet) waitRemove(devname string) error {
|
| 741 | 741 |
// a) the device registered at <device_set_prefix>-<hash> is closed, |
| 742 | 742 |
// or b) the 1 second timeout expires. |
| 743 | 743 |
func (devices *DeviceSet) waitClose(hash string) error {
|
| 744 |
- devname, err := devices.byHash(hash) |
|
| 745 |
- if err != nil {
|
|
| 746 |
- return err |
|
| 744 |
+ info := devices.Devices[hash] |
|
| 745 |
+ if info == nil {
|
|
| 746 |
+ return fmt.Errorf("Unknown device %s", hash)
|
|
| 747 | 747 |
} |
| 748 | 748 |
i := 0 |
| 749 | 749 |
for ; i < 1000; i += 1 {
|
| 750 |
- devinfo, err := getInfo(devname) |
|
| 750 |
+ devinfo, err := getInfo(info.Name()) |
|
| 751 | 751 |
if err != nil {
|
| 752 | 752 |
return err |
| 753 | 753 |
} |
| 754 | 754 |
if i%100 == 0 {
|
| 755 |
- utils.Debugf("Waiting for unmount of %s: opencount=%d", devname, devinfo.OpenCount)
|
|
| 755 |
+ utils.Debugf("Waiting for unmount of %s: opencount=%d", hash, devinfo.OpenCount)
|
|
| 756 | 756 |
} |
| 757 | 757 |
if devinfo.OpenCount == 0 {
|
| 758 | 758 |
break |
| ... | ... |
@@ -760,26 +759,11 @@ func (devices *DeviceSet) waitClose(hash string) error {
|
| 760 | 760 |
time.Sleep(1 * time.Millisecond) |
| 761 | 761 |
} |
| 762 | 762 |
if i == 1000 {
|
| 763 |
- return fmt.Errorf("Timeout while waiting for device %s to close", devname)
|
|
| 763 |
+ return fmt.Errorf("Timeout while waiting for device %s to close", hash)
|
|
| 764 | 764 |
} |
| 765 | 765 |
return nil |
| 766 | 766 |
} |
| 767 | 767 |
|
| 768 |
-// byHash is a hack to allow looking up the deviceset's pool by the hash "pool". |
|
| 769 |
-// FIXME: it seems probably cleaner to register the pool in devices.Devices, |
|
| 770 |
-// but I am afraid of arcane implications deep in the devicemapper code, |
|
| 771 |
-// so this will do. |
|
| 772 |
-func (devices *DeviceSet) byHash(hash string) (devname string, err error) {
|
|
| 773 |
- if hash == "pool" {
|
|
| 774 |
- return devices.getPoolDevName(), nil |
|
| 775 |
- } |
|
| 776 |
- info := devices.Devices[hash] |
|
| 777 |
- if info == nil {
|
|
| 778 |
- return "", fmt.Errorf("hash %s doesn't exists", hash)
|
|
| 779 |
- } |
|
| 780 |
- return info.Name(), nil |
|
| 781 |
-} |
|
| 782 |
- |
|
| 783 | 768 |
func (devices *DeviceSet) Shutdown() error {
|
| 784 | 769 |
devices.Lock() |
| 785 | 770 |
defer devices.Unlock() |