Skip to content

Commit

Permalink
lxd/storage/drivers/powerflex: Wait for disk resize before moving GPT…
Browse files Browse the repository at this point in the history
… table

Co-authored-by: Julian Pelizäus <[email protected]>
Signed-off-by: Din Music <[email protected]>
  • Loading branch information
MusicDin and roosterfish committed Jan 21, 2025
1 parent 6e841f0 commit 2bd6ccd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lxd/storage/drivers/driver_powerflex_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,13 @@ func (d *powerflex) SetVolumeQuota(vol Volume, size string, allowUnsafeResize bo
return err
}

// Ensure the block device size is correctly reflected on the attached volume
// before growing the file system.
err = block.WaitDiskSizeBytes(d.state.ShutdownCtx, devPath, sizeBytes)
if err != nil {
return fmt.Errorf("Disk device did not resize to the expected size: %w", err)
}

// Grow the filesystem to fill block device.
err = growFileSystem(fsType, devPath, vol)
if err != nil {
Expand All @@ -625,6 +632,14 @@ func (d *powerflex) SetVolumeQuota(vol Volume, size string, allowUnsafeResize bo
// Move the VM GPT alt header to end of disk if needed (not needed in unsafe resize mode as it is
// expected the caller will do all necessary post resize actions themselves).
if vol.IsVMBlock() && !allowUnsafeResize {
// The resize happens on PowerFlex, but it is not immediately reflected
// on the host system, which may result in GPT table not being moved to
// an actual end. Therefore, wait for the resize to complete.
err = block.WaitDiskSizeBytes(d.state.ShutdownCtx, devPath, sizeBytes)
if err != nil {
return fmt.Errorf("Disk device did not resize to the expected size: %w", err)
}

err = d.moveGPTAltHeader(devPath)
if err != nil {
return err
Expand Down

0 comments on commit 2bd6ccd

Please sign in to comment.