RemovePool deactivates all child thin-devices and removes thin-pool device
(ctx context.Context)
| 584 | |
| 585 | // RemovePool deactivates all child thin-devices and removes thin-pool device |
| 586 | func (p *PoolDevice) RemovePool(ctx context.Context) error { |
| 587 | deviceNames, err := p.metadata.GetDeviceNames(ctx) |
| 588 | if err != nil { |
| 589 | return fmt.Errorf("can't query device names: %w", err) |
| 590 | } |
| 591 | |
| 592 | var result []error |
| 593 | |
| 594 | // Deactivate devices if any |
| 595 | for _, name := range deviceNames { |
| 596 | if err := p.DeactivateDevice(ctx, name, true, true); err != nil { |
| 597 | result = append(result, fmt.Errorf("failed to remove %q: %w", name, err)) |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | if err := dmsetup.RemoveDevice(p.poolName, dmsetup.RemoveWithForce, dmsetup.RemoveWithRetries, dmsetup.RemoveDeferred); err != nil { |
| 602 | result = append(result, fmt.Errorf("failed to remove pool %q: %w", p.poolName, err)) |
| 603 | } |
| 604 | |
| 605 | return errors.Join(result...) |
| 606 | } |
| 607 | |
| 608 | // MarkDeviceState changes the device's state in metastore |
| 609 | func (p *PoolDevice) MarkDeviceState(ctx context.Context, name string, state DeviceState) error { |