2.4 KiB
Recurring Filesystem Trim
Summary
Longhorn currently supports the filesystem trim feature, which allows users to reclaim volume disk spaces of deleted files. However, this is a manual process, which can be time-consuming and inconvenient.
To improve user experience, Longhorn could automate the process by implementing a new RecurringJob filesystem-trim
type. This enhancement enables regularly freeing up unused volume spaces and reducing the need for manual interventions.
Related Issues
https://github.com/longhorn/longhorn/issues/5186
Motivation
Goals
Introduce a new recurring job type called filesystem-trim
to periodically trim the volume filesystem to reclaim disk spaces.
Non-goals [optional]
None
Proposal
To extend the RecurringJob custom resource definition by adding new RecurringJobType: filesystem-trim
.
User Stories
To schedule regular volume filesystem trims, user can create a RecurringJob with spec.task=filesystem-trim
and associating it with volumes.
User Experience In Detail
Recurring Filesystem Trim
- The user sees workload volume size has increased over time.
- Create RecurringJob with the
filesystem-trim
task type and assign it to the volume.apiVersion: longhorn.io/v1beta2 kind: RecurringJob metadata: name: recurring-fs-trim-per-min namespace: longhorn-system spec: concurrency: 1 cron: '* * * * *' groups: [] labels: {} name: recurring-fs-trim-per-min retain: 0 task: filesystem-trim
- The RecurringJob runs and relaims some volume spaces.
API changes
None
Design
Implementation Overview
The RecurringJob filesystem-trim
Task Type
- Call Volume API
ActionTrimFilesystem
when the RecurringJob type isfilesystem-trim
.
RecurringJob Mutate
- Mutate the
Recurringjob.Spec.Retain
to 0 when the task type isfilesystem-trim
as it is not effective for this type of task.
Test plan
Test Recurring Filesystem Trim
- Create workload.
- Create a file with some data in the workload.
- Volume actual size should increase.
- Delete the file.
- Volume actual size should not decrease.
- Create RecurringJob with type
filesystem-trim
and assign to the workload volume. - Wait for RecurringJob to complete.
- Volume actual size should decrease.
Upgrade strategy
None
Note [optional]
None