Skip to content

Discard Support #5161

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

Closed

Conversation

LDagnachew
Copy link

@LDagnachew LDagnachew commented Apr 18, 2025

Opening this as a Draft PR, as I am still working on fully integrating unmap/fstrim/discard.

Changes

Expose discard feature bit

  • Added VIRTIO_BLK_F_DISCARD to the device’s advertised avail_features so guests can negotiate discard support

Extend RequestType enum

  • Introduced a new Discard variant and mapped VIRTIO_BLK_T_DISCARDRequestType::Discard in the request conversion

Update request parsing (Request::parse) in request.rs

  • Allowed Discard (alongside Flush) to skip the data descriptor
  • Enforced sector‑aligned length and bounds checks for Discard requests

Implement handle_discard backend

  • Created handle_discard(offset, len) to call fallocate() on the host file descriptor

Reason

Attempting to resolve Issue #2708

Next Steps

  • Checking for VIRTIO_BLK_F_DISCARD support.
  • Writing Unit & Integration Tests.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@LDagnachew
Copy link
Author

Also sorry for the insane amount of commits, I didn't add DCO signatures to two of my commits, so I had to rebase to amend my commit signatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant