lvmtrim
Hi,
Is there any tool for LVM like fstrim(8) (which would likely be called "lvmtrim") ?
http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/3695
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).
Regards.
Signature · 1 line
Yann Droneaud
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
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
Quoted 3 lines · Alasdair G Kergon
2) Add vgtrim (+man page) which takes VG-style arguments, uses
process_each_pv_in_vgwhich usesprocess_each_segment_in_pvwhich 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
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
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 ?
Orissue_discardswas 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