longhorn/enhancements/20230309-recurring-filesystem-trim.md
Chin-Ya Huang f82928c33e feat(lep): recurring filesystem trim design
Ref: 5186

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
2023-03-15 17:34:48 +08:00

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.

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

  1. The user sees workload volume size has increased over time.
  2. 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
    
  3. The RecurringJob runs and relaims some volume spaces.

API changes

None

Design

Implementation Overview

The RecurringJob filesystem-trim Task Type

  1. Call Volume API ActionTrimFilesystem when the RecurringJob type is filesystem-trim.

RecurringJob Mutate

  1. Mutate the Recurringjob.Spec.Retain to 0 when the task type is filesystem-trim as it is not effective for this type of task.

Test plan

Test Recurring Filesystem Trim

  1. Create workload.
  2. Create a file with some data in the workload.
  3. Volume actual size should increase.
  4. Delete the file.
  5. Volume actual size should not decrease.
  6. Create RecurringJob with type filesystem-trim and assign to the workload volume.
  7. Wait for RecurringJob to complete.
  8. Volume actual size should decrease.

Upgrade strategy

None

Note [optional]

None