[linux-lvm] LVM & fstrim behaviour (Fedora 19)

Lukáš Czerner lczerner at redhat.com
Tue Sep 24 13:20:13 UTC 2013


On Tue, 17 Sep 2013, Jorge Fábregas wrote:

> Date: Tue, 17 Sep 2013 14:38:08 -0400
> From: Jorge Fábregas <jorge.fabregas at gmail.com>
> Reply-To: LVM general discussion and development <linux-lvm at redhat.com>
> To: linux-lvm at redhat.com
> Subject: [linux-lvm] LVM & fstrim behaviour (Fedora 19)
> 
> Hi,
> 
> I'm testing fstrim on an LVM volume but it only seems to work the first
> time I run it (just after mounting the volume).  When I run "fstrim -v
> /mnt" for the first time it prints all the free blocks that is trimming
> (almost all of the filesystem as it is empty) but subsequent runs just
> output "0 bytes trimmed" no matter how many files I create/sync & delete
> afterwards.  The "issue_discards" is set in lvm.conf.
> 
> If I do this over the raw device (/dev/sda3, same ext4 filesystem) I get
> the output corresponding to the last deleted files every time I run fstrim.
> 
> ## THIN ##
> 
> I also created a thin pool and a logical volume on that pool.  If I
> mount this volume with "discard", I can see that TRIM is working by
> doing an "lvs vgthin" (the Data Usage% grows as I create files & shrinks
> as I delete files).  However, If I mount it without the "discard" option
> (in order to use fstrim) I only see the data-usage reduction when I run
> fstrim *just* for the first time.
> 
> Any help will be appreciated.

Can you blktrace output for the devivce you're doing the fstrim on ?
Both when you run fstrim for the first time and then when you run it
again after releasing some blocks from the file system.

blktrace -d /dev/sda -o - | blkparse -i -

viz. man blktrace

Can you share how many a what size are the files you're releasing
before running fstrim again ? Are you using sync after removing
those files and before running fstrim (that's pretty important since
blocks are not released instantly from the ext4 file system - but you
can force it with sync).

I can confirm that fstrim on ext4 works as expected with loop image
and I do not see behaviour described by Jorge. I'll try thinp as
well to see what's going on.

Thanks!
-Lukas


> 
> Thanks,
> Jorge
> 
> _______________________________________________
> linux-lvm mailing list
> linux-lvm at redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
> 


More information about the linux-lvm mailing list