Skip to content

[vminitd]: api for trim filesystem operations#700

Open
saehejkang wants to merge 4 commits into
apple:mainfrom
saehejkang:add-vminit-api-trim
Open

[vminitd]: api for trim filesystem operations#700
saehejkang wants to merge 4 commits into
apple:mainfrom
saehejkang:add-vminit-api-trim

Conversation

@saehejkang

Copy link
Copy Markdown
Contributor

Addition of vminitd API for trim filesystem operations

Closes #1402

Depends on #685

@saehejkang saehejkang force-pushed the add-vminit-api-trim branch 2 times, most recently from 012768d to 3824bae Compare May 3, 2026 02:32
@saehejkang saehejkang force-pushed the add-vminit-api-trim branch from 7cd8a36 to 76c7fd9 Compare June 2, 2026 05:22
@saehejkang saehejkang marked this pull request as ready for review June 2, 2026 05:23
@saehejkang

Copy link
Copy Markdown
Contributor Author

Kind of messy, as the work is added to the freeze/thaw filesystem PR, but ready for initial review

string error = 2; // Non-empty if stat failed.
}

message FiTrimParams {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For FITRIM I don't think we want a 1:1 mapping between the ioctl parameters and the vminit API parameters. At least for now, we want to trim the entire volume that path points to:

struct fstrim_range range = {
    .start = 0,
    .len = ULLONG_MAX,
    .minlen = 0,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What we want to build toward for this call is something where we define trim policies. For this PR, schedule could just contain OneShot, and we could add Recurring in a follow-up PR.

Once the one-shot operation is merged, you can implement a container clean command that runs one shot trim on the container root fs path, and the mount paths for each named volume.

Recurring would trim the named path periodically, with a duration of zero clearing a previously established schedule for the path.

Discussion topics once we get to the recurring trim policy include:

  • Should the call naively trim path, or should it infer the mount point such that callers don't inadvertently install multiple periodic trims that operate on the same mount?
  • Should there be a Params value that clears all previously established trim policies?
import "google/protobuf/duration.proto";

message FiTrimParams {
  oneof schedule {
    OneShot one_shot = 1;
    Recurring recurring = 2;
  }

  message OneShot {}

  message Recurring {
    google.protobuf.Duration interval = 1;
  }
}

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.

2 participants