Skip to contentSkip to conversation

lvmtrim

linux-lvm Yann Droneaud 2 participants 6 messages Oct 19, 2011

lore
Share & tools
lore
#1 lore raw
Quoted 2 lines · Yann Droneaud

Is there any tool for LVM like fstrim(8) (which would likely be called "lvmtrim") ?

vgtrim

Quoted 3 lines

This tool would discard currently unused PE of an active VG like fstrim(8) is doing on ext4,btrfs,xfs blocks (depending on filesystem support).

Sounds a reasonable idea to me, although I question how the PEs that would benefit from it would have got into that state in the first place, given that lvreduce already has trim support if you had devices/issue_discards = 1 in your lvm.conf.

Alasdair

#2 lore raw
Quoted 1 line · Alasdair G Kergon

vgtrim

Suggested spec if someone wants to implement this:

1) factor out the discard code from release_pv_segment so it can be shared and used on existing segments too;

2) Add vgtrim (+man page) which takes VG-style arguments, uses process_each_pv_in_vg which uses process_each_segment_in_pv which checks if segment is free and if so calls the code from (1) to issue a discard on it.

Alasdair

#3 lore raw
Quoted 3 lines · Alasdair G Kergon

2) Add vgtrim (+man page) which takes VG-style arguments, uses process_each_pv_in_vg which uses process_each_segment_in_pv which checks if segment is free and if so calls the code from (1) to issue a discard on it.

Adding a new cmd involves:
create tools/vgtrim.c (e.g. use stripped down vgdisplay.c as template?)
Add to SOURCES in Makefile
Add section to commands.h (alphabetically)

Alasdair

#4 lore raw
In reply to Alasdair G Kergon
Quoted 6 lines · Alasdair G Kergon
Quoted 2 lines · Yann Droneaud

Is there any tool for LVM like fstrim(8) (which would likely be called "lvmtrim") ?

vgtrim

Quoted 9 lines
Quoted 3 lines

This tool would discard currently unused PE of an active VG like fstrim(8) is doing on ext4,btrfs,xfs blocks (depending on filesystem support).

Sounds a reasonable idea to me, although I question how the PEs that would benefit from it would have got into that state in the first place, given that lvreduce already has trim support if you had devices/issue_discards = 1 in your lvm.conf.

Perhaps when you forgot to discard/TRIM the whole SSD before re-using it in an active VG.

Perhaps in the case you're migrating from an older version of the LVM2 tools ?

Or issue_discards was set to 0.

Regards.

Signature · 1 line
Yann Droneaud
#5 lore raw
Quoted 5 lines · Yann Droneaud

Perhaps when you forgot to discard/TRIM the whole SSD before re-using it in an active VG.
Perhaps in the case you're migrating from an older version of the LVM2 tools ?
Or issue_discards was set to 0.

Indeed.

It's a simple tool to write, so I'm throwing it open to see if anyone wants to write and contribute it

Alasdair