Lightbits TRIM Support
The Lightbits TRIM feature allows filesystems to reclaim unused storage space by issuing commands to the storage system (called trim/discard operations). Lightbits handles trim/discard operations issued by the filesystem on its volumes. Combined with Lightbits’ thin provisioning capabilities, this improves storage performance and capacity efficiency.
For instance, the 'fstrim' operation on an XFS filesystem mounted on a Lightbits volume can reduce storage utilization (reduce volume usage size), when invoked with the TRIM feature enabled.
Lightbits has implemented the NVMe deallocate as specified in the NVMe command set specification, to improve capacity utilization and planning. This capability works with the TRIM command, allowing the operating system to inform Lightbits about unused data blocks. For more information, refer to sections 3.3.3 and 3.3.3.2.1 of the NVMe command set specification.
When the OS deletes a file and sends a TRIM command, it is translated to an NVMe dataset management deallocate command on the client side. Lightbits receives this deallocate command and manages the information internally within its software, behaving as if the data was deallocated. This approach enables more efficient capacity utilization and garbage collection - and improves write performance and endurance.
High-Level Workflow
Configuring the TRIM Feature on the Lightbits Cluster
The TRIM feature must be enabled for 3.16 installations. For existing deployments, upgrade to 3.16 and perform the following steps to enable the TRIM feature.
Once enabled, this feature cannot be disabled.
Enable the feature with this command:
> lbcli update cluster-config --parameter=EnableTrim --value=true
- Enabling TRIM does not automatically reclaim space from previously deleted data on existing volumes. To initiate space reclamation on existing volumes after enabling TRIM, refer to the instructions in the Best Practices section below.
- It is not necessary to restart Node Manager. The feature can be enabled by invoking an API (after the upgrade).
- In version 3.16.1, lbcli list feature-flags will always show trim as false. Use lbcli list cluster-config to get its status.
Viewing Reduced Storage Using TRIM
This example details the complete process of enabling TRIM, creating and deleting files, and viewing its effects on storage usage.
- Create a Lightbits volume and set up the filesystem:
> lbcli create volume --project-name=default --name="test" --acl="test" --replica-count=3 --size=1G
#On the client machine
> discovery-client add-hostnqn -a 10.20.59.4:8009 -n nqn.2016-01.com.lightbitslabs:uuid:4f47dd3a-4dc8-439a-ad46-bed23e1bbdba:suffix -q test --name dummy.txt
> nvme list
… /dev/nvme0n1 6842f8294caf4216 Lightbits LightOS 1 1.00 GB / 1.00 GB 4 KiB + 0 B 3.10 …
> mkfs.xfs /dev/nvme0n1
> mkdir /tmp/my_test_fs
> mount /dev/nvme0n1 /tmp/my_test_fs
- Check the initial storage usage:
> lbcli list nodes
- Use the dd command to create a ~0.5GB file (or 0.5GB per replica/node):
# On the client machine
> dd if=/dev/random of=/tmp/my_test_fs/my_file.bin bs=1M count=500
- Wait approximately one minute, and then check the storage usage:
> lbcli list nodes
Note the increase in used storage.
- Delete the file:
# On the client machine
> rm /tmp/my_test_fs/my_file.bin
- Check the storage usage again:
> lbcli list nodes
Note that the used storage has not decreased yet.
- Enable the TRIM feature on the Lightbits cluster:
> lbcli update cluster-config --parameter=EnableTrim --value=true
- Verify that the TRIM feature is set to “true”:
> lbcli list cluster-config
Cluster Config Parameter Value
AllowedNumRevives 2
ClockDriftIntervalForRaisingEvent 24h0m0s
ClusterName 41bcae54-1906-54a4-99bc-28a3e70fcaf9
DefaultQoSName no-limit-policy
DeviceHealthIntervalForRaisingEvent 24h0m0s
DisableVolumeStatisticsExport false
DurationToTurnIntoPermanentFailure 4h0m0s
EnableTrim true
EvictionNoProgressTimeout 1h0m0s
RevivesWindowDuration 2h0m0s
VolumeDeletionFromNodeDelay 30s
- Set up and run fstrim.timer on the client machine:
> sudo systemctl enable fstrim.timer
> sudo systemctl start fstrim.timer
# Verify the timer status
> sudo systemctl status fstrim.timer
- Manually trigger a TRIM operation to see its immediate effects:
> sudo systemctl start fstrim.service
- Wait approximately one minute, and then check the updated storage usage:
> lbcli list nodes
You should now see a reduction in the "used" storage, indicating that the TRIM operations have successfully reclaimed space.
Example Output:
> lbcli list nodes
Name UUID State NVMe endpoint Failure domains Capacity Used Local rebuild progress
server00-0 36469d85-0001-5a22-80b0-72f1d339f250 Active 10.20.59.4:4420 [rack06-server70-vm02 ser...] 7.0 GiB 536 MiB None
server01-0 2fb1c01b-b4b6-573c-a320-4295372e55d8 Active 10.20.59.5:4420 [rack06-server64-vm05 ser...] 7.0 GiB 536 MiB None
server02-0 a0625c8f-eccb-56f4-80d3-b95a836085a0 Active 10.20.59.7:4420 [rack05-server74-vm05 ser...] 7.0 GiB 536 MiB None
- To verify that TRIM is working on an ongoing basis:
Create another test file:
# On the client machine
> dd if=/dev/random of=/tmp/my_test_fs/another_file.bin bs=1M count=300
Check the storage usage:
> lbcli list nodes
Delete the file:
# On the client machine
> rm /tmp/my_test_fs/another_file.bin
Wait for the next scheduled TRIM operation (or trigger it manually), and then check the storage usage again:
> lbcli list nodes
Name UUID State NVMe endpoint Failure domains Capacity Used Local rebuild progress
server00-0 36469d85-0001-5a22-80b0-72f1d339f250 Active 10.20.59.4:4420 [rack06-server70-vm02 ser...] 7.0 GiB 32 MiB None
server01-0 2fb1c01b-b4b6-573c-a320-4295372e55d8 Active 10.20.59.5:4420 [rack06-server64-vm05 ser...] 7.0 GiB 32 MiB None
server02-0 a0625c8f-eccb-56f4-80d3-b95a836085a0 Active 10.20.59.7:4420 [rack05-server74-vm05 ser...] 7.0 GiB 32 MiB None
TRIM Operations - Best Practices
Initial Setup After Enabling TRIM
- Enable TRIM on the Lightbits cluster:
> lbcli update cluster-config --parameter=EnableTrim --value=true
- On each client machine, set up fstrim.timer:
> sudo systemctl enable fstrim.timer
> sudo systemctl start fstrim.timer
- Verify the timer status:
> sudo systemctl status fstrim.timer
- Run an initial manual TRIM to reclaim space from previously-deleted data:
> sudo systemctl start fstrim.service
Regular Maintenance
- Periodically check the status of fstrim.timer:
> sudo systemctl status fstrim.timer
- Monitor the storage usage after TRIM operations:
> lbcli list nodes
- If the storage is not being reclaimed as expected, manually trigger TRIM:
> sudo systemctl start fstrim.service
Customizing the TRIM Schedule
If a weekly schedule is not suitable, customize the TRIM schedule as follows on every client machine.
- Create a custom timer file:
> sudo systemctl edit fstrim.timer
- Add your custom schedule. For example, to run it daily:
[Timer]
OnCalendar=daily
- Save the file and reload the systemd daemon:
> sudo systemctl daemon-reload
- Restart the timer:
> sudo systemctl restart fstrim.timer
Avoiding Continuous TRIM
Do not use the -o discard mount option for filesystems on Linux, as it can significantly impact filesystem performance.
Red Hat does not recommend using Continuous TRIM. See the relevant Red Hat documentation for additional information.
TRIM Troubleshooting
If TRIM is not working:
Verify that it is enabled on the Lightbits cluster:
> lbcli get cluster-config
Check the fstrim.timer status on the client:
> sudo systemctl status fstrim.timer
Review the system logs for any TRIM-related errors:
> sudo journalctl | grep fstrim
If these or other issues persist, contact Lightbits Customer Success for assistance.