Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incusd/storage/drivers: Force blkdiscard and ignore errors #1513

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

@breml breml Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the err at least be logged just in case? Debugging issues without any trace on what went wrong could be pretty difficult.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True that could be useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make it a debug level event but not anything more visible than that as this code path is hit quite often.

} else {
// Otherwise truncate the file.
err = disk.Truncate(0)
Expand Down
Loading