Skip to content

Commit

Permalink
Merge pull request #1513 from stgraber/main
Browse files Browse the repository at this point in the history
incusd/storage/drivers: Force blkdiscard and ignore errors
  • Loading branch information
stgraber authored Dec 16, 2024
2 parents e8aa69d + 3f4b221 commit eb1d537
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/server/storage/drivers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,12 +966,9 @@ func clearDiskData(diskPath string, disk *os.File) error {
}

if linux.IsBlockdev(st.Mode()) {
// If dealing with a block device, discard its current content.
// If dealing with a block device, attempt to discard its current content.
// This saves space and avoids issues with leaving zero blocks to their original value.
_, err = subprocess.RunCommand("blkdiscard", diskPath)
if err != nil {
return err
}
_, _ = subprocess.RunCommand("blkdiscard", "-f", diskPath)
} else {
// Otherwise truncate the file.
err = disk.Truncate(0)
Expand Down

0 comments on commit eb1d537

Please sign in to comment.